bootstrap-slider-rails 6.0.4 → 6.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2035d712f3c121668276115e31036f24f3b2a459
4
- data.tar.gz: 20db5f8228ce60e118bb0c66bfa4704112b5e824
3
+ metadata.gz: 89339a909de0a4dcfedd50c03b6b3ee6411a7d4c
4
+ data.tar.gz: f8abad9fa6692b0a681e9e6fac47aa379df638fb
5
5
  SHA512:
6
- metadata.gz: 6191f2b3aba12d34ce02e360596c6ecaa5f4bacdcd92e74d35dc1d805f2392151d84bef4331fa93debc869bc086fcbaf8f069fc7ea36173150051cdf03607b8f
7
- data.tar.gz: b49f0b568ba6cde1744a10741e655330b95eeb732416d285af00b36fd41d376a073bd7aeb7f138149e15094bc31f8e87476286ca9227ceca3739fc321e6a1445
6
+ metadata.gz: ee0b58bae585f04db64478f6b07340ad1ef66e95f71f257b3289971e572bd35ae6d75be1d0c647a6b3389cfeee328b29e53d03330226b7eefd5efa3794e9dcc5
7
+ data.tar.gz: d75bf84c32245c48b2e2fa79c6f2736c647f0bd6cde6e094e45d9b8309326cb8906678bc51a06eaff589934a80257ed73699365ca5969ebb00ec68831948b3fe
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ task :update do
7
7
  base_url = 'https://raw.githubusercontent.com/seiyria/bootstrap-slider'
8
8
  puts "Downlading Bootstrap-slider #{version} ..."
9
9
  js = system("curl -fo vendor/assets/javascripts/bootstrap-slider.js " \
10
- "#{base_url}/v#{version}/src/js/bootstrap-slider.js")
10
+ "#{base_url}/v#{version}/dist/bootstrap-slider.js")
11
11
  css = system("curl -fo vendor/assets/stylesheets/bootstrap-slider.css " \
12
12
  "#{base_url}/v#{version}/dist/css/bootstrap-slider.css")
13
13
 
@@ -1,5 +1,5 @@
1
1
  module BootstrapSlider
2
2
  module Rails
3
- VERSION = '6.0.4'
3
+ VERSION = '6.0.5'
4
4
  end
5
5
  end
data/make_new_release.sh CHANGED
@@ -19,10 +19,13 @@ fi
19
19
  echo "Updating library code to version $LIBRARY_NEW_VERSION ..."
20
20
  docker run --rm -v `pwd`:/gem/ "$DOCKER_IMAGE_NAME" rake update
21
21
 
22
- LIBRARY_UPDATED=`git status --porcelain`
22
+ LIBRARY_UPDATED=`git status --porcelain | grep -v make_new_release.sh`
23
23
  if [[ -z "$LIBRARY_UPDATED" ]]; then
24
24
  echo "No update found, stopping release creation."
25
25
  exit 1
26
+ elif [[ "$LIBRARY_UPDATED" == " M lib/bootstrap-slider-rails/version.rb" ]]; then
27
+ echo "None of the JS or CSS files have been updated."
28
+ exit 1
26
29
  fi
27
30
 
28
31
  echo "Committing new version ..."
@@ -1,3 +1,10 @@
1
+ /*! =======================================================
2
+ VERSION 6.0.4
3
+ ========================================================= */
4
+ "use strict";
5
+
6
+ function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
7
+
1
8
  /*! =========================================================
2
9
  * bootstrap-slider.js
3
10
  *
@@ -24,36 +31,31 @@
24
31
  * limitations under the License.
25
32
  * ========================================================= */
26
33
 
27
-
28
34
  /**
29
35
  * Bridget makes jQuery widgets
30
36
  * v1.0.1
31
37
  * MIT license
32
38
  */
33
39
 
