Skip to content

Commit 627a17b

Browse files
committed
jshint
1 parent d6cadb0 commit 627a17b

File tree

2 files changed

+28
-40
lines changed

2 files changed

+28
-40
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<title>jQuery Knob demo</title>
5-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
5+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
66
<script src="js/jquery.knob.js"></script>
77
<script>
88
$(function($) {

js/jquery.knob.js

+27-39
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,15 @@
9090
min : this.$.data('min') || 0,
9191
max : this.$.data('max') || 100,
9292
stopper : true,
93-
readOnly : this.$.data('readonly') || (this.$.attr('readonly') == 'readonly'),
93+
readOnly : this.$.data('readonly') || (this.$.attr('readonly') === 'readonly'),
9494

9595
// UI
96-
cursor : (this.$.data('cursor') === true && 30)
97-
|| this.$.data('cursor')
98-
|| 0,
96+
cursor : (this.$.data('cursor') === true && 30) ||
97+
this.$.data('cursor') || 0,
9998
thickness : (
100-
this.$.data('thickness')
101-
&& Math.max(Math.min(this.$.data('thickness'), 1), 0.01)
102-
)
103-
|| 0.35,
99+
this.$.data('thickness') &&
100+
Math.max(Math.min(this.$.data('thickness'), 1), 0.01)
101+
) || 0.35,
104102
lineCap : this.$.data('linecap') || 'butt',
105103
width : this.$.data('width') || 200,
106104
height : this.$.data('height') || 200,
@@ -132,7 +130,7 @@
132130

133131
// fieldset = array of integer
134132
this.v = {};
135-
this.i = this.$.find('input')
133+
this.i = this.$.find('input');
136134
this.i.each(function(k) {
137135
var $this = $(this);
138136
s.i[k] = $this;
@@ -154,7 +152,7 @@
154152
// input = integer
155153
this.i = this.$;
156154
this.v = this.$.val();
157-
(this.v == '') && (this.v = this.o.min);
155+
(this.v === '') && (this.v = this.o.min);
158156

159157
this.$.bind(
160158
'change blur'
@@ -205,10 +203,10 @@
205203
);
206204

207205
// detects relative width / height
208-
this.relativeWidth = ((this.o.width % 1 !== 0)
209-
&& this.o.width.indexOf('%'));
210-
this.relativeHeight = ((this.o.height % 1 !== 0)
211-
&& this.o.height.indexOf('%'));
206+
this.relativeWidth = ((this.o.width % 1 !== 0) &&
207+
this.o.width.indexOf('%'));
208+
this.relativeHeight = ((this.o.height % 1 !== 0) &&
209+
this.o.height.indexOf('%'));
212210
this.relative = (this.relativeWidth || this.relativeHeight);
213211

214212
// computes size and carves the component
@@ -244,14 +242,14 @@
244242

245243
this._carve = function() {
246244
if(this.relative) {
247-
var w = this.relativeWidth
248-
? this.$div.parent().width()
249-
* parseInt(this.o.width) / 100
250-
: this.$div.parent().width(),
251-
h = this.relativeHeight
252-
? this.$div.parent().height()
253-
* parseInt(this.o.height) / 100
254-
: this.$div.parent().height();
245+
var w = this.relativeWidth ?
246+
this.$div.parent().width() *
247+
parseInt(this.o.width) / 100 :
248+
this.$div.parent().width(),
249+
h = this.relativeHeight ?
250+
this.$div.parent().height() *
251+
parseInt(this.o.height) / 100 :
252+
this.$div.parent().height();
255253

256254
// apply relative
257255
this.w = this.h = Math.min(w, h);
@@ -310,10 +308,7 @@
310308

311309
if (v == s.cv) return;
312310

313-
if (
314-
s.cH
315-
&& (s.cH(v) === false)
316-
) return;
311+
if (s.cH && (s.cH(v) === false)) return;
317312

318313
s.change(s._validate(v));
319314
s._draw();
@@ -343,13 +338,10 @@
343338

344339
var mouseMove = function (e) {
345340
var v = s.xy2val(e.pageX, e.pageY);
346-
341+
347342
if (v == s.cv) return;
348343

349-
if (
350-
s.cH
351-
&& (s.cH(v) === false)
352-
) return;
344+
if (s.cH && (s.cH(v) === false)) return;
353345

354346
s.change(s._validate(v));
355347
s._draw();
@@ -511,10 +503,8 @@
511503
if (null != v) {
512504

513505
if (
514-
triggerRelease !== false
515-
&& (v != this.v)
516-
&& this.rH
517-
&& (this.rH(v) === false)
506+
triggerRelease !== false && (v != this.v) && this.rH &&
507+
(this.rH(v) === false)
518508
) return;
519509

520510
this.cv = this.o.stopper ? max(min(v, this.o.max), this.o.min) : v;
@@ -544,8 +534,7 @@
544534
ret = ~~ (0.5 + (a * (this.o.max - this.o.min) / this.angleArc))
545535
+ this.o.min;
546536

547-
this.o.stopper
548-
&& (ret = max(min(ret, this.o.max), this.o.min));
537+
this.o.stopper && (ret = max(min(ret, this.o.max), this.o.min));
549538

550539
return ret;
551540
};
@@ -612,8 +601,7 @@
612601

613602
var v = parseInt(s.$.val()) + kv[kc] * m;
614603

615-
s.o.stopper
616-
&& (v = max(min(v, s.o.max), s.o.min));
604+
s.o.stopper && (v = max(min(v, s.o.max), s.o.min));
617605

618606
s.change(v);
619607
s._draw();

0 commit comments

Comments
 (0)