Skip to content

Commit 14a7cce

Browse files
committed
Going to es6!
1 parent 3d3fc48 commit 14a7cce

File tree

10 files changed

+949
-742
lines changed

10 files changed

+949
-742
lines changed

.eslintrc

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
{
2+
"ecmaFeatures": {
3+
"arrowFunctions": true,
4+
"binaryLiterals": false,
5+
"blockBindings": true,
6+
"classes": true,
7+
"defaultParams": true,
8+
"destructuring": true,
9+
"forOf": true,
10+
"generators": true,
11+
"modules": false,
12+
"objectLiteralComputedProperties": true,
13+
"objectLiteralDuplicateProperties": false,
14+
"objectLiteralShorthandMethods": true,
15+
"objectLiteralShorthandProperties": true,
16+
"octalLiterals": false,
17+
"regexUFlag": false,
18+
"regexYFlag": false,
19+
"restParams": true,
20+
"spread": true,
21+
"superInFunctions": true,
22+
"templateStrings": true,
23+
"unicodePointEscapes": true,
24+
"globalReturn": false,
25+
"jsx": true
26+
},
27+
"env": {
28+
"jquery": true,
29+
"browser": true,
30+
"node": true
31+
},
32+
"parser": "babel-eslint",
33+
"plugins": [
34+
"babel"
35+
],
36+
"rules": {
37+
38+
/*Possible Errors */
39+
"no-cond-assign": [1, "except-parens"],
40+
"no-console": 0,
41+
"no-constant-condition": 1,
42+
"no-control-regex": 1,
43+
"no-debugger": 1,
44+
"no-dupe-args": 1,
45+
"no-dupe-keys": 1,
46+
"no-duplicate-case": 0,
47+
"no-empty-character-class": 1,
48+
"no-empty": 1,
49+
"no-ex-assign": 1,
50+
"no-extra-boolean-cast": 1,
51+
"no-extra-parens": 0,
52+
"no-extra-semi": 1,
53+
"no-func-assign": 1,
54+
"no-inner-declarations": [1, "functions"],
55+
"no-invalid-regexp": 1,
56+
"no-irregular-whitespace": 1,
57+
"no-negated-in-lhs": 1,
58+
"no-obj-calls": 1,
59+
"no-regex-spaces": 1,
60+
"no-reserved-keys": 0,
61+
"no-sparse-arrays": 1,
62+
"no-unexpected-multiline": 1,
63+
"no-unreachable": 1,
64+
"use-isnan": 1,
65+
"valid-typeof": 1,
66+
67+
/* Best Practices */
68+
"accessor-pairs": 0,
69+
"block-scoped-var": 0, // see Babel section
70+
"complexity": 0,
71+
"curly": [1, "all"],
72+
"default-case": 0,
73+
"dot-notation": [1, { "allowKeywords": true, "allowPattern": "" }],
74+
"dot-location": [1, "property"],
75+
"eqeqeq": 1,
76+
"guard-for-in": 0,
77+
"no-alert": 1,
78+
"no-caller": 1,
79+
"no-div-regex": 1,
80+
"no-empty-label": 1,
81+
"no-eq-null": 0,
82+
"no-eval": 1,
83+
"no-extend-native": 1,
84+
"no-extra-bind": 1,
85+
"no-fallthrough": 0,
86+
"no-floating-decimal": 1,
87+
"no-implied-eval": 1,
88+
"no-iterator": 1,
89+
"no-labels": 1,
90+
"no-lone-blocks": 1,
91+
"no-loop-func": 1,
92+
"no-multi-spaces": 1,
93+
"no-multi-str": 1,
94+
"no-native-reassign": 1,
95+
"no-new-func": 1,
96+
"no-new-wrappers": 1,
97+
"no-new": 1,
98+
"no-octal-escape": 1,
99+
"no-octal": 1,
100+
"no-param-reassign": 0,
101+
"no-process-env": 0,
102+
"no-proto": 1,
103+
"no-redeclare": 1,
104+
"no-return-assign": 1,
105+
"no-script-url": 1,
106+
"no-self-compare": 1,
107+
"no-sequences": 1,
108+
"no-throw-literal": 1,
109+
"no-unused-expressions": 0,
110+
"no-void": 0,
111+
"no-warning-comments": [1, { "terms": ["todo", "tofix"], "location": "start" }],
112+
"no-with": 1,
113+
"radix": 1,
114+
"vars-on-top": 1,
115+
"wrap-iife": [1, "inside"],
116+
"yoda": [1, "never"],
117+
118+
/* Strict Mode */
119+
"strict": [1, "never"],
120+
121+
/* Variables */
122+
"no-catch-shadow": 0,
123+
"no-delete-var": 1,
124+
"no-label-var": 1,
125+
"no-shadow": 1,
126+
"no-undef-init": 1,
127+
"no-undef": 1,
128+
"no-unused-vars": [1, { "vars": "local", "args": "after-used" }],
129+
"no-use-before-define": 1,
130+
131+
/* Node.js */
132+
"handle-callback-err": 1,
133+
"no-mixed-requires": 1,
134+
"no-new-require": 1,
135+
"no-path-concat": 1,
136+
"no-process-exit": 1,
137+
"no-restricted-modules": [1, ""], // add any unwanted Node.js core modules
138+
"no-sync": 1,
139+
140+
/* Stylistic Issues */
141+
"array-bracket-spacing": [1, "never"],
142+
"camelcase": [1, { "properties": "always" }],
143+
"comma-spacing": [1, { "before": false, "after": true }],
144+
"comma-style": [1, "last"],
145+
"computed-property-spacing": 0,
146+
"consistent-this": 0,
147+
"eol-last": 1,
148+
"func-names": 1,
149+
"func-style": 0,
150+
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
151+
"linebreak-style": 0,
152+
"max-nested-callbacks": [0, 3],
153+
"new-cap": 0, // see Babel section
154+
"new-parens": 1,
155+
"newline-after-var": 0,
156+
"no-array-constructor": 1,
157+
"no-continue": 1,
158+
"no-inline-comments": 0,
159+
"no-lonely-if": 1,
160+
"no-multiple-empty-lines": [1, { "max": 1 }],
161+
"no-nested-ternary": 0,
162+
"no-new-object": 1,
163+
"no-spaced-func": 1,
164+
"no-ternary": 0,
165+
"no-trailing-spaces": 1,
166+
"no-underscore-dangle": 0,
167+
"no-unneeded-ternary": 1,
168+
"object-curly-spacing": 0, // see Babel section
169+
"padded-blocks": [0, "never"],
170+
"quote-props": [0, "as-needed"],
171+
"quotes": [1, "single"],
172+
"semi-spacing": [1, { "before": false, "after": true }],
173+
"semi": [1, "always"],
174+
"sort-vars": 0,
175+
"space-after-keywords": 0,
176+
"space-before-blocks": [1, "always"],
177+
"space-in-parens": [1, "never"],
178+
"space-infix-ops": 1,
179+
"space-return-throw-case": 1,
180+
"space-unary-ops": 0,
181+
"spaced-comment": [1, "always"],
182+
"wrap-regex": 1,
183+
184+
/* ECMAScript 6 */
185+
"constructor-super": 1,
186+
"generator-star-spacing": 0, // see Babel section
187+
"no-this-before-super": 1,
188+
"no-var": 1,
189+
"object-shorthand": 0, // see Babel section
190+
"prefer-const": 1,
191+
192+
/* Legacy */
193+
"max-depth": [0, 3],
194+
"max-params": 0,
195+
"max-statements": 0,
196+
"no-bitwise": 1,
197+
198+
/* Babel */
199+
// "babel/block-scoped-var": 1,
200+
"babel/object-shorthand": [1, "always"],
201+
// "babel/generator-star": 1, // deprecated
202+
"babel/generator-star-spacing": [1, "after"],
203+
"babel/object-curly-spacing": [1, "always"],
204+
// "babel/space-in-brackets": 1, // deprecated
205+
}
206+
}