34
- (function(factory) {
35
- if(typeof define === "function" && define.amd) {
40
+ (function (factory) {
41
+ if (typeof define === "function" && define.amd) {
36
42
  define(["jquery"], factory);
37
- }
38
- else if(typeof module === "object" && module.exports) {
43
+ } else if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === "object" && module.exports) {
39
44
  var jQuery;
40
45
  try {
41
46
  jQuery = require("jquery");
42
- }
43
- catch (err) {
47
+ } catch (err) {
44
48
  jQuery = null;
45
49
  }
46
50
  module.exports = factory(jQuery);
47
- }
48
- else if(window) {
51
+ } else if (window) {
49
52
  window.Slider = factory(window.jQuery);
50
53
  }
51
- }(function($) {
54
+ })(function ($) {
52
55
  // Reference to Slider constructor
53
56
  var Slider;
54
57
 
55
-
56
- (function( $ ) {
58
+ (function ($) {
57
59
 
58
60
  'use strict';
59
61
 
@@ -65,155 +67,149 @@
65
67
 
66
68
  // -------------------------- definition -------------------------- //
67
69
 
68
- function defineBridget( $ ) {
70
+ function defineBridget($) {
69
71
 
70
72
  // bail if no jQuery
71
- if ( !$ ) {
73
+ if (!$) {
72
74
  return;
73
75
  }
74
76
 
75
77
  // -------------------------- addOptionMethod -------------------------- //
76
78
 
77
79
  /**
78
- * adds option method -> $().plugin('option', {...})
79
- * @param {Function} PluginClass - constructor class
80
- */
81
- function addOptionMethod( PluginClass ) {
80
+ * adds option method -> $().plugin('option', {...})
81
+ * @param {Function} PluginClass - constructor class
82
+ */
83
+ function addOptionMethod(PluginClass) {
82
84
  // don't overwrite original option method
83
- if ( PluginClass.prototype.option ) {
85
+ if (PluginClass.prototype.option) {
84
86
  return;
85
87
  }
86
88
 
87
- // option setter
88
- PluginClass.prototype.option = function( opts ) {
89
- // bail out if not an object
90
- if ( !$.isPlainObject( opts ) ){
91
- return;
92
- }
93
- this.options = $.extend( true, this.options, opts );
94
- };
89
+ // option setter
90
+ PluginClass.prototype.option = function (opts) {
91
+ // bail out if not an object
92
+ if (!$.isPlainObject(opts)) {
93
+ return;
94
+ }
95
+ this.options = $.extend(true, this.options, opts);
96
+ };
95
97
  }
96
98
 
97
-
98
99
  // -------------------------- plugin bridge -------------------------- //
99
100
 
100
101
  // helper function for logging errors
101
102
  // $.error breaks jQuery chaining
102
- var logError = typeof console === 'undefined' ? noop :
103
- function( message ) {
104
- console.error( message );
105
- };
103
+ var logError = typeof console === 'undefined' ? noop : function (message) {
104
+ console.error(message);
105
+ };
106
106
 
107
107
  /**
108
- * jQuery plugin bridge, access methods like $elem.plugin('method')
109
- * @param {String} namespace - plugin name
110
- * @param {Function} PluginClass - constructor class
111
- */
112
- function bridge( namespace, PluginClass ) {
113
- // add to jQuery fn namespace
114
- $.fn[ namespace ] = function( options ) {
115
- if ( typeof options === 'string' ) {
116
- // call plugin method when first argument is a string
117
- // get arguments for method
118
- var args = slice.call( arguments, 1 );
119
-
120
- for ( var i=0, len = this.length; i < len; i++ ) {
121
- var elem = this[i];
122
- var instance = $.data( elem, namespace );
123
- if ( !instance ) {
124
- logError( "cannot call methods on " + namespace + " prior to initialization; " +
125
- "attempted to call '" + options + "'" );
126
- continue;
127
- }
128
- if ( !$.isFunction( instance[options] ) || options.charAt(0) === '_' ) {
129
- logError( "no such method '" + options + "' for " + namespace + " instance" );
130
- continue;
131
- }
132
-
133
- // trigger method with arguments
134
- var returnValue = instance[ options ].apply( instance, args);
135
-
136
- // break look and return first value if provided
137
- if ( returnValue !== undefined && returnValue !== instance) {
138
- return returnValue;
139
- }
140
- }
141
- // return this if no return value
142
- return this;
143
- } else {
144
- var objects = this.map( function() {
145
- var instance = $.data( this, namespace );
146
- if ( instance ) {
147
- // apply options & init
148
- instance.option( options );
149
- instance._init();
150
- } else {
151
- // initialize new instance
152
- instance = new PluginClass( this, options );
153
- $.data( this, namespace, instance );
154
- }
155
- return $(this);
156
- });
157
-
158
- if(!objects || objects.length > 1) {
159
- return objects;
160
- } else {
161
- return objects[0];
162
- }
163
- }
164
- };
108
+ * jQuery plugin bridge, access methods like $elem.plugin('method')
109
+ * @param {String} namespace - plugin name
110
+ * @param {Function} PluginClass - constructor class
111
+ */
112
+ function bridge(namespace, PluginClass) {
113
+ // add to jQuery fn namespace
114
+ $.fn[namespace] = function (options) {
115
+ if (typeof options === 'string') {
116
+ // call plugin method when first argument is a string
117
+ // get arguments for method
118
+ var args = slice.call(arguments, 1);
119
+
120
+ for (var i = 0, len = this.length; i < len; i++) {
121
+ var elem = this[i];
122
+ var instance = $.data(elem, namespace);
123
+ if (!instance) {
124
+ logError("cannot call methods on " + namespace + " prior to initialization; " + "attempted to call '" + options + "'");
125
+ continue;
126
+ }
127
+ if (!$.isFunction(instance[options]) || options.charAt(0) === '_') {
128
+ logError("no such method '" + options + "' for " + namespace + " instance");
129
+ continue;
130
+ }
165
131
 
132
+ // trigger method with arguments
133
+ var returnValue = instance[options].apply(instance, args);
134
+
135
+ // break look and return first value if provided
136
+ if (returnValue !== undefined && returnValue !== instance) {
137
+ return returnValue;
138
+ }
139
+ }
140
+ // return this if no return value
141
+ return this;
142
+ } else {
143
+ var objects = this.map(function () {
144
+ var instance = $.data(this, namespace);
145
+ if (instance) {
146
+ // apply options & init
147
+ instance.option(options);
148
+ instance._init();
149
+ } else {
150
+ // initialize new instance
151
+ instance = new PluginClass(this, options);
152
+ $.data(this, namespace, instance);
153
+ }
154
+ return $(this);
155
+ });
156
+
157
+ if (!objects || objects.length > 1) {
158
+ return objects;
159
+ } else {
160
+ return objects[0];
161
+ }
162
+ }
163
+ };
166
164
  }
167
165
 
168
166
  // -------------------------- bridget -------------------------- //
169
167
 
170
168
  /**
171
- * converts a Prototypical class into a proper jQuery plugin
172
- * the class must have a ._init method
173
- * @param {String} namespace - plugin name, used in $().pluginName
174
- * @param {Function} PluginClass - constructor class
175
- */
176
- $.bridget = function( namespace, PluginClass ) {
177
- addOptionMethod( PluginClass );
178
- bridge( namespace, PluginClass );
169
+ * converts a Prototypical class into a proper jQuery plugin
170
+ * the class must have a ._init method
171
+ * @param {String} namespace - plugin name, used in $().pluginName
172
+ * @param {Function} PluginClass - constructor class
173
+ */
174
+ $.bridget = function (namespace, PluginClass) {
175
+ addOptionMethod(PluginClass);
176
+ bridge(namespace, PluginClass);
179
177
  };
180
178
 
181
179
  return $.bridget;
182
-
183
180
  }
184
181
 
185
- // get jquery from browser global
186
- defineBridget( $ );
187
-
188
- })( $ );
189
-
182
+ // get jquery from browser global
183
+ defineBridget($);
184
+ })($);
190
185
 
191
186
  /*************************************************
187
+ BOOTSTRAP-SLIDER SOURCE CODE
188
+ **************************************************/
192
189
 
193
- BOOTSTRAP-SLIDER SOURCE CODE
194
-
195
- **************************************************/
196
-
197
- (function($) {
190
+ (function ($) {
198
191
 
199
192
  var ErrorMsgs = {
200
- formatInvalidInputErrorMsg : function(input) {
193
+ formatInvalidInputErrorMsg: function formatInvalidInputErrorMsg(input) {
201
194
  return "Invalid input value '" + input + "' passed in";
202
195
  },
203
- callingContextNotSliderInstance : "Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method"
196
+ callingContextNotSliderInstance: "Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method"
204
197
  };
205
198
 
206
199
  var SliderScale = {
207
200
  linear: {
208
- toValue: function(percentage) {
209
- var rawValue = percentage/100 * (this.options.max - this.options.min);
201
+ toValue: function toValue(percentage) {
202
+ var rawValue = percentage / 100 * (this.options.max - this.options.min);
210
203
  var shouldAdjustWithBase = true;
211
204
  if (this.options.ticks_positions.length > 0) {
212
- var minv, maxv, minp, maxp = 0;
205
+ var minv,
206
+ maxv,
207
+ minp,
208
+ maxp = 0;
213
209
  for (var i = 1; i < this.options.ticks_positions.length; i++) {
214
210
  if (percentage <= this.options.ticks_positions[i]) {
215
- minv = this.options.ticks[i-1];
216
- minp = this.options.ticks_positions[i-1];
211
+ minv = this.options.ticks[i - 1];
212
+ minp = this.options.ticks_positions[i - 1];
217
213
  maxv = this.options.ticks[i];
218
214
  maxp = this.options.ticks_positions[i];
219
215
 
@@ -235,17 +231,20 @@
235
231
  return value;
236
232
  }
237
233
  },
238
- toPercentage: function(value) {
234
+ toPercentage: function toPercentage(value) {
239
235
  if (this.options.max === this.options.min) {
240
236
  return 0;
241
237
  }
242
238
 
243
239
  if (this.options.ticks_positions.length > 0) {
244
- var minv, maxv, minp, maxp = 0;
240
+ var minv,
241
+ maxv,
242
+ minp,
243
+ maxp = 0;
245
244
  for (var i = 0; i < this.options.ticks.length; i++) {
246
- if (value <= this.options.ticks[i]) {
247
- minv = (i > 0) ? this.options.ticks[i-1] : 0;
248
- minp = (i > 0) ? this.options.ticks_positions[i-1] : 0;
245
+ if (value <= this.options.ticks[i]) {
246
+ minv = i > 0 ? this.options.ticks[i - 1] : 0;
247
+ minp = i > 0 ? this.options.ticks_positions[i - 1] : 0;
249
248
  maxv = this.options.ticks[i];
250
249
  maxp = this.options.ticks_positions[i];
251
250
 
@@ -264,13 +263,13 @@
264
263
 
265
264
  logarithmic: {
266
265
  /* Based on http://stackoverflow.com/questions/846221/logarithmic-slider */
267
- toValue: function(percentage) {
268
- var min = (this.options.min === 0) ? 0 : Math.log(this.options.min);
266
+ toValue: function toValue(percentage) {
267
+ var min = this.options.min === 0 ? 0 : Math.log(this.options.min);
269
268
  var max = Math.log(this.options.max);
270
269
  var value = Math.exp(min + (max - min) * percentage / 100);
271
270
  value = this.options.min + Math.round((value - this.options.min) / this.options.step) * this.options.step;
272
271
  /* Rounding to the nearest step could exceed the min or
273
- * max, so clip to those values. */
272
+ * max, so clip to those values. */
274
273
  if (value < this.options.min) {
275
274
  return this.options.min;
276
275
  } else if (value > this.options.max) {
@@ -279,7 +278,7 @@
279
278
  return value;
280
279
  }
281
280
  },
282
- toPercentage: function(value) {
281
+ toPercentage: function toPercentage(value) {
283
282
  if (this.options.max === this.options.min) {
284
283
  return 0;
285
284
  } else {
@@ -292,13 +291,10 @@
292
291
  }
293
292
  };
294
293
 
295
-
296
294
  /*************************************************
297
-
298
- CONSTRUCTOR
299
-
300
- **************************************************/
301
- Slider = function(element, options) {
295
+ CONSTRUCTOR
296
+ **************************************************/
297
+ Slider = function (element, options) {
302
298
  createNewSlider.call(this, element, options);
303
299
  return this;
304
300
  };
@@ -306,10 +302,9 @@
306
302
  function createNewSlider(element, options) {
307
303
 
308
304
  /*
309
- The internal state object is used to store data about the current 'state' of slider.
310
-
311
- This includes values such as the `value`, `enabled`, etc...
312
- */
305
+ The internal state object is used to store data about the current 'state' of slider.
306
+ This includes values such as the `value`, `enabled`, etc...
307
+ */
313
308
  this._state = {
314
309
  value: null,
315
310
  enabled: null,
@@ -320,53 +315,47 @@
320
315
  over: false
321
316
  };
322
317
 
323
-
324
- if(typeof element === "string") {
318
+ if (typeof element === "string") {
325
319
  this.element = document.querySelector(element);
326
- } else if(element instanceof HTMLElement) {
320
+ } else if (element instanceof HTMLElement) {
327
321
  this.element = element;
328
322
  }
329
323
 
330
324
  /*************************************************
331
-
332
- Process Options
333
-
334
- **************************************************/
325
+ Process Options
326
+ **************************************************/
335
327
  options = options ? options : {};
336
328
  var optionTypes = Object.keys(this.defaultOptions);
337
329
 
338
- for(var i = 0; i < optionTypes.length; i++) {
330
+ for (var i = 0; i < optionTypes.length; i++) {
339
331
  var optName = optionTypes[i];
340
332
 
341
333
  // First check if an option was passed in via the constructor
342
334
  var val = options[optName];
343
335
  // If no data attrib, then check data atrributes
344
- val = (typeof val !== 'undefined') ? val : getDataAttrib(this.element, optName);
336
+ val = typeof val !== 'undefined' ? val : getDataAttrib(this.element, optName);
345
337
  // Finally, if nothing was specified, use the defaults
346
- val = (val !== null) ? val : this.defaultOptions[optName];
338
+ val = val !== null ? val : this.defaultOptions[optName];
347
339
 
348
340
  // Set all options on the instance of the Slider
349
- if(!this.options) {
341
+ if (!this.options) {
350
342
  this.options = {};
351
343
  }
352
344
  this.options[optName] = val;
353
345
  }
354
346
 
355
347
  /*
356
- Validate `tooltip_position` against 'orientation`
357
- - if `tooltip_position` is incompatible with orientation, swith it to a default compatible with specified `orientation`
358
- -- default for "vertical" -> "right"
359
- -- default for "horizontal" -> "left"
360
- */
361
- if(this.options.orientation === "vertical" && (this.options.tooltip_position === "top" || this.options.tooltip_position === "bottom")) {
362
-
363
- this.options.tooltip_position = "right";
348
+ Validate `tooltip_position` against 'orientation`
349
+ - if `tooltip_position` is incompatible with orientation, swith it to a default compatible with specified `orientation`
350
+ -- default for "vertical" -> "right"
351
+ -- default for "horizontal" -> "left"
352
+ */
353
+ if (this.options.orientation === "vertical" && (this.options.tooltip_position === "top" || this.options.tooltip_position === "bottom")) {
364
354
 
365
- }
366
- else if(this.options.orientation === "horizontal" && (this.options.tooltip_position === "left" || this.options.tooltip_position === "right")) {
367
-
368
- this.options.tooltip_position = "top";
355
+ this.options.tooltip_position = "right";
356
+ } else if (this.options.orientation === "horizontal" && (this.options.tooltip_position === "left" || this.options.tooltip_position === "right")) {
369
357
 
358
+ this.options.tooltip_position = "top";
370
359
  }
371
360
 
372
361
  function getDataAttrib(element, optName) {
@@ -375,17 +364,14 @@
375
364
 
376
365
  try {
377
366
  return JSON.parse(dataValString);
378
- }
379
- catch(err) {
367
+ } catch (err) {
380
368
  return dataValString;
381
369
  }
382
370
  }
383
371
 
384
372
  /*************************************************
385
-
386
- Create Markup
387
-
388
- **************************************************/
373
+ Create Markup
374
+ **************************************************/
389
375
 
390
376
  var origWidth = this.element.style.width;
391
377
  var updateSlider = false;
@@ -469,7 +455,7 @@
469
455
  for (i = 0; i < this.options.ticks_labels.length; i++) {
470
456
  var label = document.createElement('div');
471
457
  var noTickPositionsSpecified = this.options.ticks_positions.length === 0;
472
- var tickLabelsIndex = (this.options.reversed && noTickPositionsSpecified) ? (this.options.ticks_labels.length - (i + 1)) : i;
458
+ var tickLabelsIndex = this.options.reversed && noTickPositionsSpecified ? this.options.ticks_labels.length - (i + 1) : i;
473
459
  label.className = 'slider-tick-label';
474
460
  label.innerHTML = this.options.ticks_labels[tickLabelsIndex];
475
461
 
@@ -478,8 +464,7 @@
478
464
  }
479
465
  }
480
466
 
481
-
482
- var createAndAppendTooltipSubElements = function(tooltipElem) {
467
+ var createAndAppendTooltipSubElements = function createAndAppendTooltipSubElements(tooltipElem) {
483
468
  var arrow = document.createElement("div");
484
469
  arrow.className = "tooltip-arrow";
485
470
 
@@ -488,7 +473,6 @@
488
473
 
489
474
  tooltipElem.appendChild(arrow);
490
475
  tooltipElem.appendChild(inner);
491
-
492
476
  };
493
477
 
494
478
  /* Create tooltip elements */
@@ -507,7 +491,6 @@
507
491
  sliderTooltipMax.setAttribute('role', 'presentation');
508
492
  createAndAppendTooltipSubElements(sliderTooltipMax);
509
493
 
510
-
511
494
  /* Append components to sliderElem */
512
495
  this.sliderElem.appendChild(sliderTrack);
513
496
  this.sliderElem.appendChild(sliderTooltip);
@@ -525,20 +508,18 @@
525
508
  this.element.style.display = "none";
526
509
  }
527
510
  /* If JQuery exists, cache JQ references */
528
- if($) {
511
+ if ($) {
529
512
  this.$element = $(this.element);
530
513
  this.$sliderElem = $(this.sliderElem);
531
514
  }
532
515
 
533
516
  /*************************************************
534
-
535
- Setup
536
-
537
- **************************************************/
517
+ Setup
518
+ **************************************************/
538
519
  this.eventToCallbackMap = {};
539
520
  this.sliderElem.id = this.options.id;
540
521
 
541
- this.touchCapable = 'ontouchstart' in window || (window.DocumentTouch && document instanceof window.DocumentTouch);
522
+ this.touchCapable = 'ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch;
542
523
 
543
524
  this.tooltip = this.sliderElem.querySelector('.tooltip-main');
544
525
  this.tooltipInner = this.tooltip.querySelector('.tooltip-inner');
@@ -547,7 +528,7 @@
547
528
  this.tooltipInner_min = this.tooltip_min.querySelector('.tooltip-inner');
548
529
 
549
530
  this.tooltip_max = this.sliderElem.querySelector('.tooltip-max');
550
- this.tooltipInner_max= this.tooltip_max.querySelector('.tooltip-inner');
531
+ this.tooltipInner_max = this.tooltip_max.querySelector('.tooltip-inner');
551
532
 
552
533
  if (SliderScale[this.options.scale]) {
553
534
  this.options.scale = SliderScale[this.options.scale];
@@ -562,20 +543,20 @@
562
543
  this._removeClass(this.tooltip_max, 'hide');
563
544
 
564
545
  // Undo existing inline styles for track
565
- ["left", "top", "width", "height"].forEach(function(prop) {
546
+ ["left", "top", "width", "height"].forEach(function (prop) {
566
547
  this._removeProperty(this.trackLow, prop);
567
548
  this._removeProperty(this.trackSelection, prop);
568
549
  this._removeProperty(this.trackHigh, prop);
569
550
  }, this);
570
551
 
571
552
  // Undo inline styles on handles
572
- [this.handle1, this.handle2].forEach(function(handle) {
553
+ [this.handle1, this.handle2].forEach(function (handle) {
573
554
  this._removeProperty(handle, 'left');
574
555
  this._removeProperty(handle, 'top');
575
556
  }, this);
576
557
 
577
558
  // Undo inline styles and classes on tooltips
578
- [this.tooltip, this.tooltip_min, this.tooltip_max].forEach(function(tooltip) {
559
+ [this.tooltip, this.tooltip_min, this.tooltip_max].forEach(function (tooltip) {
579
560
  this._removeProperty(tooltip, 'left');
580
561
  this._removeProperty(tooltip, 'top');
581
562
  this._removeProperty(tooltip, 'margin-left');
@@ -586,8 +567,8 @@
586
567
  }, this);
587
568
  }
588
569
 
589
- if(this.options.orientation === 'vertical') {
590
- this._addClass(this.sliderElem,'slider-vertical');
570
+ if (this.options.orientation === 'vertical') {
571
+ this._addClass(this.sliderElem, 'slider-vertical');
591
572
  this.stylePos = 'top';
592
573
  this.mousePos = 'pageY';
593
574
  this.sizePos = 'offsetHeight';
@@ -598,24 +579,21 @@
598
579
  this.stylePos = 'left';
599
580
  this.mousePos = 'pageX';
600
581
  this.sizePos = 'offsetWidth';
601
-
602
582
  }
603
583
  this._setTooltipPosition();
604
584
  /* In case ticks are specified, overwrite the min and max bounds */
605
585
  if (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) {
606
- this.options.max = Math.max.apply(Math, this.options.ticks);
607
- this.options.min = Math.min.apply(Math, this.options.ticks);
586
+ this.options.max = Math.max.apply(Math, this.options.ticks);
587
+ this.options.min = Math.min.apply(Math, this.options.ticks);
608
588
  }
609
589
 
610
590
  if (Array.isArray(this.options.value)) {
611
591
  this.options.range = true;
612
592
  this._state.value = this.options.value;
613
- }
614
- else if (this.options.range) {
593
+ } else if (this.options.range) {
615
594
  // User wants a range, but value is not an array
616
595
  this._state.value = [this.options.value, this.options.max];
617
- }
618
- else {
596
+ } else {
619
597
  this._state.value = this.options.value;
620
598
  }
621
599
 
@@ -658,10 +636,8 @@
658
636
  this.setValue(this._state.value);
659
637
 
660
638
  /******************************************
661
-
662
- Bind Event Listeners
663
-
664
- ******************************************/
639
+ Bind Event Listeners
640
+ ******************************************/
665
641
 
666
642
  // Bind keyboard handlers
667
643
  this.handle1Keydown = this._keydown.bind(this, 0);
@@ -681,18 +657,15 @@
681
657
  this.resize = this._resize.bind(this);
682
658
  window.addEventListener("resize", this.resize, false);
683
659
 
684
-
685
660
  // Bind tooltip-related handlers
686
- if(this.options.tooltip === 'hide') {
661
+ if (this.options.tooltip === 'hide') {
687
662
  this._addClass(this.tooltip, 'hide');
688
663
  this._addClass(this.tooltip_min, 'hide');
689
664
  this._addClass(this.tooltip_max, 'hide');
690
- }
691
- else if(this.options.tooltip === 'always') {
665
+ } else if (this.options.tooltip === 'always') {
692
666
  this._showTooltip();
693
667
  this._alwaysShowTooltip = true;
694
- }
695
- else {
668
+ } else {
696
669
  this.showTooltip = this._showTooltip.bind(this);
697
670
  this.hideTooltip = this._hideTooltip.bind(this);
698
671
 
@@ -706,32 +679,26 @@
706
679
  this.handle2.addEventListener("blur", this.hideTooltip, false);
707
680
  }
708
681
 
709
- if(this.options.enabled) {
682
+ if (this.options.enabled) {
710
683
  this.enable();
711
684
  } else {
712
685
  this.disable();
713
686
  }
714
-
715
687
  }
716
688
 
717
-
718
-
719
689
  /*************************************************
720
-
721
- INSTANCE PROPERTIES/METHODS
722
-
723
- - Any methods bound to the prototype are considered
724
- part of the plugin's `public` interface
725
-
726
- **************************************************/
690
+ INSTANCE PROPERTIES/METHODS
691
+ - Any methods bound to the prototype are considered
692
+ part of the plugin's `public` interface
693
+ **************************************************/
727
694
  Slider.prototype = {
728
- _init: function() {}, // NOTE: Must exist to support bridget
695
+ _init: function _init() {}, // NOTE: Must exist to support bridget
729
696
 
730
697
  constructor: Slider,
731
698
 
732
699
  defaultOptions: {
733
700
  id: "",
734
- min: 0,
701
+ min: 0,
735
702
  max: 10,
736
703
  step: 1,
737
704
  precision: 0,
@@ -744,7 +711,7 @@
744
711
  handle: 'round',
745
712
  reversed: false,
746
713
  enabled: true,
747
- formatter: function(val) {
714
+ formatter: function formatter(val) {
748
715
  if (Array.isArray(val)) {
749
716
  return val[0] + " : " + val[1];
750
717
  } else {
@@ -762,20 +729,19 @@
762
729
  labelledby: null
763
730
  },
764
731
 
765
- getElement: function() {
732
+ getElement: function getElement() {
766
733
  return this.sliderElem;
767
734
  },
768
735
 
769
- getValue: function() {
736
+ getValue: function getValue() {
770
737
  if (this.options.range) {
771
738
  return this._state.value;
772
- }
773
- else {
739
+ } else {
774
740
  return this._state.value[0];
775
741
  }
776
742
  },
777
743
 
778
- setValue: function(val, triggerSlideEvent, triggerChangeEvent) {
744
+ setValue: function setValue(val, triggerSlideEvent, triggerChangeEvent) {
779
745
  if (!val) {
780
746
  val = 0;
781
747
  }
@@ -789,10 +755,9 @@
789
755
 
790
756
  this._state.value[0] = Math.max(this.options.min, Math.min(this.options.max, this._state.value[0]));
791
757
  this._state.value[1] = Math.max(this.options.min, Math.min(this.options.max, this._state.value[1]));
792
- }
793
- else {
758
+ } else {
794
759
  this._state.value = applyPrecision(this._state.value);
795
- this._state.value = [ Math.max(this.options.min, Math.min(this.options.max, this._state.value))];
760
+ this._state.value = [Math.max(this.options.min, Math.min(this.options.max, this._state.value))];
796
761
  this._addClass(this.handle2, 'hide');
797
762
  if (this.options.selection === 'after') {
798
763
  this._state.value[1] = this.options.max;
@@ -802,11 +767,7 @@
802
767
  }
803
768
 
804
769
  if (this.options.max > this.options.min) {
805
- this._state.percentage = [
806
- this._toPercentage(this._state.value[0]),
807
- this._toPercentage(this._state.value[1]),
808
- this.options.step * 100 / (this.options.max - this.options.min)
809
- ];
770
+ this._state.percentage = [this._toPercentage(this._state.value[0]), this._toPercentage(this._state.value[1]), this.options.step * 100 / (this.options.max - this.options.min)];
810
771
  } else {
811
772
  this._state.percentage = [0, 0, 100];
812
773
  }
@@ -814,10 +775,10 @@
814
775
  this._layout();
815
776
  var newValue = this.options.range ? this._state.value : this._state.value[0];
816
777
 
817
- if(triggerSlideEvent === true) {
778
+ if (triggerSlideEvent === true) {
818
779
  this._trigger('slide', newValue);
819
780
  }
820
- if( (oldValue !== newValue) && (triggerChangeEvent === true) ) {
781
+ if (oldValue !== newValue && triggerChangeEvent === true) {
821
782
  this._trigger('change', {
822
783
  oldValue: oldValue,
823
784
  newValue: newValue
@@ -828,7 +789,7 @@
828
789
  return this;
829
790
  },
830
791
 
831
- destroy: function(){
792
+ destroy: function destroy() {
832
793
  // Remove event handlers on slider elements
833
794
  this._removeSliderEventHandlers();
834
795
 
@@ -844,13 +805,13 @@
844
805
  this.element.removeAttribute("data");
845
806
 
846
807
  // Remove JQuery handlers/data
847
- if($) {
808
+ if ($) {
848
809
  this._unbindJQueryEventHandlers();
849
810
  this.$element.removeData('slider');
850
811
  }
851
812
  },
852
813
 
853
- disable: function() {
814
+ disable: function disable() {
854
815
  this._state.enabled = false;
855
816
  this.handle1.removeAttribute("tabindex");
856
817
  this.handle2.removeAttribute("tabindex");
@@ -860,7 +821,7 @@
860
821
  return this;
861
822
  },
862
823
 
863
- enable: function() {
824
+ enable: function enable() {
864
825
  this._state.enabled = true;
865
826
  this.handle1.setAttribute("tabindex", 0);
866
827
  this.handle2.setAttribute("tabindex", 0);
@@ -870,8 +831,8 @@
870
831
  return this;
871
832
  },
872
833
 
873
- toggle: function() {
874
- if(this._state.enabled) {
834
+ toggle: function toggle() {
835
+ if (this._state.enabled) {
875
836
  this.disable();
876
837
  } else {
877
838
  this.enable();
@@ -879,63 +840,59 @@
879
840
  return this;
880
841
  },
881
842
 
882
- isEnabled: function() {
843
+ isEnabled: function isEnabled() {
883
844
  return this._state.enabled;
884
845
  },
885
846
 
886
- on: function(evt, callback) {
847
+ on: function on(evt, callback) {
887
848
  this._bindNonQueryEventHandler(evt, callback);
888
849
  return this;
889
850
  },
890
851
 
891
- off: function(evt, callback) {
892
- if($) {
893
- this.$element.off(evt, callback);
894
- this.$sliderElem.off(evt, callback);
895
- } else {
896
- this._unbindNonQueryEventHandler(evt, callback);
897
- }
898
- },
899
-
900
- getAttribute: function(attribute) {
901
- if(attribute) {
852
+ off: function off(evt, callback) {
853
+ if ($) {
854
+ this.$element.off(evt, callback);
855
+ this.$sliderElem.off(evt, callback);
856
+ } else {
857
+ this._unbindNonQueryEventHandler(evt, callback);
858
+ }
859
+ },
860
+
861
+ getAttribute: function getAttribute(attribute) {
862
+ if (attribute) {
902
863
  return this.options[attribute];
903
864
  } else {
904
865
  return this.options;
905
866
  }
906
867
  },
907
868
 
908
- setAttribute: function(attribute, value) {
869
+ setAttribute: function setAttribute(attribute, value) {
909
870
  this.options[attribute] = value;
910
871
  return this;
911
872
  },
912
873
 
913
- refresh: function() {
874
+ refresh: function refresh() {
914
875
  this._removeSliderEventHandlers();
915
876
  createNewSlider.call(this, this.element, this.options);
916
- if($) {
877
+ if ($) {
917
878
  // Bind new instance of slider to the element
918
879
  $.data(this.element, 'slider', this);
919
880
  }
920
881
  return this;
921
882
  },
922
883
 
923
- relayout: function() {
884
+ relayout: function relayout() {
924
885
  this._layout();
925
886
  return this;
926
887
  },
927
888
 
928
889
  /******************************+
929
-
930
- HELPERS
931
-
932
- - Any method that is not part of the public interface.
933
- - Place it underneath this comment block and write its signature like so:
934
-
935
- _fnName : function() {...}
936
-
937
- ********************************/
938
- _removeSliderEventHandlers: function() {
890
+ HELPERS
891
+ - Any method that is not part of the public interface.
892
+ - Place it underneath this comment block and write its signature like so:
893
+ _fnName : function() {...}
894
+ ********************************/
895
+ _removeSliderEventHandlers: function _removeSliderEventHandlers() {
939
896
  // Remove keydown event listeners
940
897
  this.handle1.removeEventListener("keydown", this.handle1Keydown, false);
941
898
  this.handle2.removeEventListener("keydown", this.handle2Keydown, false);
@@ -962,43 +919,43 @@
962
919
  // Remove window event listener
963
920
  window.removeEventListener("resize", this.resize, false);
964
921
  },
965
- _bindNonQueryEventHandler: function(evt, callback) {
966
- if(this.eventToCallbackMap[evt] === undefined) {
922
+ _bindNonQueryEventHandler: function _bindNonQueryEventHandler(evt, callback) {
923
+ if (this.eventToCallbackMap[evt] === undefined) {
967
924
  this.eventToCallbackMap[evt] = [];
968
925
  }
969
926
  this.eventToCallbackMap[evt].push(callback);
970
927
  },
971
- _unbindNonQueryEventHandler: function(evt, callback) {
972
- var callbacks = this.eventToCallbackMap[evt];
973
- if(callbacks !== undefined) {
974
- for (var i = 0; i < callbacks.length; i++) {
975
- if (callbacks[i] === callback) {
976
- callbacks.splice(i, 1);
977
- break;
978
- }
979
- }
980
- }
981
- },
982
- _cleanUpEventCallbacksMap: function() {
928
+ _unbindNonQueryEventHandler: function _unbindNonQueryEventHandler(evt, callback) {
929
+ var callbacks = this.eventToCallbackMap[evt];
930
+ if (callbacks !== undefined) {
931
+ for (var i = 0; i < callbacks.length; i++) {
932
+ if (callbacks[i] === callback) {
933
+ callbacks.splice(i, 1);
934
+ break;
935
+ }
936
+ }
937
+ }
938
+ },
939
+ _cleanUpEventCallbacksMap: function _cleanUpEventCallbacksMap() {
983
940
  var eventNames = Object.keys(this.eventToCallbackMap);
984
- for(var i = 0; i < eventNames.length; i++) {
941
+ for (var i = 0; i < eventNames.length; i++) {
985
942
  var eventName = eventNames[i];
986
943
  this.eventToCallbackMap[eventName] = null;
987
944
  }
988
945
  },
989
- _showTooltip: function() {
990
- if (this.options.tooltip_split === false ){
991
- this._addClass(this.tooltip, 'in');
992
- this.tooltip_min.style.display = 'none';
993
- this.tooltip_max.style.display = 'none';
994
- } else {
995
- this._addClass(this.tooltip_min, 'in');
996
- this._addClass(this.tooltip_max, 'in');
997
- this.tooltip.style.display = 'none';
998
- }
946
+ _showTooltip: function _showTooltip() {
947
+ if (this.options.tooltip_split === false) {
948
+ this._addClass(this.tooltip, 'in');
949
+ this.tooltip_min.style.display = 'none';
950
+ this.tooltip_max.style.display = 'none';
951
+ } else {
952
+ this._addClass(this.tooltip_min, 'in');
953
+ this._addClass(this.tooltip_max, 'in');
954
+ this.tooltip.style.display = 'none';
955
+ }
999
956
  this._state.over = true;
1000
957
  },
1001
- _hideTooltip: function() {
958
+ _hideTooltip: function _hideTooltip() {
1002
959
  if (this._state.inDrag === false && this.alwaysShowTooltip !== true) {
1003
960
  this._removeClass(this.tooltip, 'in');
1004
961
  this._removeClass(this.tooltip_min, 'in');
@@ -1006,20 +963,19 @@
1006
963
  }
1007
964
  this._state.over = false;
1008
965
  },
1009
- _layout: function() {
966
+ _layout: function _layout() {
1010
967
  var positionPercentages;
1011
968
 
1012
- if(this.options.reversed) {
1013
- positionPercentages = [ 100 - this._state.percentage[0], this.options.range ? 100 - this._state.percentage[1] : this._state.percentage[1]];
1014
- }
1015
- else {
1016
- positionPercentages = [ this._state.percentage[0], this._state.percentage[1] ];
969
+ if (this.options.reversed) {
970
+ positionPercentages = [100 - this._state.percentage[0], this.options.range ? 100 - this._state.percentage[1] : this._state.percentage[1]];
971
+ } else {
972
+ positionPercentages = [this._state.percentage[0], this._state.percentage[1]];
1017
973
  }
1018
974
 
1019
- this.handle1.style[this.stylePos] = positionPercentages[0]+'%';
975
+ this.handle1.style[this.stylePos] = positionPercentages[0] + '%';
1020
976
  this.handle1.setAttribute('aria-valuenow', this._state.value[0]);
1021
977
 
1022
- this.handle2.style[this.stylePos] = positionPercentages[1]+'%';
978
+ this.handle2.style[this.stylePos] = positionPercentages[1] + '%';
1023
979
  this.handle2.setAttribute('aria-valuenow', this._state.value[1]);
1024
980
 
1025
981
  /* Position ticks and labels */
@@ -1033,13 +989,13 @@
1033
989
  var extraMargin = 0;
1034
990
  if (this.options.ticks_positions.length === 0) {
1035
991
  if (this.options.orientation !== 'vertical') {
1036
- this.tickLabelContainer.style[styleMargin] = -labelSize/2 + 'px';
992
+ this.tickLabelContainer.style[styleMargin] = -labelSize / 2 + 'px';
1037
993
  }
1038
994
 
1039
995
  extraMargin = this.tickLabelContainer.offsetHeight;
1040
996
  } else {
1041
997
  /* Chidren are position absolute, calculate height by finding the max offsetHeight of a child */
1042
- for (i = 0 ; i < this.tickLabelContainer.childNodes.length; i++) {
998
+ for (i = 0; i < this.tickLabelContainer.childNodes.length; i++) {
1043
999
  if (this.tickLabelContainer.childNodes[i].offsetHeight > extraMargin) {
1044
1000
  extraMargin = this.tickLabelContainer.childNodes[i].offsetHeight;
1045
1001
  }
@@ -1062,7 +1018,7 @@
1062
1018
  /* Set class labels to denote whether ticks are in the selection */
1063
1019
  this._removeClass(this.ticks[i], 'in-selection');
1064
1020
  if (!this.options.range) {
1065
- if (this.options.selection === 'after' && percentage >= positionPercentages[0]){
1021
+ if (this.options.selection === 'after' && percentage >= positionPercentages[0]) {
1066
1022
  this._addClass(this.ticks[i], 'in-selection');
1067
1023
  } else if (this.options.selection === 'before' && percentage <= positionPercentages[0]) {
1068
1024
  this._addClass(this.ticks[i], 'in-selection');
@@ -1077,9 +1033,9 @@
1077
1033
  if (this.options.orientation !== 'vertical' && this.options.ticks_positions[i] !== undefined) {
1078
1034
  this.tickLabels[i].style.position = 'absolute';
1079
1035
  this.tickLabels[i].style[this.stylePos] = percentage + '%';
1080
- this.tickLabels[i].style[styleMargin] = -labelSize/2 + 'px';
1036
+ this.tickLabels[i].style[styleMargin] = -labelSize / 2 + 'px';
1081
1037
  } else if (this.options.orientation === 'vertical') {
1082
- this.tickLabels[i].style['marginLeft'] = this.sliderElem.offsetWidth + 'px';
1038
+ this.tickLabels[i].style['marginLeft'] = this.sliderElem.offsetWidth + 'px';
1083
1039
  this.tickLabelContainer.style['marginTop'] = this.sliderElem.offsetWidth / 2 * -1 + 'px';
1084
1040
  }
1085
1041
  }
@@ -1091,7 +1047,7 @@
1091
1047
  if (this.options.range) {
1092
1048
  formattedTooltipVal = this.options.formatter(this._state.value);
1093
1049
  this._setText(this.tooltipInner, formattedTooltipVal);
1094
- this.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0])/2 + '%';
1050
+ this.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0]) / 2 + '%';
1095
1051
 
1096
1052
  if (this.options.orientation === 'vertical') {
1097
1053
  this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
@@ -1140,53 +1096,52 @@
1140
1096
 
1141
1097
  if (this.options.orientation === 'vertical') {
1142
1098
  this.trackLow.style.top = '0';
1143
- this.trackLow.style.height = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
1099
+ this.trackLow.style.height = Math.min(positionPercentages[0], positionPercentages[1]) + '%';
1144
1100
 
1145
- this.trackSelection.style.top = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
1146
- this.trackSelection.style.height = Math.abs(positionPercentages[0] - positionPercentages[1]) +'%';
1101
+ this.trackSelection.style.top = Math.min(positionPercentages[0], positionPercentages[1]) + '%';
1102
+ this.trackSelection.style.height = Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';
1147
1103
 
1148
1104
  this.trackHigh.style.bottom = '0';
1149
- this.trackHigh.style.height = (100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1])) +'%';
1150
- }
1151
- else {
1105
+ this.trackHigh.style.height = 100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';
1106
+ } else {
1152
1107
  this.trackLow.style.left = '0';
1153
- this.trackLow.style.width = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
1108
+ this.trackLow.style.width = Math.min(positionPercentages[0], positionPercentages[1]) + '%';
1154
1109
 
1155
- this.trackSelection.style.left = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
1156
- this.trackSelection.style.width = Math.abs(positionPercentages[0] - positionPercentages[1]) +'%';
1110
+ this.trackSelection.style.left = Math.min(positionPercentages[0], positionPercentages[1]) + '%';
1111
+ this.trackSelection.style.width = Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';
1157
1112
 
1158
1113
  this.trackHigh.style.right = '0';
1159
- this.trackHigh.style.width = (100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1])) +'%';
1114
+ this.trackHigh.style.width = 100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';
1160
1115
 
1161
- var offset_min = this.tooltip_min.getBoundingClientRect();
1162
- var offset_max = this.tooltip_max.getBoundingClientRect();
1116
+ var offset_min = this.tooltip_min.getBoundingClientRect();
1117
+ var offset_max = this.tooltip_max.getBoundingClientRect();
1163
1118
 
1164
- if (offset_min.right > offset_max.left) {
1165
- this._removeClass(this.tooltip_max, 'top');
1166
- this._addClass(this.tooltip_max, 'bottom');
1167
- this.tooltip_max.style.top = 18 + 'px';
1168
- } else {
1169
- this._removeClass(this.tooltip_max, 'bottom');
1170
- this._addClass(this.tooltip_max, 'top');
1171
- this.tooltip_max.style.top = this.tooltip_min.style.top;
1172
- }
1119
+ if (offset_min.right > offset_max.left) {
1120
+ this._removeClass(this.tooltip_max, 'top');
1121
+ this._addClass(this.tooltip_max, 'bottom');
1122
+ this.tooltip_max.style.top = 18 + 'px';
1123
+ } else {
1124
+ this._removeClass(this.tooltip_max, 'bottom');
1125
+ this._addClass(this.tooltip_max, 'top');
1126
+ this.tooltip_max.style.top = this.tooltip_min.style.top;
1127
+ }
1173
1128
  }
1174
1129
  },
1175
- _resize: function (ev) {
1130
+ _resize: function _resize(ev) {
1176
1131
  /*jshint unused:false*/
1177
1132
  this._state.offset = this._offset(this.sliderElem);
1178
1133
  this._state.size = this.sliderElem[this.sizePos];
1179
1134
  this._layout();
1180
1135
  },
1181
- _removeProperty: function(element, prop) {
1136
+ _removeProperty: function _removeProperty(element, prop) {
1182
1137
  if (element.style.removeProperty) {
1183
- element.style.removeProperty(prop);
1138
+ element.style.removeProperty(prop);
1184
1139
  } else {
1185
- element.style.removeAttribute(prop);
1140
+ element.style.removeAttribute(prop);
1186
1141
  }
1187
1142
  },
1188
- _mousedown: function(ev) {
1189
- if(!this._state.enabled) {
1143
+ _mousedown: function _mousedown(ev) {
1144
+ if (!this._state.enabled) {
1190
1145
  return false;
1191
1146
  }
1192
1147
 
@@ -1198,7 +1153,7 @@
1198
1153
  if (this.options.range) {
1199
1154
  var diff1 = Math.abs(this._state.percentage[0] - percentage);
1200
1155
  var diff2 = Math.abs(this._state.percentage[1] - percentage);
1201
- this._state.dragged = (diff1 < diff2) ? 0 : 1;
1156
+ this._state.dragged = diff1 < diff2 ? 0 : 1;
1202
1157
  } else {
1203
1158
  this._state.dragged = 0;
1204
1159
  }
@@ -1211,10 +1166,10 @@
1211
1166
  document.removeEventListener("touchend", this.mouseup, false);
1212
1167
  }
1213
1168
 
1214
- if(this.mousemove){
1169
+ if (this.mousemove) {
1215
1170
  document.removeEventListener("mousemove", this.mousemove, false);
1216
1171
  }
1217
- if(this.mouseup){
1172
+ if (this.mouseup) {
1218
1173
  document.removeEventListener("mouseup", this.mouseup, false);
1219
1174
  }
1220
1175
 
@@ -1246,27 +1201,29 @@
1246
1201
 
1247
1202
  return true;
1248
1203
  },
1249
- _triggerFocusOnHandle: function(handleIdx) {
1250
- if(handleIdx === 0) {
1204
+ _triggerFocusOnHandle: function _triggerFocusOnHandle(handleIdx) {
1205
+ if (handleIdx === 0) {
1251
1206
  this.handle1.focus();
1252
1207
  }
1253
- if(handleIdx === 1) {
1208
+ if (handleIdx === 1) {
1254
1209
  this.handle2.focus();
1255
1210
  }
1256
1211
  },
1257
- _keydown: function(handleIdx, ev) {
1258
- if(!this._state.enabled) {
1212
+ _keydown: function _keydown(handleIdx, ev) {
1213
+ if (!this._state.enabled) {
1259
1214
  return false;
1260
1215
  }
1261
1216
 
1262
1217
  var dir;
1263
1218
  switch (ev.keyCode) {
1264
1219
  case 37: // left
1265
- case 40: // down
1220
+ case 40:
1221
+ // down
1266
1222
  dir = -1;
1267
1223
  break;
1268
1224
  case 39: // right
1269
- case 38: // up
1225
+ case 38:
1226
+ // up
1270
1227
  dir = 1;
1271
1228
  break;
1272
1229
  }
@@ -1276,8 +1233,8 @@
1276
1233
 
1277
1234
  // use natural arrow keys instead of from min to max
1278
1235
  if (this.options.natural_arrow_keys) {
1279
- var ifVerticalAndNotReversed = (this.options.orientation === 'vertical' && !this.options.reversed);
1280
- var ifHorizontalAndReversed = (this.options.orientation === 'horizontal' && this.options.reversed);
1236
+ var ifVerticalAndNotReversed = this.options.orientation === 'vertical' && !this.options.reversed;
1237
+ var ifHorizontalAndReversed = this.options.orientation === 'horizontal' && this.options.reversed;
1281
1238
 
1282
1239
  if (ifVerticalAndNotReversed || ifHorizontalAndReversed) {
1283
1240
  dir = -dir;
@@ -1286,8 +1243,7 @@
1286
1243
 
1287
1244
  var val = this._state.value[handleIdx] + dir * this.options.step;
1288
1245
  if (this.options.range) {
1289
- val = [ (!handleIdx) ? val : this._state.value[0],
1290
- ( handleIdx) ? val : this._state.value[1]];
1246
+ val = [!handleIdx ? val : this._state.value[0], handleIdx ? val : this._state.value[1]];
1291
1247
  }
1292
1248
 
1293
1249
  this._trigger('slideStart', val);
@@ -1302,18 +1258,18 @@
1302
1258
 
1303
1259
  return false;
1304
1260
  },
1305
- _pauseEvent: function(ev) {
1306
- if(ev.stopPropagation) {
1261
+ _pauseEvent: function _pauseEvent(ev) {
1262
+ if (ev.stopPropagation) {
1307
1263
  ev.stopPropagation();
1308
1264
  }
1309
- if(ev.preventDefault) {
1310
- ev.preventDefault();
1311
- }
1312
- ev.cancelBubble=true;
1313
- ev.returnValue=false;
1265
+ if (ev.preventDefault) {
1266
+ ev.preventDefault();
1267
+ }
1268
+ ev.cancelBubble = true;
1269
+ ev.returnValue = false;
1314
1270
  },
1315
- _mousemove: function(ev) {
1316
- if(!this._state.enabled) {
1271
+ _mousemove: function _mousemove(ev) {
1272
+ if (!this._state.enabled) {
1317
1273
  return false;
1318
1274
  }
1319
1275
 
@@ -1327,7 +1283,7 @@
1327
1283
 
1328
1284
  return false;
1329
1285
  },
1330
- _adjustPercentageForRangeSliders: function(percentage) {
1286
+ _adjustPercentageForRangeSliders: function _adjustPercentageForRangeSliders(percentage) {
1331
1287
  if (this.options.range) {
1332
1288
  var precision = this._getNumDigitsAfterDecimalPlace(percentage);
1333
1289
  precision = precision ? precision - 1 : 0;
@@ -1341,8 +1297,8 @@
1341
1297
  }
1342
1298
  }
1343
1299
  },
1344
- _mouseup: function() {
1345
- if(!this._state.enabled) {
1300
+ _mouseup: function _mouseup() {
1301
+ if (!this._state.enabled) {
1346
1302
  return false;
1347
1303
  }
1348
1304
  if (this.touchCapable) {
@@ -1350,9 +1306,9 @@
1350
1306
  document.removeEventListener("touchmove", this.mousemove, false);
1351
1307
  document.removeEventListener("touchend", this.mouseup, false);
1352
1308
  }
1353
- // Unbind mouse event handlers:
1354
- document.removeEventListener("mousemove", this.mousemove, false);
1355
- document.removeEventListener("mouseup", this.mouseup, false);
1309
+ // Unbind mouse event handlers:
1310
+ document.removeEventListener("mousemove", this.mousemove, false);
1311
+ document.removeEventListener("mouseup", this.mouseup, false);
1356
1312
 
1357
1313
  this._state.inDrag = false;
1358
1314
  if (this._state.over === false) {
@@ -1366,20 +1322,20 @@
1366
1322
 
1367
1323
  return false;
1368
1324
  },
1369
- _calculateValue: function(snapToClosestTick) {
1325
+ _calculateValue: function _calculateValue(snapToClosestTick) {
1370
1326
  var val;
1371
1327
  if (this.options.range) {
1372
- val = [this.options.min,this.options.max];
1373
- if (this._state.percentage[0] !== 0){
1374
- val[0] = this._toValue(this._state.percentage[0]);
1375
- val[0] = this._applyPrecision(val[0]);
1376
- }
1377
- if (this._state.percentage[1] !== 100){
1378
- val[1] = this._toValue(this._state.percentage[1]);
1379
- val[1] = this._applyPrecision(val[1]);
1380
- }
1328
+ val = [this.options.min, this.options.max];
1329
+ if (this._state.percentage[0] !== 0) {
1330
+ val[0] = this._toValue(this._state.percentage[0]);
1331
+ val[0] = this._applyPrecision(val[0]);
1332
+ }
1333
+ if (this._state.percentage[1] !== 100) {
1334
+ val[1] = this._toValue(this._state.percentage[1]);
1335
+ val[1] = this._applyPrecision(val[1]);
1336
+ }
1381
1337
  } else {
1382
- val = this._toValue(this._state.percentage[0]);
1338
+ val = this._toValue(this._state.percentage[0]);
1383
1339
  val = parseFloat(val);
1384
1340
  val = this._applyPrecision(val);
1385
1341
  }
@@ -1399,24 +1355,26 @@
1399
1355
 
1400
1356
  return val;
1401
1357
  },
1402
- _applyPrecision: function(val) {
1358
+ _applyPrecision: function _applyPrecision(val) {
1403
1359
  var precision = this.options.precision || this._getNumDigitsAfterDecimalPlace(this.options.step);
1404
1360
  return this._applyToFixedAndParseFloat(val, precision);
1405
1361
  },
1406
- _getNumDigitsAfterDecimalPlace: function(num) {
1407
- var match = (''+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
1408
- if (!match) { return 0; }
1362
+ _getNumDigitsAfterDecimalPlace: function _getNumDigitsAfterDecimalPlace(num) {
1363
+ var match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
1364
+ if (!match) {
1365
+ return 0;
1366
+ }
1409
1367
  return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));
1410
1368
  },
1411
- _applyToFixedAndParseFloat: function(num, toFixedInput) {
1369
+ _applyToFixedAndParseFloat: function _applyToFixedAndParseFloat(num, toFixedInput) {
1412
1370
  var truncatedNum = num.toFixed(toFixedInput);
1413
1371
  return parseFloat(truncatedNum);
1414
1372
  },
1415
1373
  /*
1416
- Credits to Mike Samuel for the following method!
1417
- Source: http://stackoverflow.com/questions/10454518/javascript-how-to-retrieve-the-number-of-decimals-of-a-string-number
1418
- */
1419
- _getPercentage: function(ev) {
1374
+ Credits to Mike Samuel for the following method!
1375
+ Source: http://stackoverflow.com/questions/10454518/javascript-how-to-retrieve-the-number-of-decimals-of-a-string-number
1376
+ */
1377
+ _getPercentage: function _getPercentage(ev) {
1420
1378
  if (this.touchCapable && (ev.type === 'touchstart' || ev.type === 'touchmove')) {
1421
1379
  ev = ev.touches[0];
1422
1380
  }
@@ -1425,7 +1383,7 @@
1425
1383
  var sliderOffset = this._state.offset[this.stylePos];
1426
1384
  var distanceToSlide = eventPosition - sliderOffset;
1427
1385
  // Calculate what percent of the length the slider handle has slid
1428
- var percentage = (distanceToSlide / this._state.size) * 100;
1386
+ var percentage = distanceToSlide / this._state.size * 100;
1429
1387
  percentage = Math.round(percentage / this._state.percentage[2]) * this._state.percentage[2];
1430
1388
  if (this.options.reversed) {
1431
1389
  percentage = 100 - percentage;
@@ -1436,44 +1394,46 @@
1436
1394
  // 100% corresponds to the 'max' value of the slide
1437
1395
  return Math.max(0, Math.min(100, percentage));
1438
1396
  },
1439
- _validateInputValue: function(val) {
1397
+ _validateInputValue: function _validateInputValue(val) {
1440
1398
  if (typeof val === 'number') {
1441
1399
  return val;
1442
1400
  } else if (Array.isArray(val)) {
1443
1401
  this._validateArray(val);
1444
1402
  return val;
1445
1403
  } else {
1446
- throw new Error( ErrorMsgs.formatInvalidInputErrorMsg(val) );
1404
+ throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(val));
1447
1405
  }
1448
1406
  },
1449
- _validateArray: function(val) {
1450
- for(var i = 0; i < val.length; i++) {
1451
- var input = val[i];
1452
- if (typeof input !== 'number') { throw new Error( ErrorMsgs.formatInvalidInputErrorMsg(input) ); }
1407
+ _validateArray: function _validateArray(val) {
1408
+ for (var i = 0; i < val.length; i++) {
1409
+ var input = val[i];
1410
+ if (typeof input !== 'number') {
1411
+ throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(input));
1412
+ }
1453
1413
  }
1454
1414
  },
1455
- _setDataVal: function(val) {
1415
+ _setDataVal: function _setDataVal(val) {
1456
1416
  this.element.setAttribute('data-value', val);
1457
1417
  this.element.setAttribute('value', val);
1458
- this.element.value = val;
1418
+ this.element.value = val;
1459
1419
  },
1460
- _trigger: function(evt, val) {
1461
- val = (val || val === 0) ? val : undefined;
1420
+ _trigger: function _trigger(evt, val) {
1421
+ val = val || val === 0 ? val : undefined;
1462
1422
 
1463
1423
  var callbackFnArray = this.eventToCallbackMap[evt];
1464
- if(callbackFnArray && callbackFnArray.length) {
1465
- for(var i = 0; i < callbackFnArray.length; i++) {
1424
+ if (callbackFnArray && callbackFnArray.length) {
1425
+ for (var i = 0; i < callbackFnArray.length; i++) {
1466
1426
  var callbackFn = callbackFnArray[i];
1467
1427
  callbackFn(val);
1468
1428
  }
1469
1429
  }
1470
1430
 
1471
1431
  /* If JQuery exists, trigger JQuery events */
1472
- if($) {
1432
+ if ($) {
1473
1433
  this._triggerJQueryEvent(evt, val);
1474
1434
  }
1475
1435
  },
1476
- _triggerJQueryEvent: function(evt, val) {
1436
+ _triggerJQueryEvent: function _triggerJQueryEvent(evt, val) {
1477
1437
  var eventData = {
1478
1438
  type: evt,
1479
1439
  value: val
@@ -1481,22 +1441,22 @@
1481
1441
  this.$element.trigger(eventData);
1482
1442
  this.$sliderElem.trigger(eventData);
1483
1443
  },
1484
- _unbindJQueryEventHandlers: function() {
1444
+ _unbindJQueryEventHandlers: function _unbindJQueryEventHandlers() {
1485
1445
  this.$element.off();
1486
1446
  this.$sliderElem.off();
1487
1447
  },
1488
- _setText: function(element, text) {
1489
- if(typeof element.innerText !== "undefined") {
1490
- element.innerText = text;
1491
- } else if(typeof element.textContent !== "undefined") {
1492
- element.textContent = text;
1493
- }
1448
+ _setText: function _setText(element, text) {
1449
+ if (typeof element.innerText !== "undefined") {
1450
+ element.innerText = text;
1451
+ } else if (typeof element.textContent !== "undefined") {
1452
+ element.textContent = text;
1453
+ }
1494
1454
  },
1495
- _removeClass: function(element, classString) {
1455
+ _removeClass: function _removeClass(element, classString) {
1496
1456
  var classes = classString.split(" ");
1497
1457
  var newClasses = element.className;
1498
1458
 
1499
- for(var i = 0; i < classes.length; i++) {
1459
+ for (var i = 0; i < classes.length; i++) {
1500
1460
  var classTag = classes[i];
1501
1461
  var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
1502
1462
  newClasses = newClasses.replace(regex, " ");
@@ -1504,88 +1464,85 @@
1504
1464
 
1505
1465
  element.className = newClasses.trim();
1506
1466
  },
1507
- _addClass: function(element, classString) {
1467
+ _addClass: function _addClass(element, classString) {
1508
1468
  var classes = classString.split(" ");
1509
1469
  var newClasses = element.className;
1510
1470
 
1511
- for(var i = 0; i < classes.length; i++) {
1471
+ for (var i = 0; i < classes.length; i++) {
1512
1472
  var classTag = classes[i];
1513
1473
  var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
1514
1474
  var ifClassExists = regex.test(newClasses);
1515
1475
 
1516
- if(!ifClassExists) {
1476
+ if (!ifClassExists) {
1517
1477
  newClasses += " " + classTag;
1518
1478
  }
1519
1479
  }
1520
1480
 
1521
1481
  element.className = newClasses.trim();
1522
1482
  },
1523
- _offsetLeft: function(obj){
1483
+ _offsetLeft: function _offsetLeft(obj) {
1524
1484
  return obj.getBoundingClientRect().left;
1525
1485
  },
1526
- _offsetTop: function(obj){
1486
+ _offsetTop: function _offsetTop(obj) {
1527
1487
  var offsetTop = obj.offsetTop;
1528
- while((obj = obj.offsetParent) && !isNaN(obj.offsetTop)){
1488
+ while ((obj = obj.offsetParent) && !isNaN(obj.offsetTop)) {
1529
1489
  offsetTop += obj.offsetTop;
1530
1490
  }
1531
1491
  return offsetTop;
1532
1492
  },
1533
- _offset: function (obj) {
1493
+ _offset: function _offset(obj) {
1534
1494
  return {
1535
1495
  left: this._offsetLeft(obj),
1536
1496
  top: this._offsetTop(obj)
1537
1497
  };
1538
- },
1539
- _css: function(elementRef, styleName, value) {
1540
- if ($) {
1541
- $.style(elementRef, styleName, value);
1542
- } else {
1543
- var style = styleName.replace(/^-ms-/, "ms-").replace(/-([\da-z])/gi, function (all, letter) {
1544
- return letter.toUpperCase();
1545
- });
1546
- elementRef.style[style] = value;
1547
- }
1548
1498
  },
1549
- _toValue: function(percentage) {
1499
+ _css: function _css(elementRef, styleName, value) {
1500
+ if ($) {
1501
+ $.style(elementRef, styleName, value);
1502
+ } else {
1503
+ var style = styleName.replace(/^-ms-/, "ms-").replace(/-([\da-z])/gi, function (all, letter) {
1504
+ return letter.toUpperCase();
1505
+ });
1506
+ elementRef.style[style] = value;
1507
+ }
1508
+ },
1509
+ _toValue: function _toValue(percentage) {
1550
1510
  return this.options.scale.toValue.apply(this, [percentage]);
1551
1511
  },
1552
- _toPercentage: function(value) {
1512
+ _toPercentage: function _toPercentage(value) {
1553
1513
  return this.options.scale.toPercentage.apply(this, [value]);
1554
1514
  },
1555
- _setTooltipPosition: function(){
1515
+ _setTooltipPosition: function _setTooltipPosition() {
1556
1516
  var tooltips = [this.tooltip, this.tooltip_min, this.tooltip_max];
1557
- if (this.options.orientation === 'vertical'){
1517
+ if (this.options.orientation === 'vertical') {
1558
1518
  var tooltipPos = this.options.tooltip_position || 'right';
1559
- var oppositeSide = (tooltipPos === 'left') ? 'right' : 'left';
1560
- tooltips.forEach(function(tooltip){
1519
+ var oppositeSide = tooltipPos === 'left' ? 'right' : 'left';
1520
+ tooltips.forEach((function (tooltip) {
1561
1521
  this._addClass(tooltip, tooltipPos);
1562
1522
  tooltip.style[oppositeSide] = '100%';
1563
- }.bind(this));
1564
- } else if(this.options.tooltip_position === 'bottom') {
1565
- tooltips.forEach(function(tooltip){
1523
+ }).bind(this));
1524
+ } else if (this.options.tooltip_position === 'bottom') {
1525
+ tooltips.forEach((function (tooltip) {
1566
1526
  this._addClass(tooltip, 'bottom');
1567
1527
  tooltip.style.top = 22 + 'px';
1568
- }.bind(this));
1528
+ }).bind(this));
1569
1529
  } else {
1570
- tooltips.forEach(function(tooltip){
1530
+ tooltips.forEach((function (tooltip) {
1571
1531
  this._addClass(tooltip, 'top');
1572
1532
  tooltip.style.top = -this.tooltip.outerHeight - 14 + 'px';
1573
- }.bind(this));
1533
+ }).bind(this));
1574
1534
  }
1575
1535
  }
1576
1536
  };
1577
1537
 
1578
1538
  /*********************************
1579
-
1580
- Attach to global namespace
1581
-
1582
- *********************************/
1583
- if($) {
1539
+ Attach to global namespace
1540
+ *********************************/
1541
+ if ($) {
1584
1542
  var namespace = $.fn.slider ? 'bootstrapSlider' : 'slider';
1585
1543
  $.bridget(namespace, Slider);
1586
1544
  }
1587
-
1588
- })( $ );
1545
+ })($);
1589
1546
 
1590
1547
  return Slider;
1591
- }));
1548
+ });