adminlte2-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/README.md +19 -0
  4. data/lib/adminlte2/rails/version.rb +1 -1
  5. data/lib/generators/admin_lte_plugins/USAGE +28 -0
  6. data/lib/generators/admin_lte_plugins/admin_lte_plugins_generator.rb +100 -0
  7. data/lib/generators/admin_lte_plugins/templates/ChartJS/Chart.js +3457 -0
  8. data/lib/generators/admin_lte_plugins/templates/Sparkline/jquery.sparkline.js +3054 -0
  9. data/lib/generators/admin_lte_plugins/templates/bootstrap-slider/bootstrap-slider.js +1167 -0
  10. data/lib/generators/admin_lte_plugins/templates/bootstrap-slider/slider.css +169 -0
  11. data/lib/generators/admin_lte_plugins/templates/bootstrap-wysihtml5/bootstrap3-wysihtml5.css +102 -0
  12. data/lib/generators/admin_lte_plugins/templates/bootstrap-wysihtml5/bootstrap3-wysihtml5.js +350 -0
  13. data/lib/generators/admin_lte_plugins/templates/colorpicker/bootstrap-colorpicker.css +214 -0
  14. data/lib/generators/admin_lte_plugins/templates/colorpicker/bootstrap-colorpicker.js +949 -0
  15. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/alpha-horizontal.png +0 -0
  16. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/alpha.png +0 -0
  17. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/hue-horizontal.png +0 -0
  18. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/hue.png +0 -0
  19. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/saturation.png +0 -0
  20. data/lib/generators/admin_lte_plugins/templates/datepicker/bootstrap-datepicker.js +1671 -0
  21. data/lib/generators/admin_lte_plugins/templates/datepicker/datepicker3.css +790 -0
  22. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ar.js +15 -0
  23. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.az.js +12 -0
  24. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.bg.js +14 -0
  25. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ca.js +14 -0
  26. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.cs.js +15 -0
  27. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.cy.js +14 -0
  28. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.da.js +15 -0
  29. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.de.js +17 -0
  30. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.el.js +13 -0
  31. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.es.js +14 -0
  32. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.et.js +18 -0
  33. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.fa.js +17 -0
  34. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.fi.js +16 -0
  35. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.fr.js +17 -0
  36. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.gl.js +11 -0
  37. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.he.js +15 -0
  38. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.hr.js +13 -0
  39. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.hu.js +16 -0
  40. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.id.js +15 -0
  41. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.is.js +14 -0
  42. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.it.js +17 -0
  43. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ja.js +15 -0
  44. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ka.js +17 -0
  45. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.kk.js +15 -0
  46. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.kr.js +13 -0
  47. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.lt.js +16 -0
  48. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.lv.js +16 -0
  49. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.mk.js +15 -0
  50. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ms.js +14 -0
  51. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.nb.js +14 -0
  52. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.nl-BE.js +17 -0
  53. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.nl.js +14 -0
  54. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.no.js +16 -0
  55. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.pl.js +15 -0
  56. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.pt-BR.js +15 -0
  57. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.pt.js +16 -0
  58. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ro.js +16 -0
  59. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.rs-latin.js +14 -0
  60. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.rs.js +14 -0
  61. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ru.js +15 -0
  62. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sk.js +15 -0
  63. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sl.js +14 -0
  64. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sq.js +15 -0
  65. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sv.js +16 -0
  66. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sw.js +15 -0
  67. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.th.js +14 -0
  68. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.tr.js +16 -0
  69. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ua.js +15 -0
  70. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.vi.js +16 -0
  71. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.zh-CN.js +16 -0
  72. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.zh-TW.js +17 -0
  73. data/lib/generators/admin_lte_plugins/templates/daterangepicker/daterangepicker-bs3.css +245 -0
  74. data/lib/generators/admin_lte_plugins/templates/daterangepicker/daterangepicker.js +883 -0
  75. data/lib/generators/admin_lte_plugins/templates/fullcalendar/fullcalendar.css +977 -0
  76. data/lib/generators/admin_lte_plugins/templates/fullcalendar/fullcalendar.js +9732 -0
  77. data/lib/generators/admin_lte_plugins/templates/fullcalendar/fullcalendar.print.css +202 -0
  78. data/lib/generators/admin_lte_plugins/templates/jVectorMap/jquery-jvectormap-1.2.2.css +40 -0
  79. data/lib/generators/admin_lte_plugins/templates/jVectorMap/jquery-jvectormap-1.2.2.min.js +8 -0
  80. data/lib/generators/admin_lte_plugins/templates/jVectorMap/jquery-jvectormap-world-mill-en.js +1 -0
  81. data/lib/generators/admin_lte_plugins/templates/knob/jquery.knob.js +805 -0
  82. data/lib/generators/admin_lte_plugins/templates/morris/morris.css +2 -0
  83. data/lib/generators/admin_lte_plugins/templates/morris/morris.js +1892 -0
  84. data/lib/generators/admin_lte_plugins/templates/pace/pace.js +2 -0
  85. data/lib/generators/admin_lte_plugins/templates/timepicker/bootstrap-timepicker.css +121 -0
  86. data/lib/generators/admin_lte_plugins/templates/timepicker/bootstrap-timepicker.js +903 -0
  87. metadata +83 -1
