Skip to content

Commit b385fea

Browse files
author
rstaib
committed
Add GruntJS and new file structure
1 parent 0d9f4f8 commit b385fea

File tree

12 files changed

+226
-29
lines changed

12 files changed

+226
-29
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dist
2+
build/dist
3+
docs
4+
*~
5+
*.diff
6+
*.patch
7+
.DS_Store
8+
node_modules

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
node_js:
3+
- 0.10
4+
install:
5+
- npm install grunt-cli -g
6+
- npm install

Gruntfile.js

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*jshint node:true*/
2+
module.exports = function (grunt)
3+
{
4+
"use strict";
5+
6+
grunt.initConfig({
7+
pkg: grunt.file.readJSON('package.json'),
8+
concat: {
9+
dist: {
10+
files: {
11+
'dist/jquery.steps.js': ['jquery.steps.js']
12+
}
13+
}
14+
},
15+
uglify: {
16+
options: {
17+
preserveComments: false,
18+
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
19+
'<%= grunt.template.today("mm/dd/yyyy") %>\\r\\n' +
20+
'<%= pkg.homepage ? "* " + pkg.homepage + "\\r\\n" : "" %>' +
21+
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
22+
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
23+
},
24+
all: {
25+
files: {
26+
'dist/jquery.steps.min.js': ['dist/jquery.steps.js']
27+
}
28+
}
29+
},
30+
compress: {
31+
main: {
32+
options: {
33+
archive: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip'
34+
},
35+
files: [
36+
{
37+
src: [
38+
'README.md',
39+
/*'changelog.txt',*/
40+
'demo/** /*.*',
41+
'lib/*.*',
42+
'test/** /*.*'
43+
]
44+
},
45+
{
46+
flatten: true,
47+
src: ['dist/*.js'],
48+
filter: 'isFile'
49+
}
50+
]
51+
}
52+
},
53+
qunit: {
54+
files: ['test/index.html']
55+
},
56+
jshint: {
57+
options: {
58+
curly: true,
59+
eqeqeq: true,
60+
immed: true,
61+
latedef: true,
62+
newcap: true,
63+
noarg: true,
64+
sub: true,
65+
undef: true,
66+
eqnull: true,
67+
browser: true,
68+
globals: {
69+
jQuery: true,
70+
$: true,
71+
console: true
72+
}
73+
},
74+
files: [
75+
'jquery.steps.js'
76+
],
77+
test: {
78+
options: {
79+
globals: {
80+
jQuery: true,
81+
$: true,
82+
QUnit: true,
83+
module: true,
84+
test: true,
85+
start: true,
86+
stop: true,
87+
expect: true,
88+
ok: true,
89+
equal: true,
90+
deepEqual: true,
91+
strictEqual: true
92+
}
93+
},
94+
files: {
95+
src: [
96+
'test/test.js'
97+
]
98+
}
99+
},
100+
grunt: {
101+
files: {
102+
src: [
103+
'Gruntfile.js'
104+
]
105+
}
106+
}
107+
}
108+
});
109+
110+
grunt.loadNpmTasks('grunt-contrib-jshint');
111+
grunt.loadNpmTasks('grunt-contrib-qunit');
112+
grunt.loadNpmTasks('grunt-contrib-uglify');
113+
grunt.loadNpmTasks('grunt-contrib-concat');
114+
grunt.loadNpmTasks('grunt-contrib-yuidoc');
115+
grunt.loadNpmTasks('grunt-contrib-compress');
116+
117+
grunt.registerTask('default', ['jshint'/*, 'qunit'*/]);
118+
grunt.registerTask('release', ['default', 'concat'/*, 'yuidoc'*/, 'uglify', 'compress']);
119+
};

src/jquery.steps.css renamed to demos/css/jquery.steps.css

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
/* Common */
1+
.wizard
2+
{
3+
width: 600px;
4+
}
5+
6+
7+
8+
/* Common */
29
.wizard a
310
{
411
outline: 0;
@@ -22,7 +29,8 @@
2229

2330
.wizard > .steps
2431
{
25-
display: block;
32+
display: inline-block;
33+
width: 600px;
2634
}
2735

2836
.wizard > .steps .number
@@ -64,6 +72,12 @@
6472
background: #f00;
6573
}
6674

