(function(d){"function"===typeof define&&define.amd?define(["jquery","./core","./mouse","./widget"],d):d(jQuery)})(function(d){return d.widget("ui.slider",d.ui.mouse,{version:"1.11.4",widgetEventPrefix:"slide",options:{animate:!1,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.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget ui-widget-content ui-corner-all");this._refresh();this._setOption("disabled",this.options.disabled);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").addClass("ui-state-default ui-corner-all"),e=[];b=a.values&&a.values.length||1;c.length>
b&&(c.slice(b).remove(),c=c.slice(0,b));for(a=c.length;a<b;a++)e.push("<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>");this.handles=c.add(d(e.join("")).appendTo(this.element));this.handle=this.handles.eq(0);this.handles.each(function(a){d(this).data("ui-slider-handle-index",a)})},_createRange:function(){var a=this.options,b="";a.range?(!0===a.range&&(a.values?a.values.length&&2!==a.values.length?a.values=[a.values[0],a.values[0]]:d.isArray(a.values)&&(a.values=
a.values.slice(0)):a.values=[this._valueMin(),this._valueMin()]),this.range&&this.range.length?this.range.removeClass("ui-slider-range-min ui-slider-range-max").css({left:"",bottom:""}):(this.range=d("<div></div>").appendTo(this.element),b="ui-slider-range ui-widget-header ui-corner-all"),this.range.addClass(b+("min"===a.range||"max"===a.range?" ui-slider-range-"+a.range:""))):(this.range&&this.range.remove(),this.range=null)},_setupEvents:function(){this._off(this.handles);this._on(this.handles,
this._handleEvents);this._hoverable(this.handles);this._focusable(this.handles)},_destroy:function(){this.handles.remove();this.range&&this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-widget ui-widget-content ui-corner-all");this._mouseDestroy()},_mouseCapture:function(a){var b,c,e,f,k,g=this,h=this.options;if(h.disabled)return!1;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();
b=this._normValueFromMouse({x:a.pageX,y:a.pageY});c=this._valueMax()-this._valueMin()+1;this.handles.each(function(a){var k=Math.abs(b-g.values(a));if(c>k||c===k&&(a===g._lastChangedValue||g.values(a)===h.min))c=k,e=d(this),f=a});if(!1===this._start(a,f))return!1;this._mouseSliding=!0;this._handleIndex=f;e.addClass("ui-state-active").focus();k=e.offset();this._clickOffset=d(a.target).parents().addBack().is(".ui-slider-handle")?{left:a.pageX-k.left-e.width()/2,top:a.pageY-k.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.handles.removeClass("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;1<b&&(b=1);0>b&&(b=0);"vertical"===this.orientation&&
(b=1-b);a=this._valueMax()-this._valueMin();b=this._valueMin()+b*a;return this._trimAlignValue(b)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values());return this._trigger("start",a,c)},_slide:function(a,b,c){var d;this.options.values&&this.options.values.length?(d=this.values(b?0:1),2===this.options.values.length&&!0===this.options.range&&(0===b&&c>d||1===b&&c<d)&&(c=d),c!==this.values(b)&&
(d=this.values(),d[b]=c,a=this._trigger("slide",a,{handle:this.handles[b],value:c,values:d}),this.values(b?0:1),!1!==a&&this.values(b,c))):c!==this.value()&&(a=this._trigger("slide",a,{handle:this.handles[b],value:c}),!1!==a&&this.value(c))},_stop:function(a,b){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values());this._trigger("stop",a,c)},_change:function(a,b){if(!this._keySliding&&!this._mouseSliding){var c=
{handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values());this._lastChangedValue=b;this._trigger("change",a,c)}},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<arguments.length)this.options.values[a]=this._trimAlignValue(b),this._refreshValue(),this._change(null,a);else if(arguments.length)if(d.isArray(arguments[0])){c=
this.options.values;e=arguments[0];for(f=0;f<c.length;f+=1)c[f]=this._trimAlignValue(e[f]),this._change(null,f);this._refreshValue()}else return this.options.values&&this.options.values.length?this._values(a):this.value();else return this._values()},_setOption:function(a,b){var c,e=0;"range"===a&&!0===this.options.range&&("min"===b?(this.options.value=this._values(0),this.options.values=null):"max"===b&&(this.options.value=this._values(this.options.values.length-1),this.options.values=null));d.isArray(this.options.values)&&
(e=this.options.values.length);"disabled"===a&&this.element.toggleClass("ui-state-disabled",!!b);this._super(a,b);switch(a){case "orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();this.handles.css("horizontal"===b?"bottom":"left","");break;case "value":this._animateOff=!0;this._refreshValue();this._change(null,0);this._animateOff=!1;break;case "values":this._animateOff=!0;this._refreshValue();
for(c=0;c<e;c+=1)this._change(null,c);this._animateOff=!1;break;case "step":case "min":case "max":this._animateOff=!0;this._calculateNewMax();this._refreshValue();this._animateOff=!1;break;case "range":this._animateOff=!0,this._refresh(),this._animateOff=!1}},_value:function(){var a=this.options.value;return a=this._trimAlignValue(a)},_values:function(a){var b,c;if(arguments.length)return b=this.options.values[a],b=this._trimAlignValue(b);if(this.options.values&&this.options.values.length){b=this.options.values.slice();
for(c=0;c<b.length;c+=1)b[c]=this._trimAlignValue(b[c]);return b}return[]},_trimAlignValue:function(a){if(a<=this._valueMin())return this._valueMin();if(a>=this._valueMax())return this._valueMax();var b=0<this.options.step?this.options.step:1,c=(a-this._valueMin())%b;a-=c;2*Math.abs(c)>=b&&(a+=0<c?b:-b);return parseFloat(a.toFixed(5))},_calculateNewMax:function(){var a=this.options.max,b=this._valueMin(),c=this.options.step,a=Math.floor(+(a-b).toFixed(this._precision())/c)*c+b;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},_refreshValue:function(){var a,b,c,e,f,k=this.options.range,g=this.options,h=this,l=this._animateOff?!1:g.animate,m={};if(this.options.values&&this.options.values.length)this.handles.each(function(c){b=
(h.values(c)-h._valueMin())/(h._valueMax()-h._valueMin())*100;m["horizontal"===h.orientation?"left":"bottom"]=b+"%";d(this).stop(1,1)[l?"animate":"css"](m,g.animate);if(!0===h.options.range)if("horizontal"===h.orientation){if(0===c)h.range.stop(1,1)[l?"animate":"css"]({left:b+"%"},g.animate);if(1===c)h.range[l?"animate":"css"]({width:b-a+"%"},{queue:!1,duration:g.animate})}else{if(0===c)h.range.stop(1,1)[l?"animate":"css"]({bottom:b+"%"},g.animate);if(1===c)h.range[l?"animate":"css"]({height:b-a+
"%"},{queue:!1,duration:g.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,g.animate);if("min"===k&&"horizontal"===this.orientation)this.range.stop(1,1)[l?"animate":"css"]({width:b+"%"},g.animate);if("max"===k&&"horizontal"===this.orientation)this.range[l?"animate":"css"]({width:100-b+"%"},{queue:!1,duration:g.animate});if("min"===k&&"vertical"===this.orientation)this.range.stop(1,
1)[l?"animate":"css"]({height:b+"%"},g.animate);if("max"===k&&"vertical"===this.orientation)this.range[l?"animate":"css"]({height:100-b+"%"},{queue:!1,duration:g.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,d(a.target).addClass("ui-state-active"),b=this._start(a,f),!1===b))return}e=this.options.step;b=this.options.values&&this.options.values.length?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),d(a.target).removeClass("ui-state-active"))}}})});