.jshintrc

Lines changed: 0 additions & 14 deletions
This file was deleted.

Gruntfile.js

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@ module.exports = function(grunt) {
1313
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
1414
// Task configuration.
1515
clean: {
16-
files: ['dist']
16+
dist: {
17+
src: 'dist'
18+
},
19+
tmp: {
20+
src: 'tmp'
21+
}
1722
},
1823
concat: {
1924
options: {
2025
banner: '<%= banner %>',
2126
stripBanners: true
2227
},
2328
dist: {
24-
src: ['src/jquery.<%= pkg.name %>.js'],
29+
src: ['dist/jquery.<%= pkg.name %>.js'],
2530
dest: 'dist/jquery.<%= pkg.name %>.js'
2631
},
2732
},
@@ -37,23 +42,14 @@ module.exports = function(grunt) {
3742
qunit: {
3843
files: ['test/**/*.html']
3944
},
40-
jshint: {
45+
eslint: {
4146
gruntfile: {
42-
options: {
43-
jshintrc: '.jshintrc'
44-
},
4547
src: 'Gruntfile.js'
4648
},
4749
src: {
48-
options: {
49-
jshintrc: 'src/.jshintrc'
50-
},
5150
src: ['src/**/*.js']
5251
},
5352
test: {
54-
options: {
55-
jshintrc: 'test/.jshintrc'
56-
},
5753
src: ['test/**/*.js']
5854
},
5955
},
@@ -71,20 +67,33 @@ module.exports = function(grunt) {
7167
tasks: ['jshint:test', 'qunit']
7268
},
7369
},
70+
babel: {
71+
options: {
72+
sourceMap: false,
73+
presets: ['es2015'],
74+
//plugins: ['transform-es2015-modules-amd']
75+
},
76+
dist: {
77+
files: {
78+
'dist/jquery.<%= pkg.name %>.js': 'src/jquery.<%= pkg.name %>.js'
79+
}
80+
}
81+
}
7482
});
7583