75+
.wizard > .content
76+
{
77+
display: inline-block;
78+
width: 600px;
79+
}
80+
6781
.wizard > .content > .title
6882
{
6983
position: absolute;
@@ -73,7 +87,7 @@
7387
.wizard > .content > .body
7488
{
7589
border: 1px solid #CCC;
76-
width: 50%;
90+
width: 100%;
7791
height: 200px;
7892
}
7993

@@ -84,6 +98,12 @@
8498
height: 200px;
8599
}
86100

101+
.wizard > .actions
102+
{
103+
display: inline-block;
104+
width: 600px;
105+
}
106+
87107
.wizard > .actions a.disabled
88108
{
89109
background: #ccc;

demos/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<meta name="viewport" content="width=device-width">
1212
<link rel="stylesheet" href="css/normalize.css">
1313
<link rel="stylesheet" href="css/main.css">
14-
<link rel="stylesheet" href="../src/jquery.steps.css">
15-
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
16-
<script src="js/vendor/jquery-1.9.1.min.js"></script>
17-
<script src="../src/jquery.steps.js"></script>
14+
<link rel="stylesheet" href="css/jquery.steps.css">
15+
<script src="../lib/modernizr-2.6.2.min.js"></script>
16+
<script src="../lib/jquery-1.9.1.min.js"></script>
17+
<script src="../jquery.steps.js"></script>
1818
</head>
1919
<body>
2020
<!--[if lt IE 7]>

src/jquery.steps.js renamed to jquery.steps.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131

132132
return this.each(function (i)
133133
{
134-
$this = $(this);
134+
var $this = $(this);
135135
$this.data("options", opts);
136136
$this.data("state", {
137137
currentIndex: opts.startIndex,
@@ -183,7 +183,7 @@
183183
}
184184

185185
// If nothing has changed
186-
if (oldIndex == state.currentIndex)
186+
if (oldIndex === state.currentIndex)
187187
{
188188
$(".steps a[href$=-" + oldIndex + "]", wizard).focus();
189189
return false;
@@ -242,7 +242,7 @@
242242
var $this = $(this);
243243
var state = $this.data("state");
244244

245-
return (index == state.currentStep) ? state.currentStep : getStepProperties($this, index);
245+
return (index === state.currentStep) ? state.currentStep : getStepProperties($this, index);
246246
};
247247

248248
/// <summary>
@@ -301,7 +301,7 @@
301301
$.fn.steps.remove = function (index)
302302
{
303303
// State must be modified
304-
throw new "Not yet implemented!";
304+
throw new Error("Not yet implemented!");
305305
};
306306

307307
/// <summary>
@@ -310,7 +310,7 @@
310310
$.fn.steps.insert = function (index, step)
311311
{
312312
// State must be modified
313-
throw new "Not yet implemented!";
313+
throw new Error("Not yet implemented!");
314314
};
315315

316316
/*
@@ -357,9 +357,9 @@
357357
var options = wizard.data("options");
358358
var state = wizard.data("state");
359359

360-
if (index < 0 || index >= state.stepCount || state.stepCount == 0)
360+
if (index < 0 || index >= state.stepCount || state.stepCount === 0)
361361
{
362-
throw new "Index out of range.";
362+
throw new Error("Index out of range.");
363363
}
364364

365365
if (options.forceMoveForward && index < state.currentIndex)
@@ -428,11 +428,11 @@
428428
}
429429
else
430430
{
431-
$(".steps li:eq(" + oldIndex + ")", wizard).addClass("error")
431+
$(".steps li:eq(" + oldIndex + ")", wizard).addClass("error");
432432
}
433433

434434
return true;
435-
};
435+
}
436436

437437
/// <summary>
438438
/// Transforms the initial html structure/code.
@@ -461,11 +461,11 @@
461461

462462
if (stepTitles.length > stepContents.length)
463463
{
464-
throw new "One or more corresponding step contents are missing.";
464+
throw new Error("One or more corresponding step contents are missing.");
465465
}
466466
else if (stepTitles.length < stepContents.length)
467467
{
468-
throw new "One or more corresponding step titles are missing.";
468+
throw new Error("One or more corresponding step titles are missing.");
469469
}
470470

471471
var stepsWrapper = $(document.createElement(options.stepsContainerTag)).addClass("steps");
@@ -476,7 +476,7 @@
476476

477477
stepTitles.each(function (index)
478478
{
479-
$header = $(this).attr("id", getUniqueId(wizard) + "-" + index).attr("tabindex", "-1");
479+
var $header = $(this).attr("id", getUniqueId(wizard) + "-" + index).attr("tabindex", "-1");
480480

481481
var title = null;
482482
var stepItem = $("<li></li>");
@@ -518,7 +518,7 @@
518518

519519
// Set state values
520520
state.stepCount = stepContents.length;
521-
state.currentStep = getStepProperties($this, state.currentIndex);
521+
state.currentStep = getStepProperties(wizard, state.currentIndex);
522522

523523
if (options.enablePagination)
524524
{
@@ -549,21 +549,22 @@
549549
/// </summary>
550550
function loadAsyncContent(wizard)
551551
{
552-
var options = wizard.data("options");
553-
var state = wizard.data("state");
552+
var options = wizard.data("options"),
553+
state = wizard.data("state");
554554

555555
if (!options.enableContentCache || !state.currentStep.contentLoaded)
556556
{
557+
var currentStepContent;
557558
switch (state.currentStep.contentMode)
558559
{
559560
case $.fn.steps.contentMode.iframe:
560-
var currentStepContent = $(".content > .body", wizard).eq(state.currentIndex);
561+
currentStepContent = $(".content > .body", wizard).eq(state.currentIndex);
561562
currentStepContent.html($("<iframe src=\"" + state.currentStep.contentUrl + "\" />"));
562563
currentStepContent.data("loaded", "1");
563564
break;
564565

565566
case $.fn.steps.contentMode.async:
566-
var currentStepContent = $(".content > .body", wizard).eq(state.currentIndex);
567+
currentStepContent = $(".content > .body", wizard).eq(state.currentIndex);
567568
currentStepContent.empty();
568569
$.ajax({ url: state.currentStep.contentUrl, cache: false }).done(function (data)
569570
{
@@ -603,7 +604,7 @@
603604

604605
if (options.enableFinishButton && options.showFinishButtonAlways)
605606
{
606-
if (state.stepCount == 0)
607+
if (state.stepCount === 0)
607608
{
608609
finish.addClass("disabled");
609610
next.addClass("disabled");
@@ -621,7 +622,7 @@
621622
}
622623
else
623624
{
624-
if (state.stepCount == 0)
625+
if (state.stepCount === 0)
625626
{
626627
finish.hide();
627628
next.show().addClass("disabled");
@@ -668,7 +669,7 @@
668669
{
669670
if (substitutes[key] === undefined)
670671
{
671-
throw new "The key \"" + key + "\" does not exist in the substitute collection!";
672+
throw new Error("The key \"" + key + "\" does not exist in the substitute collection!");
672673
}
673674

674675
return substitutes[key];
@@ -691,7 +692,7 @@
691692

692693
return {
693694
title: $header.html(),
694-
content: (mode == $.fn.steps.contentMode.html) ? $content.html() : "",
695+
content: (mode === $.fn.steps.contentMode.html) ? $content.html() : "",
695696
contentUrl: contentUrl,
696697
contentMode: mode,
697698
contentLoaded: contentLoaded
@@ -705,7 +706,7 @@
705706
{
706707
if (wizard.data("uid") === undefined)
707708
{
708-
wizard.data("uid", "steps-uid-" + ++uniqueId);
709+
wizard.data("uid", "steps-uid-".concat(++uniqueId));
709710
}
710711
}
711712

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)