(function(d){d.widget("ui.slider",d.ui.mouse,{widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var a=this,b=this.options,c=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f=b.values&&b.values.length||1,e=[];this._mouseSliding=this._keySliding=!1;this._animateOff=!0;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+
this.orientation+" ui-widget ui-widget-content ui-corner-all"+(b.disabled?" ui-slider-disabled ui-disabled":""));this.range=d([]);b.range&&(!0===b.range&&(b.values||(b.values=[this._valueMin(),this._valueMin()]),b.values.length&&2!==b.values.length&&(b.values=[b.values[0],b.values[0]])),this.range=d("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+("min"===b.range||"max"===b.range?" ui-slider-range-"+b.range:"")));for(var g=c.length;g<f;g+=1)e.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
this.handles=c.add(d(e.join("")).appendTo(a.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(a){a.preventDefault()}).hover(function(){b.disabled||d(this).addClass("ui-state-hover")},function(){d(this).removeClass("ui-state-hover")}).focus(function(){b.disabled?d(this).blur():(d(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),d(this).addClass("ui-state-focus"))}).blur(function(){d(this).removeClass("ui-state-focus")});this.handles.each(function(a){d(this).data("index.ui-slider-handle",
a)});this.handles.keydown(function(b){var c=d(this).data("index.ui-slider-handle"),f,e,g;if(!a.options.disabled){switch(b.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(b.preventDefault(),!a._keySliding&&(a._keySliding=!0,d(this).addClass("ui-state-active"),f=a._start(b,c),!1===f))return}f=a.options.step;a.options.values&&a.options.values.length?
e=g=a.values(c):e=g=a.value();switch(b.keyCode){case d.ui.keyCode.HOME:g=a._valueMin();break;case d.ui.keyCode.END:g=a._valueMax();break;case d.ui.keyCode.PAGE_UP:g=a._trimAlignValue(e+(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.PAGE_DOWN:g=a._trimAlignValue(e-(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(e===a._valueMax())return;g=a._trimAlignValue(e+f);break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(e===a._valueMin())return;g=a._trimAlignValue(e-
f)}a._slide(b,c,g)}}).keyup(function(b){var c=d(this).data("index.ui-slider-handle");a._keySliding&&(a._keySliding=!1,a._stop(b,c),a._change(b,c),d(this).removeClass("ui-state-active"))});this._refreshValue();this._animateOff=!1},destroy:function(){return this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider"),this._mouseDestroy(),this},
_mouseCapture:function(a){var b=this.options,c,f,e,g,i,h,j,k,l;return b.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),c={x:a.pageX,y:a.pageY},f=this._normValueFromMouse(c),e=this._valueMax()-this._valueMin()+1,i=this,this.handles.each(function(a){var b=Math.abs(f-i.values(a));e>b&&(e=b,g=d(this),h=a)}),!0===b.range&&this.values(1)===b.min&&(h+=1,g=d(this.handles[h])),j=this._start(a,h),!1===j?!1:(this._mouseSliding=
!0,i._handleIndex=h,g.addClass("ui-state-active").focus(),k=g.offset(),l=!d(a.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:a.pageX-k.left-g.width()/2,top:a.pageY-k.top-g.height()/2-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(a,h,f),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(a){var b=
this._normValueFromMouse({x:a.pageX,y:a.pageY});return this._slide(a,this._handleIndex,b),!1},_mouseStop:function(a){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(a,this._handleIndex),this._change(a,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(a){var b,c,f,e,d;return"horizontal"===
this.orientation?(b=this.elementSize.width,c=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(b=this.elementSize.height,c=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),f=c/b,1<f&&(f=1),0>f&&(f=0),"vertical"===this.orientation&&(f=1-f),e=this._valueMax()-this._valueMin(),d=this._valueMin()+f*e,this._trimAlignValue(d)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};return this.options.values&&this.options.values.length&&(c.value=
this.values(b),c.values=this.values()),this._trigger("start",a,c)},_slide:function(a,b,c){var d,e,g;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)&&(e=this.values(),e[b]=c,g=this._trigger("slide",a,{handle:this.handles[b],value:c,values:e}),this.values(b?0:1),!1!==g&&this.values(b,c,!0))):c!==this.value()&&(g=this._trigger("slide",a,{handle:this.handles[b],value:c}),!1!==
g&&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._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,f,e;if(1<arguments.length)this.options.values[a]=this._trimAlignValue(b),this._refreshValue(),this._change(null,a);else{if(!arguments.length)return this._values();if(!d.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(a):this.value();c=this.options.values;f=arguments[0];for(e=0;e<c.length;e+=1)c[e]=this._trimAlignValue(f[e]),this._change(null,
e);this._refreshValue()}},_setOption:function(a,b){var c,f=0;d.isArray(this.options.values)&&(f=this.options.values.length);d.Widget.prototype._setOption.apply(this,arguments);switch(a){case "disabled":b?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.propAttr("disabled",!0),this.element.addClass("ui-disabled")):(this.handles.propAttr("disabled",!1),this.element.removeClass("ui-disabled"));break;case "orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+
this.orientation);this._refreshValue();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<f;c+=1)this._change(null,c);this._animateOff=!1}},_value:function(){var a=this.options.value;return a=this._trimAlignValue(a),a},_values:function(a){var b,c;if(arguments.length)return b=this.options.values[a],b=this._trimAlignValue(b),b;b=this.options.values.slice();for(c=0;c<b.length;c+=1)b[c]=
this._trimAlignValue(b[c]);return b},_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=a-c;return 2*Math.abs(c)>=b&&(a+=0<c?b:-b),parseFloat(a.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var a=this.options.range,b=this.options,c=this,f=this._animateOff?!1:b.animate,e,g=
{},i,h,j,k;this.options.values&&this.options.values.length?this.handles.each(function(a){e=100*((c.values(a)-c._valueMin())/(c._valueMax()-c._valueMin()));g["horizontal"===c.orientation?"left":"bottom"]=e+"%";d(this).stop(1,1)[f?"animate":"css"](g,b.animate);!0===c.options.range&&("horizontal"===c.orientation?(0===a&&c.range.stop(1,1)[f?"animate":"css"]({left:e+"%"},b.animate),1===a&&c.range[f?"animate":"css"]({width:e-i+"%"},{queue:!1,duration:b.animate})):(0===a&&c.range.stop(1,1)[f?"animate":"css"]({bottom:e+
"%"},b.animate),1===a&&c.range[f?"animate":"css"]({height:e-i+"%"},{queue:!1,duration:b.animate})));i=e}):(h=this.value(),j=this._valueMin(),k=this._valueMax(),e=k!==j?100*((h-j)/(k-j)):0,g["horizontal"===c.orientation?"left":"bottom"]=e+"%",this.handle.stop(1,1)[f?"animate":"css"](g,b.animate),"min"===a&&"horizontal"===this.orientation&&this.range.stop(1,1)[f?"animate":"css"]({width:e+"%"},b.animate),"max"===a&&"horizontal"===this.orientation&&this.range[f?"animate":"css"]({width:100-e+"%"},{queue:!1,
duration:b.animate}),"min"===a&&"vertical"===this.orientation&&this.range.stop(1,1)[f?"animate":"css"]({height:e+"%"},b.animate),"max"===a&&"vertical"===this.orientation&&this.range[f?"animate":"css"]({height:100-e+"%"},{queue:!1,duration:b.animate}))}});d.extend(d.ui.slider,{version:"1.8.23"})})(jQuery);