PageSourceSearch

https://wmcamp.net/js/bootstrap.slider.js?2

js wmcamp.net collected 2026-09-29 02:29:58 UTC 23,045 bytes, 793 lines download raw bytes

1/* =========================================================
2 * bootstrap-slider.js v3.0.0
3 * =========================================================
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ========================================================= */
17
18(function( $ ) {
19
20	var ErrorMsgs = {
21		formatInvalidInputErrorMsg : function(input) {
22			return "Invalid input value '" + input + "' passed in";
23		},
24		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"
25	};
26
27
28	var Slider = function(element, options) {
29		var el = this.element = $(element).hide();
30		var origWidth =  $(element)[0].style.width;
31
32		var updateSlider = false;
33		var parent = this.element.parent();
34
35
36		if (parent.hasClass('slider') === true) {
37			updateSlider = true;
38			this.picker = parent;
39		} else {
40			this.picker = $(`
41				<div class="slider">
42					<div class="slider-track">
43						<div class="slider-selection"></div>
44						<div class="slider-handle"></div>
45						<div class="slider-handle"></div>
46					</div>
47					<div id="tooltip" class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>
48					<div id="tooltip_min" class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>
49					<div id="tooltip_max" class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>
50				</div>
51			`)
52			.insertBefore(this.element)
53			.append(this.element);
54		}
55
56		var $track = this.picker.find('.slider-track');
57
58		var min = parseFloat($(element).attr('data-slider-min')) || 0;
59		var max = parseFloat($(element).attr('data-slider-max')) || 100;
60		var totalRange = max - min;
61
62		$track.removeAttr('data-limit-min').removeAttr('data-limit-max').find('.slider-limit-min, .slider-limit-max').remove();
63		if ($(element).is('[data-slider-limit-min]')) {
64			var limitMin = parseFloat($(element).attr('data-slider-limit-min'));
65			if (!isNaN(limitMin) && totalRange > 0 && limitMin > min && limitMin <= max) {
66				var percentMin = ((limitMin - min) / totalRange) * 100;
67				$track.attr('data-limit-min',limitMin);
68				$track.append('<div class="slider-limit-min"></div>');
69				$track.find('.slider-limit-min').css({
70					left: '0%',
71					width: percentMin + '%'
72				});
73			}
74		}
75
76		if ($(element).is('[data-slider-limit-max]')) {
77			var limitMax = parseFloat($(element).attr('data-slider-limit-max'));
78			if (!isNaN(limitMax) && totalRange > 0 && limitMax >= min && limitMax < max) {
79				$track.attr('data-limit-max',limitMax);
80				var percentMax = ((limitMax - min) / totalRange) * 100;
81				var widthMax = 100 - percentMax;
82				$track.append('<div class="slider-limit-max"></div>');
83				$track.find('.slider-limit-max').css({
84					left: percentMax + '%',
85					width: widthMax + '%'
86				});
87			}
88		}
89		$track.find('[data-toggle="tooltip"]').tooltip();
90
91		this.id = this.element.data('slider-id')||options.id;
92		if (this.id) {
93			this.picker[0].id = this.id;
94		}
95
96		if (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch) {
97			this.touchCapable = true;
98		}
99
100		var tooltip = this.element.data('slider-tooltip')||options.tooltip;
101
102		this.tooltip = this.picker.find('#tooltip');
103		this.tooltipInner = this.tooltip.find('div.tooltip-inner');
104
105		this.tooltip_min = this.picker.find('#tooltip_min');
106		this.tooltipInner_min = this.tooltip_min.find('div.tooltip-inner');
107
108		this.tooltip_max = this.picker.find('#tooltip_max');
109		this.tooltipInner_max= this.tooltip_max.find('div.tooltip-inner');
110
111		if (updateSlider === true) {
112			// Reset classes
113			this.picker.removeClass('slider-horizontal');
114			this.picker.removeClass('slider-vertical');
115			if(this.tooltip) this.tooltip.removeClass('hide');
116			if(this.tooltip_min) this.tooltip_min.removeClass('hide');
117			if(this.tooltip_max) this.tooltip_max.removeClass('hide');
118
119		}
120
121		const sliderSetTooltip = (stooltip, stooltip_cls, stooltip_css) => {
122			if (stooltip && stooltip.length) {
123				stooltip.addClass(stooltip_cls).css(stooltip_css);
124			}
125		}
126
127		this.orientation = this.element.data('slider-orientation')||options.orientation;
128		switch(this.orientation) {
129			case 'vertical':
130				this.picker.addClass('slider-vertical');
131				this.stylePos = 'top';
132				this.mousePos = 'pageY';
133				this.sizePos = 'offsetHeight';
134				sliderSetTooltip(this.tooltip, 'right', { left: '100%' });
135				sliderSetTooltip(this.tooltip_min, 'right', { left: '100%' });
136				sliderSetTooltip(this.tooltip_max, 'right', { left: '100%' });
137				break;
138			default:
139				this.picker
140					.addClass('slider-horizontal')
141					.css('width', origWidth);
142				this.orientation = 'horizontal';
143				this.stylePos = 'left';
144				this.mousePos = 'pageX';
145				this.sizePos = 'offsetWidth';
146				sliderSetTooltip(this.tooltip, 'top', { top: -this.tooltip.outerHeight() - 14 });
147				sliderSetTooltip(this.tooltip_min, 'top', { top: -this.tooltip_min.outerHeight() - 14 });
148				sliderSetTooltip(this.tooltip_max, 'top', { top: -this.tooltip_max.outerHeight() - 14 });
149				break;
150		}
151
152		var self = this;
153		$.each(['min',
154				'max',
155				'step',
156				'precision',
157				'value',
158				'reversed',
159				'handle'
160			], function(i, attr) {
161				if (typeof el.data('slider-' + attr) !== 'undefined') {
162					self[attr] = el.data('slider-' + attr);
163				} else if (typeof options[attr] !== 'undefined') {
164					self[attr] = options[attr];
165				} else if (typeof el.prop(attr) !== 'undefined') {
166					self[attr] = el.prop(attr);
167				} else {
168					self[attr] = 0; // to prevent empty string issues in calculations in IE
169				}
170		});
171
172		if (this.value instanceof Array) {
173			if (updateSlider && !this.range) {
174				this.value = this.value[0];
175			} else {
176				this.range = true;
177			}
178		} else if (this.range) {
179			// User wants a range, but value is not an array
180			this.value = [this.value, this.max];
181		}
182
183		this.selection = this.element.data('slider-selection')||options.selection;
184		this.selectionEl = this.picker.find('.slider-selection');
185		if (this.selection === 'none') {
186			this.selectionEl.addClass('hide');
187		}
188
189		this.selectionElStyle = this.selectionEl[0].style;
190
191		this.handle1 = this.picker.find('.slider-handle:first');
192		this.handle1Stype = this.handle1[0].style;
193
194		this.handle2 = this.picker.find('.slider-handle:last');
195		this.handle2Stype = this.handle2[0].style;
196
197		if (updateSlider === true) {
198			// Reset classes
199			this.handle1.removeClass('round triangle');
200			this.handle2.removeClass('round triangle hide');
201		}
202
203		switch(this.handle) {
204			case 'round':
205				this.handle1.addClass('round');
206				this.handle2.addClass('round');
207				break;
208			case 'triangle':
209				this.handle1.addClass('triangle');
210				this.handle2.addClass('triangle');
211				break;
212		}
213
214		this.offset = this.picker.offset();
215		this.size = this.picker[0][this.sizePos];
216		this.formater = options.formater;
217		
218		this.tooltip_separator = options.tooltip_separator;
219		this.tooltip_split = options.tooltip_split;
220
221		this.setValue(this.value);
222
223		this.handle1.on({
224			keydown: $.proxy(this.keydown, this, 0)
225		});
226		this.handle2.on({
227			keydown: $.proxy(this.keydown, this, 1)
228		});
229
230		if (this.touchCapable) {
231			// Touch: Bind touch events:
232			this.picker.on({
233				touchstart: $.proxy(this.mousedown, this)
234			});
235		}
236		// Bind mouse events:
237		this.picker.on({
238			mousedown: $.proxy(this.mousedown, this)
239		});
240
241		if(tooltip === 'hide') {
242			this.tooltip.addClass('hide');
243			this.tooltip_min.addClass('hide');
244			this.tooltip_max.addClass('hide');
245		} else if(tooltip === 'always') {
246			this.showTooltip();
247			this.alwaysShowTooltip = true;
248		} else {
249			this.picker.on({
250				mouseenter: $.proxy(this.showTooltip, this),
251				mouseleave: $.proxy(this.hideTooltip, this)
252			});
253			this.handle1.on({
254				focus: $.proxy(this.showTooltip, this),
255				blur: $.proxy(this.hideTooltip, this)
256			});
257			this.handle2.on({
258				focus: $.proxy(this.showTooltip, this),
259				blur: $.proxy(this.hideTooltip, this)
260			});
261		}
262
263		this.enabled = options.enabled &&
264						(this.element.data('slider-enabled') === undefined || this.element.data('slider-enabled') === true);
265		if(this.enabled) {
266			this.enable();
267		} else {
268			this.disable();
269		}
270	};
271
272	Slider.prototype = {
273		constructor: Slider,
274
275		over: false,
276		inDrag: false,
277
278		showTooltip: function(){
279            if (this.tooltip_split === false ){
280                this.tooltip.addClass('in');
281            } else {
282                this.tooltip_min.addClass('in');
283                this.tooltip_max.addClass('in');
284            }
285
286			this.over = true;
287		},
288
289		hideTooltip: function(){
290			if (this.inDrag === false && this.alwaysShowTooltip !== true) {
291				this.tooltip.removeClass('in');
292				this.tooltip_min.removeClass('in');
293				this.tooltip_max.removeClass('in');
294			}
295			this.over = false;
296		},
297
298		layout: function(){
299			var positionPercentages;
300
301			if(this.reversed) {
302				positionPercentages = [ 100 - this.percentage[0], this.percentage[1] ];
303			} else {
304				positionPercentages = [ this.percentage[0], this.percentage[1] ];
305			}
306
307			this.handle1Stype[this.stylePos] = positionPercentages[0]+'%';
308			this.handle2Stype[this.stylePos] = positionPercentages[1]+'%';
309
310			if (this.orientation === 'vertical') {
311				this.selectionElStyle.top = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
312				this.selectionElStyle.height = Math.abs(positionPercentages[0] - positionPercentages[1]) +'%';
313			} else {
314				this.selectionElStyle.left = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
315				this.selectionElStyle.width = Math.abs(positionPercentages[0] - positionPercentages[1]) +'%';
316
317                var offset_min = this.tooltip_min[0].getBoundingClientRect();
318                var offset_max = this.tooltip_max[0].getBoundingClientRect();
319
320                if (offset_min.right > offset_max.left) {
321                    this.tooltip_max.removeClass('top');
322                    this.tooltip_max.addClass('bottom')[0].style.top = 18 + 'px';
323                } else {
324                    this.tooltip_max.removeClass('bottom');
325                    this.tooltip_max.addClass('top')[0].style.top = -30 + 'px';
326                }
327			}
328
329			if (this.range) {
330				this.tooltipInner.text(
331					this.formater(this.value[0]) + this.tooltip_separator + this.formater(this.value[1])
332				);
333				this.tooltip[0].style[this.stylePos] = this.size * (positionPercentages[0] + (positionPercentages[1] - positionPercentages[0])/2)/100 - (this.orientation === 'vertical' ? this.tooltip.outerHeight()/2 : this.tooltip.outerWidth()/2) +'px';
334
335                this.tooltipInner_min.text(
336					this.formater(this.value[0])
337				);
338                this.tooltipInner_max.text(
339					this.formater(this.value[1])
340				);
341
342				this.tooltip_min[0].style[this.stylePos] = this.size * ( (positionPercentages[0])/100) - (this.orientation === 'vertical' ? this.tooltip_min.outerHeight()/2 : this.tooltip_min.outerWidth()/2) +'px';
343				this.tooltip_max[0].style[this.stylePos] = this.size * ( (positionPercentages[1])/100) - (this.orientation === 'vertical' ? this.tooltip_max.outerHeight()/2 : this.tooltip_max.outerWidth()/2) +'px';
344
345			} else {
346				this.tooltipInner.text(
347					this.formater(this.value[0])
348				);
349				this.tooltip[0].style[this.stylePos] = this.size * positionPercentages[0]/100 - (this.orientation === 'vertical' ? this.tooltip.outerHeight()/2 : this.tooltip.outerWidth()/2) +'px';
350			}
351		},
352
353		mousedown: function(ev) {
354			if(!this.isEnabled()) {
355				return false;
356			}
357			// Touch: Get the original event:
358			if (this.touchCapable && ev.type === 'touchstart') {
359				ev = ev.originalEvent;
360			}
361
362			this.triggerFocusOnHandle();
363
364			this.offset = this.picker.offset();
365			this.size = this.picker[0][this.sizePos];
366
367			var percentage = this.getPercentage(ev);
368
369			if (this.range) {
370				var diff1 = Math.abs(this.percentage[0] - percentage);
371				var diff2 = Math.abs(this.percentage[1] - percentage);
372				this.dragged = (diff1 < diff2) ? 0 : 1;
373			} else {
374				this.dragged = 0;
375			}
376
377			this.percentage[this.dragged] = this.reversed ? 100 - percentage : percentage;
378			this.layout();
379
380			if (this.touchCapable) {
381				// Touch: Bind touch events:
382				$(document).on({
383					touchmove: $.proxy(this.mousemove, this),
384					touchend: $.proxy(this.mouseup, this)
385				});
386			}
387			// Bind mouse events:
388			$(document).on({
389				mousemove: $.proxy(this.mousemove, this),
390				mouseup: $.proxy(this.mouseup, this)
391			});
392
393			this.inDrag = true;
394			var val = this.calculateValue();
395			this.element.trigger({
396					type: 'slideStart',
397					value: val
398				})
399				.data('value', val)
400				.prop('value', val);
401			this.setValue(val);
402			return true;
403		},
404
405		triggerFocusOnHandle: function(handleIdx) {
406			if(handleIdx === 0) {
407				this.handle1.focus();
408			}
409			if(handleIdx === 1) {
410				this.handle2.focus();
411			}
412		},
413
414		keydown: function(handleIdx, ev) {
415			if(!this.isEnabled()) {
416				return false;
417			}
418
419			var dir;
420			switch (ev.which) {
421				case 37: // left
422				case 40: // down
423					dir = -1;
424					break;
425				case 39: // right
426				case 38: // up
427					dir = 1;
428					break;
429			}
430			if (!dir) {
431				return;
432			}
433
434			var oneStepValuePercentageChange = dir * this.percentage[2];
435			var percentage = this.percentage[handleIdx] + oneStepValuePercentageChange;
436
437			if (percentage > 100) {
438				percentage = 100;
439			} else if (percentage < 0) {
440				percentage = 0;
441			}
442
443			this.dragged = handleIdx;
444			this.adjustPercentageForRangeSliders(percentage);
445			this.percentage[this.dragged] = percentage;
446			this.layout();
447
448			var val = this.calculateValue();
449			
450			this.element.trigger({
451					type: 'slideStart',
452					value: val
453				})
454				.data('value', val)
455				.prop('value', val);
456
457			this.slide(val);
458
459			this.element
460				.trigger({
461					type: 'slideStop',
462					value: val
463				})
464				.data('value', val)
465				.prop('value', val);
466			return false;
467		},
468
469		mousemove: function(ev) {
470			if(!this.isEnabled()) {
471				return false;
472			}
473			// Touch: Get the original event:
474			if (this.touchCapable && ev.type === 'touchmove') {
475				ev = ev.originalEvent;
476			}
477
478			var percentage = this.getPercentage(ev);
479			this.adjustPercentageForRangeSliders(percentage);
480			this.percentage[this.dragged] = this.reversed ? 100 - percentage : percentage;
481			this.layout();
482
483			var val = this.calculateValue();
484			this.slide(val);
485
486			return false;
487		},
488		slide: function(val) {
489			this.setValue(val);
490
491			var slideEventValue = this.range ? this.value : this.value[0];
492			this.element
493				.trigger({
494					'type': 'slide',
495					'value': slideEventValue
496				})
497				.data('value', this.value)
498				.prop('value', this.value);
499		},
500		adjustPercentageForRangeSliders: function(percentage) {
501			if (this.range) {
502				if (this.dragged === 0 && this.percentage[1] < percentage) {
503					this.percentage[0] = this.percentage[1];
504					this.dragged = 1;
505				} else if (this.dragged === 1 && this.percentage[0] > percentage) {
506					this.percentage[1] = this.percentage[0];
507					this.dragged = 0;
508				}
509			}
510		},
511
512		mouseup: function() {
513			if(!this.isEnabled()) {
514				return false;
515			}
516			if (this.touchCapable) {
517				// Touch: Unbind touch event handlers:
518				$(document).off({
519					touchmove: this.mousemove,
520					touchend: this.mouseup
521				});
522			}
523			// Unbind mouse event handlers:
524			$(document).off({
525				mousemove: this.mousemove,
526				mouseup: this.mouseup
527			});
528
529			this.inDrag = false;
530			if (this.over === false) {
531				this.hideTooltip();
532			}
533			var val = this.calculateValue();
534			this.layout();
535			this.element
536				.data('value', val)
537				.prop('value', val)
538				.trigger({
539					type: 'slideStop',
540					value: val
541				});
542			return false;
543		},
544
545		calculateValue: function() {
546			var val;
547			if (this.range) {
548				val = [this.min,this.max];
549                if (this.percentage[0] !== 0){
550                    val[0] = (Math.max(this.min, this.min + Math.round((this.diff * this.percentage[0]/100)/this.step)*this.step));
551                    val[0] = this.applyPrecision(val[0]);
552                }
553                if (this.percentage[1] !== 100){
554                    val[1] = (Math.min(this.max, this.min + Math.round((this.diff * this.percentage[1]/100)/this.step)*this.step));
555                    val[1] = this.applyPrecision(val[1]);
556                }
557				this.value = val;
558			} else {
559				val = (this.min + Math.round((this.diff * this.percentage[0]/100)/this.step)*this.step);
560				if (val < this.min) {
561					val = this.min;
562				}
563				else if (val > this.max) {
564					val = this.max;
565				}
566				val = parseFloat(val);
567				val = this.applyPrecision(val);
568				this.value = [val, this.value[1]];
569			}
570			return val;
571		},
572		applyPrecision: function(val) {
573			var precision = this.precision || this.getNumDigitsAfterDecimalPlace(this.step);
574			return this.applyToFixedAndParseFloat(val, precision);
575		},
576		/*
577			Credits to Mike Samuel for the following method!
578			Source: http://stackoverflow.com/questions/10454518/javascript-how-to-retrieve-the-number-of-decimals-of-a-string-number
579		*/
580		getNumDigitsAfterDecimalPlace: function(num) {
581			var match = (''+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
582			if (!match) { return 0; }
583			return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));
584		},
585
586		applyToFixedAndParseFloat: function(num, toFixedInput) {
587			var truncatedNum = num.toFixed(toFixedInput);
588			return parseFloat(truncatedNum);
589		},
590
591		getPercentage: function(ev) {
592			if (this.touchCapable && (ev.type === 'touchstart' || ev.type === 'touchmove')) {
593				ev = ev.touches[0];
594			}
595			var percentage = (ev[this.mousePos] - this.offset[this.stylePos])*100/this.size;
596			percentage = Math.round(percentage/this.percentage[2])*this.percentage[2];
597			return Math.max(0, Math.min(100, percentage));
598		},
599
600		getValue: function() {
601			if (this.range) {
602				return this.value;
603			}
604			return this.value[0];
605		},
606
607		setValue: function(val) {
608			if (!val) {
609				val = 0;
610			}
611
612			this.value = this.validateInputValue(val);
613
614			if (this.range) {
615				this.value[0] = this.applyPrecision(this.value[0]);
616				this.value[1] = this.applyPrecision(this.value[1]); 
617
618				this.value[0] = Math.max(this.min, Math.min(this.max, this.value[0]));
619				this.value[1] = Math.max(this.min, Math.min(this.max, this.value[1]));
620			} else {
621				this.value = this.applyPrecision(this.value);
622				this.value = [ Math.max(this.min, Math.min(this.max, this.value))];
623				this.handle2.addClass('hide');
624				if (this.selection === 'after') {
625					this.value[1] = this.max;
626				} else {
627					this.value[1] = this.min;
628				}
629			}
630
631			this.diff = this.max - this.min;
632			if (this.diff > 0) {
633				this.percentage = [
634					(this.value[0] - this.min) * 100 / this.diff,
635					(this.value[1] - this.min) * 100 / this.diff,
636					this.step * 100 / this.diff
637				];
638			} else {
639				this.percentage = [0, 0, 100];
640			}
641
642			this.layout();
643		},
644
645		validateInputValue : function(val) {
646			if(typeof val === 'number') {
647				return val;
648			} else if(val instanceof Array) {
649				$.each(val, function(i, input) { if (typeof input !== 'number') { throw new Error( ErrorMsgs.formatInvalidInputErrorMsg(input) ); }});
650				return val;
651			} else {
652				throw new Error( ErrorMsgs.formatInvalidInputErrorMsg(val) );
653			}
654		},
655
656		destroy: function(){
657			this.handle1.off();
658			this.handle2.off();
659			this.element.off().show().insertBefore(this.picker);
660			this.picker.off().remove();
661			$(this.element).removeData('slider');
662		},
663
664		disable: function() {
665			this.enabled = false;
666			this.handle1.removeAttr("tabindex");
667			this.handle2.removeAttr("tabindex");
668			this.picker.addClass('slider-disabled');
669			this.element.trigger('slideDisabled');
670		},
671
672		enable: function() {
673			this.enabled = true;
674			this.handle1.attr("tabindex", 0);
675			this.handle2.attr("tabindex", 0);
676			this.picker.removeClass('slider-disabled');
677			this.element.trigger('slideEnabled');
678		},
679
680		toggle: function() {
681			if(this.enabled) {
682				this.disable();
683			} else {
684				this.enable();
685			}
686		},
687
688		isEnabled: function() {
689			return this.enabled;
690		},
691
692		setAttribute: function(attribute, value) {
693			this[attribute] = value;
694		},
695
696		getAttribute: function(attribute) {
697			return this[attribute];
698		}
699
700	};
701
702	var publicMethods = {
703		getValue : Slider.prototype.getValue,
704		setValue : Slider.prototype.setValue,
705		setAttribute : Slider.prototype.setAttribute,
706		getAttribute : Slider.prototype.getAttribute,
707		destroy : Slider.prototype.destroy,
708		disable : Slider.prototype.disable,
709		enable : Slider.prototype.enable,
710		toggle : Slider.prototype.toggle,
711		isEnabled: Slider.prototype.isEnabled
712	};
713
714	$.fn.slider = function (option) {
715		if (typeof option === 'string' && option !== 'refresh') {
716			var args = Array.prototype.slice.call(arguments, 1);
717			return invokePublicMethod.call(this, option, args);
718		} else {
719			return createNewSliderInstance.call(this, option);
720		}
721	};
722
723	function invokePublicMethod(methodName, args) {
724		if(publicMethods[methodName]) {
725			var sliderObject = retrieveSliderObjectFromElement(this);
726			var result = publicMethods[methodName].apply(sliderObject, args);
727
728			if (typeof result === "undefined") {
729				return $(this);
730			} else {
731				return result;
732			}
733		} else {
734			throw new Error("method '" + methodName + "()' does not exist for slider.");
735		}
736	}
737
738	function retrieveSliderObjectFromElement(element) {
739		var sliderObject = $(element).data('slider');
740		if(sliderObject && sliderObject instanceof Slider) {
741			return sliderObject;
742		} else {
743			throw new Error(ErrorMsgs.callingContextNotSliderInstance);
744		}
745	}
746
747	function createNewSliderInstance(opts) {
748		var $this = $(this);
749		$this.each(function() {
750			var $this = $(this),
751				slider = $this.data('slider'),
752				options = typeof opts === 'object' && opts;
753
754			// If slider already exists, use its attributes
755			// as options so slider refreshes properly
756			if (slider && !options) {
757				options = {};
758
759				$.each($.fn.slider.defaults, function(key) {
760					options[key] = slider[key];
761				});
762			}
763
764			$this.data('slider', (new Slider(this, $.extend({}, $.fn.slider.defaults, options))));
765		});
766		return $this;
767	}
768
769	$.fn.slider.defaults = {
770		min: 0,
771		max: 10,
772		step: 1,
773		precision: 0,
774		orientation: 'horizontal',
775		value: 5,
776		range: false,
777		selection: 'before',
778		tooltip: 'show',
779		tooltip_separator: ':',
780		tooltip_split: false,
781		handle: 'round',
782		reversed : false,
783		enabled: true,
784		formater: function(value) {
785			return value;
786		}
787	};
788
789	$.fn.slider.Constructor = Slider;
790
791})( window.jQuery );
792
793/* vim: set noexpandtab tabstop=4 shiftwidth=4 autoindent: */

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.