7684
// These plugins provide necessary tasks.
7785
grunt.loadNpmTasks('grunt-contrib-clean');
7886
grunt.loadNpmTasks('grunt-contrib-concat');
7987
grunt.loadNpmTasks('grunt-contrib-uglify');
8088
grunt.loadNpmTasks('grunt-contrib-qunit');
81-
grunt.loadNpmTasks('grunt-contrib-jshint');
89+
grunt.loadNpmTasks('grunt-eslint');
8290
grunt.loadNpmTasks('grunt-contrib-watch');
91+
grunt.loadNpmTasks('grunt-babel');
8392

8493
// Default task.
85-
grunt.registerTask('default', ['jshint', 'qunit', 'clean', 'concat', 'uglify']);
86-
94+
grunt.registerTask('default', ['eslint', 'clean:dist', 'babel', 'concat', 'qunit', 'uglify']);
95+
8796
// Travis CI task.
88-
grunt.registerTask('travis', ['jshint', 'qunit', 'clean', 'concat', 'uglify']);
97+
grunt.registerTask('travis', ['eslint', 'clean:dist', 'babel', 'concat', 'qunit', 'uglify']);
8998

9099
};

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ machine.prev(); //Previous element
4646
machine.next(); //Next element
4747
```
4848

49+
Stop the machine:
50+
51+
```javascript
52+
machine.stop();
53+
```
54+
4955
Get selected element:
5056

5157
```javascript
5258
machine.active; //Current element index
5359
```
5460

55-
Get the next selected element:
61+
Get the selected element if shuffling:
5662

5763
```javascript
5864
machine.futureActive; //Future active element index
@@ -61,13 +67,19 @@ machine.futureActive; //Future active element index
6167
Check if the machine is running:
6268

6369
```javascript
64-
machine.isRunning; //Returns boolean
70+
machine.running; //Returns boolean
6571
```
6672

6773
Check if the machine is stopping:
6874

6975
```javascript
70-
machine.isStopping; //Returns boolean
76+
machine.stopping; //Returns boolean
77+
```
78+
79+
Check if the machine is visible:
80+
81+
```javascript
82+
machine.visible; //Returns boolean
7183
```
7284

7385
Change spin result, if the returned value is out of bounds, the element will be randomly choosen:
@@ -79,7 +91,7 @@ machine.setRandomize(foo); //foo must be a function (should return int) or an in
7991
Change spin direction, machine must not be running:
8092

8193
```javascript
82-
machine.setDirection(direction); //direction must be a String ('up' || 'down')
94+
machine.direction = direction; //direction must be a String ('up' || 'down')
8395
```
8496

8597
## Params

0 commit comments

Comments
 (0)