template.js.base.slider.min.js Maven / Gradle / Ivy
'use strict';(function(d){"function"===typeof define&&define.amd?define(["jquery","./mouse","../keycode","../version","../widget"],d):d(jQuery)})(function(d){return d.widget("ui.slider",d.ui.mouse,{version:"1.12.1",widgetEventPrefix:"slide",options:{animate:!1,classes:{"ui-slider":"ui-corner-all","ui-slider-handle":"ui-corner-all","ui-slider-range":"ui-corner-all ui-widget-header"},distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null,change:null,slide:null,start:null,
stop:null},numPages:5,_create:function(){this._mouseSliding=this._keySliding=!1;this._animateOff=!0;this._handleIndex=null;this._detectOrientation();this._mouseInit();this._calculateNewMax();this._addClass("ui-slider ui-slider-"+this.orientation,"ui-widget ui-widget-content");this._refresh();this._animateOff=!1},_refresh:function(){this._createRange();this._createHandles();this._setupEvents();this._refreshValue()},_createHandles:function(){var a,b;a=this.options;var c=this.element.find(".ui-slider-handle"),
e=[];b=a.values&&a.values.length||1;c.length>b&&(c.slice(b).remove(),c=c.slice(0,b));for(a=c.length;ag||c===g&&(a===h._lastChangedValue||h.values(a)===k.min))c=g,e=d(this),f=a});if(!1===this._start(a,f))return!1;this._mouseSliding=!0;this._handleIndex=f;this._addClass(e,null,"ui-state-active");e.trigger("focus");g=e.offset();this._clickOffset=d(a.target).parents().addBack().is(".ui-slider-handle")?{left:a.pageX-g.left-e.width()/2,top:a.pageY-g.top-e.height()/2-(parseInt(e.css("borderTopWidth"),
10)||0)-(parseInt(e.css("borderBottomWidth"),10)||0)+(parseInt(e.css("marginTop"),10)||0)}:{left:0,top:0};this.handles.hasClass("ui-state-hover")||this._slide(a,f,b);return this._animateOff=!0},_mouseStart:function(){return!0},_mouseDrag:function(a){var b=this._normValueFromMouse({x:a.pageX,y:a.pageY});this._slide(a,this._handleIndex,b);return!1},_mouseStop:function(a){this._removeClass(this.handles,null,"ui-state-active");this._mouseSliding=!1;this._stop(a,this._handleIndex);this._change(a,this._handleIndex);
this._clickOffset=this._handleIndex=null;return this._animateOff=!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(a){var b;"horizontal"===this.orientation?(b=this.elementSize.width,a=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(b=this.elementSize.height,a=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0));b=a/b;1b&&(b=0);"vertical"===this.orientation&&
(b=1-b);a=this._valueMax()-this._valueMin();b=this._valueMin()+b*a;return this._trimAlignValue(b)},_uiHash:function(a,b,c){var d={handle:this.handles[a],handleIndex:a,value:void 0!==b?b:this.value()};this._hasMultipleValues()&&(d.value=void 0!==b?b:this.values(a),d.values=c||this.values());return d},_hasMultipleValues:function(){return this.options.values&&this.options.values.length},_start:function(a,b){return this._trigger("start",a,this._uiHash(b))},_slide:function(a,b,c){var d,f=this.value(),
g=this.values();this._hasMultipleValues()&&(d=this.values(b?0:1),f=this.values(b),2===this.options.values.length&&!0===this.options.range&&(c=0===b?Math.min(d,c):Math.max(d,c)),g[b]=c);c!==f&&(a=this._trigger("slide",a,this._uiHash(b,c,g)),!1!==a&&(this._hasMultipleValues()?this.values(b,c):this.value(c)))},_stop:function(a,b){this._trigger("stop",a,this._uiHash(b))},_change:function(a,b){this._keySliding||this._mouseSliding||(this._lastChangedValue=b,this._trigger("change",a,this._uiHash(b)))},value:function(a){if(arguments.length)this.options.value=
this._trimAlignValue(a),this._refreshValue(),this._change(null,0);else return this._value()},values:function(a,b){var c,e,f;if(1=this._valueMax())return this._valueMax();
var b=0=b&&(a+=0this.options.max&&(a-=c);this.max=parseFloat(a.toFixed(this._precision()))},_precision:function(){var a=this._precisionOf(this.options.step);null!==this.options.min&&(a=Math.max(a,this._precisionOf(this.options.min)));return a},_precisionOf:function(a){a=
a.toString();var b=a.indexOf(".");return-1===b?0:a.length-b-1},_valueMin:function(){return this.options.min},_valueMax:function(){return this.max},_refreshRange:function(a){"vertical"===a&&this.range.css({width:"",left:""});"horizontal"===a&&this.range.css({height:"",bottom:""})},_refreshValue:function(){var a,b,c,e,f,g=this.options.range,h=this.options,k=this,l=this._animateOff?!1:h.animate,m={};if(this._hasMultipleValues())this.handles.each(function(c){b=(k.values(c)-k._valueMin())/(k._valueMax()-
k._valueMin())*100;m["horizontal"===k.orientation?"left":"bottom"]=b+"%";d(this).stop(1,1)[l?"animate":"css"](m,h.animate);if(!0===k.options.range)if("horizontal"===k.orientation){if(0===c)k.range.stop(1,1)[l?"animate":"css"]({left:b+"%"},h.animate);if(1===c)k.range[l?"animate":"css"]({width:b-a+"%"},{queue:!1,duration:h.animate})}else{if(0===c)k.range.stop(1,1)[l?"animate":"css"]({bottom:b+"%"},h.animate);if(1===c)k.range[l?"animate":"css"]({height:b-a+"%"},{queue:!1,duration:h.animate})}a=b});else{c=
this.value();e=this._valueMin();f=this._valueMax();b=f!==e?(c-e)/(f-e)*100:0;m["horizontal"===this.orientation?"left":"bottom"]=b+"%";this.handle.stop(1,1)[l?"animate":"css"](m,h.animate);if("min"===g&&"horizontal"===this.orientation)this.range.stop(1,1)[l?"animate":"css"]({width:b+"%"},h.animate);if("max"===g&&"horizontal"===this.orientation)this.range.stop(1,1)[l?"animate":"css"]({width:100-b+"%"},h.animate);if("min"===g&&"vertical"===this.orientation)this.range.stop(1,1)[l?"animate":"css"]({height:b+
"%"},h.animate);if("max"===g&&"vertical"===this.orientation)this.range.stop(1,1)[l?"animate":"css"]({height:100-b+"%"},h.animate)}},_handleEvents:{keydown:function(a){var b,c,e,f=d(a.target).data("ui-slider-handle-index");switch(a.keyCode){case d.ui.keyCode.HOME:case d.ui.keyCode.END:case d.ui.keyCode.PAGE_UP:case d.ui.keyCode.PAGE_DOWN:case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(a.preventDefault(),!this._keySliding&&(this._keySliding=!0,this._addClass(d(a.target),
null,"ui-state-active"),b=this._start(a,f),!1===b))return}e=this.options.step;b=this._hasMultipleValues()?c=this.values(f):c=this.value();switch(a.keyCode){case d.ui.keyCode.HOME:c=this._valueMin();break;case d.ui.keyCode.END:c=this._valueMax();break;case d.ui.keyCode.PAGE_UP:c=this._trimAlignValue(b+(this._valueMax()-this._valueMin())/this.numPages);break;case d.ui.keyCode.PAGE_DOWN:c=this._trimAlignValue(b-(this._valueMax()-this._valueMin())/this.numPages);break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(b===
this._valueMax())return;c=this._trimAlignValue(b+e);break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(b===this._valueMin())return;c=this._trimAlignValue(b-e)}this._slide(a,f,c)},keyup:function(a){var b=d(a.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(a,b),this._change(a,b),this._removeClass(d(a.target),null,"ui-state-active"))}}})});
© 2015 - 2024 Weber Informatics LLC | Privacy Policy