@@ -0,0 +1,1167 @@
1
+ /*! =========================================================
2
+ * bootstrap-slider.js
3
+ *
4
+ * Maintainers:
5
+ * Kyle Kemp
6
+ * - Twitter: @seiyria
7
+ * - Github: seiyria
8
+ * Rohit Kalkur
9
+ * - Twitter: @Rovolutionary
10
+ * - Github: rovolution
11
+ *
12
+ * =========================================================
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ * ========================================================= */
26
+
27
+
28
+ /**
29
+ * Bridget makes jQuery widgets
30
+ * v1.0.1
31
+ * MIT license
32
+ */
33
+ ( function( $ ) {
34
+
35
+ ( function( $ ) {
36
+
37
+ 'use strict';
38
+
39
+ // -------------------------- utils -------------------------- //
40
+
41
+ var slice = Array.prototype.slice;
42
+
43
+ function noop() {}
44
+
45
+ // -------------------------- definition -------------------------- //
46
+
47
+ function defineBridget( $ ) {
48
+
49
+ // bail if no jQuery
50
+ if ( !$ ) {
51
+ return;
52
+ }
53
+
54
+ // -------------------------- addOptionMethod -------------------------- //
55
+
56
+ /**
57
+ * adds option method -> $().plugin('option', {...})
58
+ * @param {Function} PluginClass - constructor class
59
+ */
60
+ function addOptionMethod( PluginClass ) {
61
+ // don't overwrite original option method
62
+ if ( PluginClass.prototype.option ) {
63
+ return;
64
+ }
65
+
66
+ // option setter
67
+ PluginClass.prototype.option = function( opts ) {
68
+ // bail out if not an object
69
+ if ( !$.isPlainObject( opts ) ){
70
+ return;
71
+ }
72
+ this.options = $.extend( true, this.options, opts );
73
+ };
74
+ }
75
+
76
+
77
+ // -------------------------- plugin bridge -------------------------- //
78
+
79
+ // helper function for logging errors
80
+ // $.error breaks jQuery chaining
81
+ var logError = typeof console === 'undefined' ? noop :
82
+ function( message ) {
83
+ console.error( message );
84
+ };
85
+
86
+ /**
87
+ * jQuery plugin bridge, access methods like $elem.plugin('method')
88
+ * @param {String} namespace - plugin name
89
+ * @param {Function} PluginClass - constructor class
90
+ */
91
+ function bridge( namespace, PluginClass ) {
92
+ // add to jQuery fn namespace
93
+ $.fn[ namespace ] = function( options ) {
94
+ if ( typeof options === 'string' ) {
95
+ // call plugin method when first argument is a string
96
+ // get arguments for method
97
+ var args = slice.call( arguments, 1 );
98
+
99
+ for ( var i=0, len = this.length; i < len; i++ ) {
100
+ var elem = this[i];
101
+ var instance = $.data( elem, namespace );
102
+ if ( !instance ) {
103
+ logError( "cannot call methods on " + namespace + " prior to initialization; " +
104
+ "attempted to call '" + options + "'" );
105
+ continue;
106
+ }
107
+ if ( !$.isFunction( instance[options] ) || options.charAt(0) === '_' ) {
108
+ logError( "no such method '" + options + "' for " + namespace + " instance" );
109
+ continue;
110
+ }
111
+
112
+ // trigger method with arguments
113
+ var returnValue = instance[ options ].apply( instance, args);
114
+
115
+ // break look and return first value if provided
116
+ if ( returnValue !== undefined && returnValue !== instance) {
117
+ return returnValue;
118
+ }
119
+ }
120
+ // return this if no return value
121
+ return this;
122
+ } else {
123
+ var objects = this.map( function() {
124
+ var instance = $.data( this, namespace );
125
+ if ( instance ) {
126
+ // apply options & init
127
+ instance.option( options );
128
+ instance._init();
129
+ } else {
130
+ // initialize new instance
131
+ instance = new PluginClass( this, options );
132
+ $.data( this, namespace, instance );
133
+ }
134
+ return $(this);
135
+ });
136
+
137
+ if(!objects || objects.length > 1) {
138
+ return objects;
139
+ } else {
140
+ return objects[0];
141
+ }
142
+ }
143
+ };
144
+
145
+ }
146
+
147
+ // -------------------------- bridget -------------------------- //
148
+
149
+ /**
150
+ * converts a Prototypical class into a proper jQuery plugin
151
+ * the class must have a ._init method
152
+ * @param {String} namespace - plugin name, used in $().pluginName
153
+ * @param {Function} PluginClass - constructor class
154
+ */
155
+ $.bridget = function( namespace, PluginClass ) {
156
+ addOptionMethod( PluginClass );
157
+ bridge( namespace, PluginClass );
158
+ };
159
+
160
+ return $.bridget;
161
+
162
+ }
163
+
164
+ // get jquery from browser global
165
+ defineBridget( $ );
166
+
167
+ })( $ );
168
+
169
+
170
+ /*************************************************
171
+
172
+ BOOTSTRAP-SLIDER SOURCE CODE
173
+
174
+ **************************************************/
175
+
176
+ (function( $ ) {
177
+
178
+ var ErrorMsgs = {
179
+ formatInvalidInputErrorMsg : function(input) {
180
+ return "Invalid input value '" + input + "' passed in";
181
+ },
182
+ 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"
183
+ };
184
+
185
+
186
+
187
+ /*************************************************
188
+
189
+ CONSTRUCTOR
190
+
191
+ **************************************************/
192
+ var Slider = function(element, options) {
193
+ createNewSlider.call(this, element, options);
194
+ return this;
195
+ };
196
+
197
+ function createNewSlider(element, options) {
198
+ /*************************************************
199
+
200
+ Create Markup
201
+
202
+ **************************************************/
203
+ if(typeof element === "string") {
204
+ this.element = document.querySelector(element);
205
+ } else if(element instanceof HTMLElement) {
206
+ this.element = element;
207
+ }
208
+
209
+ var origWidth = this.element.style.width;
210
+ var updateSlider = false;
211
+ var parent = this.element.parentNode;
212
+ var sliderTrackSelection;
213
+ var sliderMinHandle;
214
+ var sliderMaxHandle;
215
+
216
+ if (this.sliderElem) {
217
+ updateSlider = true;
218
+ } else {
219
+ /* Create elements needed for slider */
220
+ this.sliderElem = document.createElement("div");
221
+ this.sliderElem.className = "slider";
222
+
223
+ /* Create slider track elements */
224
+ var sliderTrack = document.createElement("div");
225
+ sliderTrack.className = "slider-track";
226
+
227
+ sliderTrackSelection = document.createElement("div");
228
+ sliderTrackSelection.className = "slider-selection";
229
+
230
+ sliderMinHandle = document.createElement("div");
231
+ sliderMinHandle.className = "slider-handle min-slider-handle";
232
+
233
+ sliderMaxHandle = document.createElement("div");
234
+ sliderMaxHandle.className = "slider-handle max-slider-handle";
235
+
236
+ sliderTrack.appendChild(sliderTrackSelection);
237
+ sliderTrack.appendChild(sliderMinHandle);
238
+ sliderTrack.appendChild(sliderMaxHandle);
239
+
240
+ var createAndAppendTooltipSubElements = function(tooltipElem) {
241
+ var arrow = document.createElement("div");
242
+ arrow.className = "tooltip-arrow";
243
+
244
+ var inner = document.createElement("div");
245
+ inner.className = "tooltip-inner";
246
+
247
+ tooltipElem.appendChild(arrow);
248
+ tooltipElem.appendChild(inner);
249
+ };
250
+
251
+ /* Create tooltip elements */
252
+ var sliderTooltip = document.createElement("div");
253
+ sliderTooltip.className = "tooltip tooltip-main";
254
+ createAndAppendTooltipSubElements(sliderTooltip);
255
+
256
+ var sliderTooltipMin = document.createElement("div");
257
+ sliderTooltipMin.className = "tooltip tooltip-min";
258
+ createAndAppendTooltipSubElements(sliderTooltipMin);
259
+
260
+ var sliderTooltipMax = document.createElement("div");
261
+ sliderTooltipMax.className = "tooltip tooltip-max";
262
+ createAndAppendTooltipSubElements(sliderTooltipMax);
263
+
264
+
265
+ /* Append components to sliderElem */
266
+ this.sliderElem.appendChild(sliderTrack);
267
+ this.sliderElem.appendChild(sliderTooltip);
268
+ this.sliderElem.appendChild(sliderTooltipMin);
269
+ this.sliderElem.appendChild(sliderTooltipMax);
270
+
271
+ /* Append slider element to parent container, right before the original <input> element */
272
+ parent.insertBefore(this.sliderElem, this.element);
273
+
274
+ /* Hide original <input> element */
275
+ this.element.style.display = "none";
276
+ }
277
+ /* If JQuery exists, cache JQ references */
278
+ if($) {
279
+ this.$element = $(this.element);
280
+ this.$sliderElem = $(this.sliderElem);
281
+ }
282
+
283
+ /*************************************************
284
+
285
+ Process Options
286
+
287
+ **************************************************/
288
+ options = options ? options : {};
289
+ var optionTypes = Object.keys(this.defaultOptions);
290
+
291
+ for(var i = 0; i < optionTypes.length; i++) {
292
+ var optName = optionTypes[i];
293
+
294
+ // First check if an option was passed in via the constructor
295
+ var val = options[optName];
296
+ // If no data attrib, then check data atrributes
297
+ val = (typeof val !== 'undefined') ? val : getDataAttrib(this.element, optName);
298
+ // Finally, if nothing was specified, use the defaults
299
+ val = (val !== null) ? val : this.defaultOptions[optName];
300
+
301
+ // Set all options on the instance of the Slider
302
+ if(!this.options) {
303
+ this.options = {};
304
+ }
305
+ this.options[optName] = val;
306
+ }
307
+
308
+ function getDataAttrib(element, optName) {
309
+ var dataName = "data-slider-" + optName;
310
+ var dataValString = element.getAttribute(dataName);
311
+
312
+ try {
313
+ return JSON.parse(dataValString);
314
+ }
315
+ catch(err) {
316
+ return dataValString;
317
+ }
318
+ }
319
+
320
+ /*************************************************
321
+
322
+ Setup
323
+
324
+ **************************************************/
325
+ this.eventToCallbackMap = {};
326
+ this.sliderElem.id = this.options.id;
327
+
328
+ this.touchCapable = 'ontouchstart' in window || (window.DocumentTouch && document instanceof window.DocumentTouch);
329
+
330
+ this.tooltip = this.sliderElem.querySelector('.tooltip-main');
331
+ this.tooltipInner = this.tooltip.querySelector('.tooltip-inner');
332
+
333
+ this.tooltip_min = this.sliderElem.querySelector('.tooltip-min');
334
+ this.tooltipInner_min = this.tooltip_min.querySelector('.tooltip-inner');
335
+
336
+ this.tooltip_max = this.sliderElem.querySelector('.tooltip-max');
337
+ this.tooltipInner_max= this.tooltip_max.querySelector('.tooltip-inner');
338
+
339
+ if (updateSlider === true) {
340
+ // Reset classes
341
+ this._removeClass(this.sliderElem, 'slider-horizontal');
342
+ this._removeClass(this.sliderElem, 'slider-vertical');
343
+ this._removeClass(this.tooltip, 'hide');
344
+ this._removeClass(this.tooltip_min, 'hide');
345
+ this._removeClass(this.tooltip_max, 'hide');
346
+
347
+ // Undo existing inline styles for track
348
+ ["left", "top", "width", "height"].forEach(function(prop) {
349
+ this._removeProperty(this.trackSelection, prop);
350
+ }, this);
351
+
352
+ // Undo inline styles on handles
353
+ [this.handle1, this.handle2].forEach(function(handle) {
354
+ this._removeProperty(handle, 'left');
355
+ this._removeProperty(handle, 'top');
356
+ }, this);
357
+
358
+ // Undo inline styles and classes on tooltips
359
+ [this.tooltip, this.tooltip_min, this.tooltip_max].forEach(function(tooltip) {
360
+ this._removeProperty(tooltip, 'left');
361
+ this._removeProperty(tooltip, 'top');
362
+ this._removeProperty(tooltip, 'margin-left');
363
+ this._removeProperty(tooltip, 'margin-top');
364
+
365
+ this._removeClass(tooltip, 'right');
366
+ this._removeClass(tooltip, 'top');
367
+ }, this);
368
+ }
369
+
370
+ if(this.options.orientation === 'vertical') {
371
+ this._addClass(this.sliderElem,'slider-vertical');
372
+
373
+ this.stylePos = 'top';
374
+ this.mousePos = 'pageY';
375
+ this.sizePos = 'offsetHeight';
376
+
377
+ this._addClass(this.tooltip, 'right');
378
+ this.tooltip.style.left = '100%';
379
+
380
+ this._addClass(this.tooltip_min, 'right');
381
+ this.tooltip_min.style.left = '100%';
382
+
383
+ this._addClass(this.tooltip_max, 'right');
384
+ this.tooltip_max.style.left = '100%';
385
+ } else {
386
+ this._addClass(this.sliderElem, 'slider-horizontal');
387
+ this.sliderElem.style.width = origWidth;
388
+
389
+ this.options.orientation = 'horizontal';
390
+ this.stylePos = 'left';
391
+ this.mousePos = 'pageX';
392
+ this.sizePos = 'offsetWidth';
393
+
394
+ this._addClass(this.tooltip, 'top');
395
+ this.tooltip.style.top = -this.tooltip.outerHeight - 14 + 'px';
396
+
397
+ this._addClass(this.tooltip_min, 'top');
398
+ this.tooltip_min.style.top = -this.tooltip_min.outerHeight - 14 + 'px';
399
+
400
+ this._addClass(this.tooltip_max, 'top');
401
+ this.tooltip_max.style.top = -this.tooltip_max.outerHeight - 14 + 'px';
402
+ }
403
+
404
+ if (this.options.value instanceof Array) {
405
+ this.options.range = true;
406
+ } else if (this.options.range) {
407
+ // User wants a range, but value is not an array
408
+ this.options.value = [this.options.value, this.options.max];
409
+ }
410
+
411
+ this.trackSelection = sliderTrackSelection || this.trackSelection;
412
+ if (this.options.selection === 'none') {
413
+ this._addClass(this.trackSelection, 'hide');
414
+ }
415
+
416
+ this.handle1 = sliderMinHandle || this.handle1;
417
+ this.handle2 = sliderMaxHandle || this.handle2;
418
+
419
+ if (updateSlider === true) {
420
+ // Reset classes
421
+ this._removeClass(this.handle1, 'round triangle');
422
+ this._removeClass(this.handle2, 'round triangle hide');
423
+ }
424
+
425
+ var availableHandleModifiers = ['round', 'triangle', 'custom'];
426
+ var isValidHandleType = availableHandleModifiers.indexOf(this.options.handle) !== -1;
427
+ if (isValidHandleType) {
428
+ this._addClass(this.handle1, this.options.handle);
429
+ this._addClass(this.handle2, this.options.handle);
430
+ }
431
+
432
+ this.offset = this._offset(this.sliderElem);
433
+ this.size = this.sliderElem[this.sizePos];
434
+ this.setValue(this.options.value);
435
+
436
+ /******************************************
437
+
438
+ Bind Event Listeners
439
+
440
+ ******************************************/
441
+
442
+ // Bind keyboard handlers
443
+ this.handle1Keydown = this._keydown.bind(this, 0);
444
+ this.handle1.addEventListener("keydown", this.handle1Keydown, false);
445
+
446
+ this.handle2Keydown = this._keydown.bind(this, 0);
447
+ this.handle2.addEventListener("keydown", this.handle2Keydown, false);
448
+
449
+ if (this.touchCapable) {
450
+ // Bind touch handlers
451
+ this.mousedown = this._mousedown.bind(this);
452
+ this.sliderElem.addEventListener("touchstart", this.mousedown, false);
453
+ } else {
454
+ // Bind mouse handlers
455
+ this.mousedown = this._mousedown.bind(this);
456
+ this.sliderElem.addEventListener("mousedown", this.mousedown, false);
457
+ }
458
+
459
+ // Bind tooltip-related handlers
460
+ if(this.options.tooltip === 'hide') {
461
+ this._addClass(this.tooltip, 'hide');
462
+ this._addClass(this.tooltip_min, 'hide');
463
+ this._addClass(this.tooltip_max, 'hide');
464
+ } else if(this.options.tooltip === 'always') {
465
+ this._showTooltip();
466
+ this._alwaysShowTooltip = true;
467
+ } else {
468
+ this.showTooltip = this._showTooltip.bind(this);
469
+ this.hideTooltip = this._hideTooltip.bind(this);
470
+
471
+ this.sliderElem.addEventListener("mouseenter", this.showTooltip, false);
472
+ this.sliderElem.addEventListener("mouseleave", this.hideTooltip, false);
473
+
474
+ this.handle1.addEventListener("focus", this.showTooltip, false);
475
+ this.handle1.addEventListener("blur", this.hideTooltip, false);
476
+
477
+ this.handle2.addEventListener("focus", this.showTooltip, false);
478
+ this.handle2.addEventListener("blur", this.hideTooltip, false);
479
+ }
480
+
481
+ if(this.options.enabled) {
482
+ this.enable();
483
+ } else {
484
+ this.disable();
485
+ }
486
+ }
487
+
488
+ /*************************************************
489
+
490
+ INSTANCE PROPERTIES/METHODS
491
+
492
+ - Any methods bound to the prototype are considered
493
+ part of the plugin's `public` interface
494
+
495
+ **************************************************/
496
+ Slider.prototype = {
497
+ _init: function() {}, // NOTE: Must exist to support bridget
498
+
499
+ constructor: Slider,
500
+
501
+ defaultOptions: {
502
+ id: "",
503
+ min: 0,
504
+ max: 10,
505
+ step: 1,
506
+ precision: 0,
507
+ orientation: 'horizontal',
508
+ value: 5,
509
+ range: false,
510
+ selection: 'before',
511
+ tooltip: 'show',
512
+ tooltip_split: false,
513
+ handle: 'round',
514
+ reversed: false,
515
+ enabled: true,
516
+ formatter: function(val) {
517
+ if(val instanceof Array) {
518
+ return val[0] + " : " + val[1];
519
+ } else {
520
+ return val;
521
+ }
522
+ },
523
+ natural_arrow_keys: false
524
+ },
525
+
526
+ over: false,
527
+
528
+ inDrag: false,
529
+
530
+ getValue: function() {
531
+ if (this.options.range) {
532
+ return this.options.value;
533
+ }
534
+ return this.options.value[0];
535
+ },
536
+
537
+ setValue: function(val, triggerSlideEvent) {
538
+ if (!val) {
539
+ val = 0;
540
+ }
541
+ this.options.value = this._validateInputValue(val);
542
+ var applyPrecision = this._applyPrecision.bind(this);
543
+
544
+ if (this.options.range) {
545
+ this.options.value[0] = applyPrecision(this.options.value[0]);
546
+ this.options.value[1] = applyPrecision(this.options.value[1]);
547
+
548
+ this.options.value[0] = Math.max(this.options.min, Math.min(this.options.max, this.options.value[0]));
549
+ this.options.value[1] = Math.max(this.options.min, Math.min(this.options.max, this.options.value[1]));
550
+ } else {
551
+ this.options.value = applyPrecision(this.options.value);
552
+ this.options.value = [ Math.max(this.options.min, Math.min(this.options.max, this.options.value))];
553
+ this._addClass(this.handle2, 'hide');
554
+ if (this.options.selection === 'after') {
555
+ this.options.value[1] = this.options.max;
556
+ } else {
557
+ this.options.value[1] = this.options.min;
558
+ }
559
+ }
560
+
561
+ this.diff = this.options.max - this.options.min;
562
+ if (this.diff > 0) {
563
+ this.percentage = [
564
+ (this.options.value[0] - this.options.min) * 100 / this.diff,
565
+ (this.options.value[1] - this.options.min) * 100 / this.diff,
566
+ this.options.step * 100 / this.diff
567
+ ];
568
+ } else {
569
+ this.percentage = [0, 0, 100];
570
+ }
571
+
572
+ this._layout();
573
+
574
+ var sliderValue = this.options.range ? this.options.value : this.options.value[0];
575
+ this._setDataVal(sliderValue);
576
+
577
+ if(triggerSlideEvent === true) {
578
+ this._trigger('slide', sliderValue);
579
+ }
580
+
581
+ return this;
582
+ },
583
+
584
+ destroy: function(){
585
+ // Remove event handlers on slider elements
586
+ this._removeSliderEventHandlers();
587
+
588
+ // Remove the slider from the DOM
589
+ this.sliderElem.parentNode.removeChild(this.sliderElem);
590
+ /* Show original <input> element */
591
+ this.element.style.display = "";
592
+
593
+ // Clear out custom event bindings
594
+ this._cleanUpEventCallbacksMap();
595
+
596
+ // Remove data values
597
+ this.element.removeAttribute("data");
598
+
599
+ // Remove JQuery handlers/data
600
+ if($) {
601
+ this._unbindJQueryEventHandlers();
602
+ this.$element.removeData('slider');
603
+ }
604
+ },
605
+
606
+ disable: function() {
607
+ this.options.enabled = false;
608
+ this.handle1.removeAttribute("tabindex");
609
+ this.handle2.removeAttribute("tabindex");
610
+ this._addClass(this.sliderElem, 'slider-disabled');
611
+ this._trigger('slideDisabled');
612
+
613
+ return this;
614
+ },
615
+
616
+ enable: function() {
617
+ this.options.enabled = true;
618
+ this.handle1.setAttribute("tabindex", 0);
619
+ this.handle2.setAttribute("tabindex", 0);
620
+ this._removeClass(this.sliderElem, 'slider-disabled');
621
+ this._trigger('slideEnabled');
622
+
623
+ return this;
624
+ },
625
+
626
+ toggle: function() {
627
+ if(this.options.enabled) {
628
+ this.disable();
629
+ } else {
630
+ this.enable();
631
+ }
632
+
633
+ return this;
634
+ },
635
+
636
+ isEnabled: function() {
637
+ return this.options.enabled;
638
+ },
639
+
640
+ on: function(evt, callback) {
641
+ if($) {
642
+ this.$element.on(evt, callback);
643
+ this.$sliderElem.on(evt, callback);
644
+ } else {
645
+ this._bindNonQueryEventHandler(evt, callback);
646
+ }
647
+ return this;
648
+ },
649
+
650
+ getAttribute: function(attribute) {
651
+ if(attribute) {
652
+ return this.options[attribute];
653
+ } else {
654
+ return this.options;
655
+ }
656
+ },
657
+
658
+ setAttribute: function(attribute, value) {
659
+ this.options[attribute] = value;
660
+ return this;
661
+ },
662
+
663
+ refresh: function() {
664
+ this._removeSliderEventHandlers();
665
+ createNewSlider.call(this, this.element, this.options);
666
+ if($) {
667
+ // Bind new instance of slider to the element
668
+ $.data(this.element, 'slider', this);
669
+ }
670
+ return this;
671
+ },
672
+
673
+ /******************************+
674
+
675
+ HELPERS
676
+
677
+ - Any method that is not part of the public interface.
678
+ - Place it underneath this comment block and write its signature like so:
679
+
680
+ _fnName : function() {...}
681
+
682
+ ********************************/
683
+ _removeSliderEventHandlers: function() {
684
+ // Remove event listeners from handle1
685
+ this.handle1.removeEventListener("keydown", this.handle1Keydown, false);
686
+ this.handle1.removeEventListener("focus", this.showTooltip, false);
687
+ this.handle1.removeEventListener("blur", this.hideTooltip, false);
688
+
689
+ // Remove event listeners from handle2
690
+ this.handle2.removeEventListener("keydown", this.handle2Keydown, false);
691
+ this.handle2.removeEventListener("focus", this.handle2Keydown, false);
692
+ this.handle2.removeEventListener("blur", this.handle2Keydown, false);
693
+
694
+ // Remove event listeners from sliderElem
695
+ this.sliderElem.removeEventListener("mouseenter", this.showTooltip, false);
696
+ this.sliderElem.removeEventListener("mouseleave", this.hideTooltip, false);
697
+ this.sliderElem.removeEventListener("touchstart", this.mousedown, false);
698
+ this.sliderElem.removeEventListener("mousedown", this.mousedown, false);
699
+ },
700
+ _bindNonQueryEventHandler: function(evt, callback) {
701
+ if(this.eventToCallbackMap[evt]===undefined) {
702
+ this.eventToCallbackMap[evt] = [];
703
+ }
704
+ this.eventToCallbackMap[evt].push(callback);
705
+ },
706
+ _cleanUpEventCallbacksMap: function() {
707
+ var eventNames = Object.keys(this.eventToCallbackMap);
708
+ for(var i = 0; i < eventNames.length; i++) {
709
+ var eventName = eventNames[i];
710
+ this.eventToCallbackMap[eventName] = null;
711
+ }
712
+ },
713
+ _showTooltip: function() {
714
+ if (this.options.tooltip_split === false ){
715
+ this._addClass(this.tooltip, 'in');
716
+ } else {
717
+ this._addClass(this.tooltip_min, 'in');
718
+ this._addClass(this.tooltip_max, 'in');
719
+ }
720
+ this.over = true;
721
+ },
722
+ _hideTooltip: function() {
723
+ if (this.inDrag === false && this.alwaysShowTooltip !== true) {
724
+ this._removeClass(this.tooltip, 'in');
725
+ this._removeClass(this.tooltip_min, 'in');
726
+ this._removeClass(this.tooltip_max, 'in');
727
+ }
728
+ this.over = false;
729
+ },
730
+ _layout: function() {
731
+ var positionPercentages;
732
+
733
+ if(this.options.reversed) {
734
+ positionPercentages = [ 100 - this.percentage[0], this.percentage[1] ];
735
+ } else {
736
+ positionPercentages = [ this.percentage[0], this.percentage[1] ];
737
+ }
738
+
739
+ this.handle1.style[this.stylePos] = positionPercentages[0]+'%';
740
+ this.handle2.style[this.stylePos] = positionPercentages[1]+'%';
741
+
742
+ if (this.options.orientation === 'vertical') {
743
+ this.trackSelection.style.top = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
744
+ this.trackSelection.style.height = Math.abs(positionPercentages[0] - positionPercentages[1]) +'%';
745
+ } else {
746
+ this.trackSelection.style.left = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
747
+ this.trackSelection.style.width = Math.abs(positionPercentages[0] - positionPercentages[1]) +'%';
748
+
749
+ var offset_min = this.tooltip_min.getBoundingClientRect();
750
+ var offset_max = this.tooltip_max.getBoundingClientRect();
751
+
752
+ if (offset_min.right > offset_max.left) {
753
+ this._removeClass(this.tooltip_max, 'top');
754
+ this._addClass(this.tooltip_max, 'bottom');
755
+ this.tooltip_max.style.top = 18 + 'px';
756
+ } else {
757
+ this._removeClass(this.tooltip_max, 'bottom');
758
+ this._addClass(this.tooltip_max, 'top');
759
+ this.tooltip_max.style.top = -30 + 'px';
760
+ }
761
+ }
762
+
763
+
764
+ var formattedTooltipVal;
765
+
766
+ if (this.options.range) {
767
+ formattedTooltipVal = this.options.formatter(this.options.value);
768
+ this._setText(this.tooltipInner, formattedTooltipVal);
769
+ this.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0])/2 + '%';
770
+
771
+ if (this.options.orientation === 'vertical') {
772
+ this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
773
+ } else {
774
+ this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
775
+ }
776
+
777
+ if (this.options.orientation === 'vertical') {
778
+ this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
779
+ } else {
780
+ this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
781
+ }
782
+
783
+ var innerTooltipMinText = this.options.formatter(this.options.value[0]);
784
+ this._setText(this.tooltipInner_min, innerTooltipMinText);
785
+
786
+ var innerTooltipMaxText = this.options.formatter(this.options.value[1]);
787
+ this._setText(this.tooltipInner_max, innerTooltipMaxText);
788
+
789
+ this.tooltip_min.style[this.stylePos] = positionPercentages[0] + '%';
790
+
791
+ if (this.options.orientation === 'vertical') {
792
+ this._css(this.tooltip_min, 'margin-top', -this.tooltip_min.offsetHeight / 2 + 'px');
793
+ } else {
794
+ this._css(this.tooltip_min, 'margin-left', -this.tooltip_min.offsetWidth / 2 + 'px');
795
+ }
796
+
797
+ this.tooltip_max.style[this.stylePos] = positionPercentages[1] + '%';
798
+
799
+ if (this.options.orientation === 'vertical') {
800
+ this._css(this.tooltip_max, 'margin-top', -this.tooltip_max.offsetHeight / 2 + 'px');
801
+ } else {
802
+ this._css(this.tooltip_max, 'margin-left', -this.tooltip_max.offsetWidth / 2 + 'px');
803
+ }
804
+ } else {
805
+ formattedTooltipVal = this.options.formatter(this.options.value[0]);
806
+ this._setText(this.tooltipInner, formattedTooltipVal);
807
+
808
+ this.tooltip.style[this.stylePos] = positionPercentages[0] + '%';
809
+ if (this.options.orientation === 'vertical') {
810
+ this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
811
+ } else {
812
+ this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
813
+ }
814
+ }
815
+ },
816
+ _removeProperty: function(element, prop) {
817
+ if (element.style.removeProperty) {
818
+ element.style.removeProperty(prop);
819
+ } else {
820
+ element.style.removeAttribute(prop);
821
+ }
822
+ },
823
+ _mousedown: function(ev) {
824
+ if(!this.options.enabled) {
825
+ return false;
826
+ }
827
+
828
+ this._triggerFocusOnHandle();
829
+
830
+ this.offset = this._offset(this.sliderElem);
831
+ this.size = this.sliderElem[this.sizePos];
832
+
833
+ var percentage = this._getPercentage(ev);
834
+
835
+ if (this.options.range) {
836
+ var diff1 = Math.abs(this.percentage[0] - percentage);
837
+ var diff2 = Math.abs(this.percentage[1] - percentage);
838
+ this.dragged = (diff1 < diff2) ? 0 : 1;
839
+ } else {
840
+ this.dragged = 0;
841
+ }
842
+
843
+ this.percentage[this.dragged] = this.options.reversed ? 100 - percentage : percentage;
844
+ this._layout();
845
+
846
+ this.mousemove = this._mousemove.bind(this);
847
+ this.mouseup = this._mouseup.bind(this);
848
+
849
+ if (this.touchCapable) {
850
+ // Touch: Bind touch events:
851
+ document.addEventListener("touchmove", this.mousemove, false);
852
+ document.addEventListener("touchend", this.mouseup, false);
853
+ } else {
854
+ // Bind mouse events:
855
+ document.addEventListener("mousemove", this.mousemove, false);
856
+ document.addEventListener("mouseup", this.mouseup, false);
857
+ }
858
+
859
+ this.inDrag = true;
860
+
861
+ var val = this._calculateValue();
862
+ this._trigger('slideStart', val);
863
+ this._setDataVal(val);
864
+ this.setValue(val);
865
+
866
+ this._pauseEvent(ev);
867
+
868
+ return true;
869
+ },
870
+ _triggerFocusOnHandle: function(handleIdx) {
871
+ if(handleIdx === 0) {
872
+ this.handle1.focus();
873
+ }
874
+ if(handleIdx === 1) {
875
+ this.handle2.focus();
876
+ }
877
+ },
878
+ _keydown: function(handleIdx, ev) {
879
+ if(!this.options.enabled) {
880
+ return false;
881
+ }
882
+
883
+ var dir;
884
+ switch (ev.keyCode) {
885
+ case 37: // left
886
+ case 40: // down
887
+ dir = -1;
888
+ break;
889
+ case 39: // right
890
+ case 38: // up
891
+ dir = 1;
892
+ break;
893
+ }
894
+ if (!dir) {
895
+ return;
896
+ }
897
+
898
+ // use natural arrow keys instead of from min to max
899
+ if (this.options.natural_arrow_keys) {
900
+ var ifVerticalAndNotReversed = (this.options.orientation === 'vertical' && !this.options.reversed);
901
+ var ifHorizontalAndReversed = (this.options.orientation === 'horizontal' && this.options.reversed);
902
+
903
+ if (ifVerticalAndNotReversed || ifHorizontalAndReversed) {
904
+ dir = dir * -1;
905
+ }
906
+ }
907
+
908
+ var oneStepValuePercentageChange = dir * this.percentage[2];
909
+ var percentage = this.percentage[handleIdx] + oneStepValuePercentageChange;
910
+
911
+ if (percentage > 100) {
912
+ percentage = 100;
913
+ } else if (percentage < 0) {
914
+ percentage = 0;
915
+ }
916
+
917
+ this.dragged = handleIdx;
918
+ this._adjustPercentageForRangeSliders(percentage);
919
+ this.percentage[this.dragged] = percentage;
920
+ this._layout();
921
+
922
+ var val = this._calculateValue();
923
+
924
+ this._trigger('slideStart', val);
925
+ this._setDataVal(val);
926
+ this.setValue(val, true);
927
+
928
+ this._trigger('slideStop', val);
929
+ this._setDataVal(val);
930
+
931
+ this._pauseEvent(ev);
932
+
933
+ return false;
934
+ },
935
+ _pauseEvent: function(ev) {
936
+ if(ev.stopPropagation) {
937
+ ev.stopPropagation();
938
+ }
939
+ if(ev.preventDefault) {
940
+ ev.preventDefault();
941
+ }
942
+ ev.cancelBubble=true;
943
+ ev.returnValue=false;
944
+ },
945
+ _mousemove: function(ev) {
946
+ if(!this.options.enabled) {
947
+ return false;
948
+ }
949
+
950
+ var percentage = this._getPercentage(ev);
951
+ this._adjustPercentageForRangeSliders(percentage);
952
+ this.percentage[this.dragged] = this.options.reversed ? 100 - percentage : percentage;
953
+ this._layout();
954
+
955
+ var val = this._calculateValue();
956
+ this.setValue(val, true);
957
+
958
+ return false;
959
+ },
960
+ _adjustPercentageForRangeSliders: function(percentage) {
961
+ if (this.options.range) {
962
+ if (this.dragged === 0 && this.percentage[1] < percentage) {
963
+ this.percentage[0] = this.percentage[1];
964
+ this.dragged = 1;
965
+ } else if (this.dragged === 1 && this.percentage[0] > percentage) {
966
+ this.percentage[1] = this.percentage[0];
967
+ this.dragged = 0;
968
+ }
969
+ }
970
+ },
971
+ _mouseup: function() {
972
+ if(!this.options.enabled) {
973
+ return false;
974
+ }
975
+ if (this.touchCapable) {
976
+ // Touch: Unbind touch event handlers:
977
+ document.removeEventListener("touchmove", this.mousemove, false);
978
+ document.removeEventListener("touchend", this.mouseup, false);
979
+ } else {
980
+ // Unbind mouse event handlers:
981
+ document.removeEventListener("mousemove", this.mousemove, false);
982
+ document.removeEventListener("mouseup", this.mouseup, false);
983
+ }
984
+
985
+ this.inDrag = false;
986
+ if (this.over === false) {
987
+ this._hideTooltip();
988
+ }
989
+ var val = this._calculateValue();
990
+
991
+ this._layout();
992
+ this._setDataVal(val);
993
+ this._trigger('slideStop', val);
994
+
995
+ return false;
996
+ },
997
+ _calculateValue: function() {
998
+ var val;
999
+ if (this.options.range) {
1000
+ val = [this.options.min,this.options.max];
1001
+ if (this.percentage[0] !== 0){
1002
+ val[0] = (Math.max(this.options.min, this.options.min + Math.round((this.diff * this.percentage[0]/100)/this.options.step)*this.options.step));
1003
+ val[0] = this._applyPrecision(val[0]);
1004
+ }
1005
+ if (this.percentage[1] !== 100){
1006
+ val[1] = (Math.min(this.options.max, this.options.min + Math.round((this.diff * this.percentage[1]/100)/this.options.step)*this.options.step));
1007
+ val[1] = this._applyPrecision(val[1]);
1008
+ }
1009
+ this.options.value = val;
1010
+ } else {
1011
+ val = (this.options.min + Math.round((this.diff * this.percentage[0]/100)/this.options.step)*this.options.step);
1012
+ if (val < this.options.min) {
1013
+ val = this.options.min;
1014
+ }
1015
+ else if (val > this.options.max) {
1016
+ val = this.options.max;
1017
+ }
1018
+ val = parseFloat(val);
1019
+ val = this._applyPrecision(val);
1020
+ this.options.value = [val, this.options.value[1]];
1021
+ }
1022
+ return val;
1023
+ },
1024
+ _applyPrecision: function(val) {
1025
+ var precision = this.options.precision || this._getNumDigitsAfterDecimalPlace(this.step);
1026
+ return this._applyToFixedAndParseFloat(val, precision);
1027
+ },
1028
+ _getNumDigitsAfterDecimalPlace: function(num) {
1029
+ var match = (''+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
1030
+ if (!match) { return 0; }
1031
+ return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));
1032
+ },
1033
+ _applyToFixedAndParseFloat: function(num, toFixedInput) {
1034
+ var truncatedNum = num.toFixed(toFixedInput);
1035
+ return parseFloat(truncatedNum);
1036
+ },
1037
+ /*
1038
+ Credits to Mike Samuel for the following method!
1039
+ Source: http://stackoverflow.com/questions/10454518/javascript-how-to-retrieve-the-number-of-decimals-of-a-string-number
1040
+ */
1041
+ _getPercentage: function(ev) {
1042
+ if (this.touchCapable && (ev.type === 'touchstart' || ev.type === 'touchmove')) {
1043
+ ev = ev.touches[0];
1044
+ }
1045
+ var percentage = (ev[this.mousePos] - this.offset[this.stylePos])*100/this.size;
1046
+ percentage = Math.round(percentage/this.percentage[2])*this.percentage[2];
1047
+ return Math.max(0, Math.min(100, percentage));
1048
+ },
1049
+ _validateInputValue: function(val) {
1050
+ if(typeof val === 'number') {
1051
+ return val;
1052
+ } else if(val instanceof Array) {
1053
+ this._validateArray(val);
1054
+ return val;
1055
+ } else {
1056
+ throw new Error( ErrorMsgs.formatInvalidInputErrorMsg(val) );
1057
+ }
1058
+ },
1059
+ _validateArray: function(val) {
1060
+ for(var i = 0; i < val.length; i++) {
1061
+ var input = val[i];
1062
+ if (typeof input !== 'number') { throw new Error( ErrorMsgs.formatInvalidInputErrorMsg(input) ); }
1063
+ }
1064
+ },
1065
+ _setDataVal: function(val) {
1066
+ var value = "value: '" + val + "'";
1067
+ this.element.setAttribute('data', value);
1068
+ this.element.setAttribute('value', val);
1069
+ },
1070
+ _trigger: function(evt, val) {
1071
+ val = val || undefined;
1072
+
1073
+ var callbackFnArray = this.eventToCallbackMap[evt];
1074
+ if(callbackFnArray && callbackFnArray.length) {
1075
+ for(var i = 0; i < callbackFnArray.length; i++) {
1076
+ var callbackFn = callbackFnArray[i];
1077
+ callbackFn(val);
1078
+ }
1079
+ }
1080
+
1081
+ /* If JQuery exists, trigger JQuery events */
1082
+ if($) {
1083
+ this._triggerJQueryEvent(evt, val);
1084
+ }
1085
+ },
1086
+ _triggerJQueryEvent: function(evt, val) {
1087
+ var eventData = {
1088
+ type: evt,
1089
+ value: val
1090
+ };
1091
+ this.$element.trigger(eventData);
1092
+ this.$sliderElem.trigger(eventData);
1093
+ },
1094
+ _unbindJQueryEventHandlers: function() {
1095
+ this.$element.off();
1096
+ this.$sliderElem.off();
1097
+ },
1098
+ _setText: function(element, text) {
1099
+ if(typeof element.innerText !== "undefined") {
1100
+ element.innerText = text;
1101
+ } else if(typeof element.textContent !== "undefined") {
1102
+ element.textContent = text;
1103
+ }
1104
+ },
1105
+ _removeClass: function(element, classString) {
1106
+ var classes = classString.split(" ");
1107
+ var newClasses = element.className;
1108
+
1109
+ for(var i = 0; i < classes.length; i++) {
1110
+ var classTag = classes[i];
1111
+ var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
1112
+ newClasses = newClasses.replace(regex, " ");
1113
+ }
1114
+
1115
+ element.className = newClasses.trim();
1116
+ },
1117
+ _addClass: function(element, classString) {
1118
+ var classes = classString.split(" ");
1119
+ var newClasses = element.className;
1120
+
1121
+ for(var i = 0; i < classes.length; i++) {
1122
+ var classTag = classes[i];
1123
+ var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
1124
+ var ifClassExists = regex.test(newClasses);
1125
+
1126
+ if(!ifClassExists) {
1127
+ newClasses += " " + classTag;
1128
+ }
1129
+ }
1130
+
1131
+ element.className = newClasses.trim();
1132
+ },
1133
+ _offset: function (obj) {
1134
+ var ol = 0;
1135
+ var ot = 0;
1136
+ if (obj.offsetParent) {
1137
+ do {
1138
+ ol += obj.offsetLeft;
1139
+ ot += obj.offsetTop;
1140
+ } while (obj = obj.offsetParent);
1141
+ }
1142
+ return {
1143
+ left: ol,
1144
+ top: ot
1145
+ };
1146
+ },
1147
+ _css: function(elementRef, styleName, value) {
1148
+ elementRef.style[styleName] = value;
1149
+ }
1150
+ };
1151
+
1152
+ /*********************************
1153
+
1154
+ Attach to global namespace
1155
+
1156
+ *********************************/
1157
+ if($) {
1158
+ var namespace = $.fn.slider ? 'bootstrapSlider' : 'slider';
1159
+ $.bridget(namespace, Slider);
1160
+ } else {
1161
+ window.Slider = Slider;
1162
+ }
1163
+
1164
+
1165
+ })( $ );
1166
+
1167
+ })( window.jQuery );