Skip to content

Commit f611723

Browse files
committed
Update JSHint rules and abide by them
1 parent eff1513 commit f611723

File tree

2 files changed

+45
-44
lines changed

2 files changed

+45
-44
lines changed

.jshintrc

+32-27
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
{
22
// strict
3-
"bitwise": true,
4-
"camelcase": true,
5-
"curly": true,
6-
"eqeqeq": true,
7-
"es3": false,
8-
"forin": false,
9-
"freeze": false,
10-
"immed": true,
11-
"indent": 4,
12-
"latedef": true,
13-
"newcap": true,
14-
"noarg": true,
15-
"noempty": true,
16-
"nonew": false,
17-
"plusplus": false,
18-
"quotmark": true,
19-
"undef": true,
20-
"strict": true,
21-
"trailing": true,
22-
"maxparams": 4,
23-
"maxdepth": 5,
24-
"maxstatements": 20,
25-
"maxlen": 120,
3+
"bitwise": false,
4+
"camelcase": true,
5+
"curly": false,
6+
"eqeqeq": false,
7+
"es3": false,
8+
"forin": false,
9+
"freeze": false,
10+
"immed": true,
11+
"indent": 4,
12+
"latedef": true,
13+
"newcap": true,
14+
"noarg": true,
15+
"noempty": true,
16+
"nonew": false,
17+
"plusplus": false,
18+
"quotmark": "single",
19+
"undef": true,
20+
"strict": true,
21+
"trailing": true,
22+
"unused": true,
23+
"expr": true,
24+
25+
// relax
26+
"boss": true,
27+
"eqnull": true,
28+
"supernew": true,
29+
"validthis": true,
2630

2731
// environment
28-
"browser": true,
32+
"browser": true,
2933

3034
// globals
3135
"globals": {
32-
"jQuery": true,
33-
"module": true,
34-
"define": false
36+
"module": true,
37+
"define": false,
38+
"require": false,
39+
"jQuery": false
3540
}
3641
}

src/easyzoom.js

+13-17
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@
5353
this.$flyout = $('<div class="easyzoom-flyout" />');
5454
this.$notice = $('<div class="easyzoom-notice" />');
5555

56-
this.$target
57-
.on('mousemove.easyzoom touchmove.easyzoom', $.proxy(this._onMove, this))
58-
.on('mouseleave.easyzoom touchend.easyzoom', $.proxy(this._onLeave, this))
59-
.on('mouseenter.easyzoom touchstart.easyzoom', $.proxy(this._onEnter, this));
56+
this.$target.on({
57+
'mousemove.easyzoom touchmove.easyzoom': $.proxy(this._onMove, this),
58+
'mouseleave.easyzoom touchend.easyzoom': $.proxy(this._onLeave, this),
59+
'mouseenter.easyzoom touchstart.easyzoom': $.proxy(this._onEnter, this)
60+
});
6061

61-
this.opts.preventClicks &&this.$target.on('click.easyzoom', function(e) {
62+
this.opts.preventClicks && this.$target.on('click.easyzoom', function(e) {
6263
e.preventDefault();
6364
});
6465
};
@@ -111,7 +112,7 @@
111112

112113
this.isMouseOver = true;
113114

114-
if (touches && touches.length == 1) {
115+
if (!touches || touches.length == 1) {
115116
e.preventDefault();
116117
this.show(e, true);
117118
}
@@ -132,9 +133,8 @@
132133
/**
133134
* On leave
134135
* @private
135-
* @param {Event} e
136136
*/
137-
EasyZoom.prototype._onLeave = function(e) {
137+
EasyZoom.prototype._onLeave = function() {
138138
this.isMouseOver = false;
139139
this.isOpen && this.hide();
140140
};
@@ -180,7 +180,7 @@
180180
* @param {Function} callback
181181
*/
182182
EasyZoom.prototype._loadImage = function(href, callback) {
183-
var zoom = new Image();
183+
var zoom = new Image;
184184

185185
this.$target
186186
.addClass('is-loading')
@@ -205,8 +205,7 @@
205205
var touchlist = e.touches || e.originalEvent.touches;
206206
lx = touchlist[0].pageX;
207207
ly = touchlist[0].pageY;
208-
}
209-
else {
208+
} else {
210209
lx = e.pageX || lx;
211210
ly = e.pageY || ly;
212211
}
@@ -220,8 +219,7 @@
220219
// Close if outside
221220
if (xl < 0 || xt < 0 || xl > dw || xt > dh) {
222221
this.hide();
223-
}
224-
else {
222+
} else {
225223
var top = xt * -1;
226224
var left = xl * -1;
227225

@@ -300,8 +298,7 @@
300298

301299
if (!api) {
302300
$.data(this, 'easyZoom', new EasyZoom(this, options));
303-
}
304-
else if (api.isOpen === undefined) {
301+
} else if (api.isOpen === undefined) {
305302
api._init();
306303
}
307304
});
@@ -312,8 +309,7 @@
312309
define(function() {
313310
return EasyZoom;
314311
});
315-
}
316-
else if (typeof module !== 'undefined' && module.exports) {
312+
} else if (typeof module !== 'undefined' && module.exports) {
317313
module.exports = EasyZoom;
318314
}
319315

0 commit comments

Comments
 (0)