(function($){
$.fn.unwrap=$.fn.unwrap||function(_1){
return this.each(function(){
$(this).parents(_1).eq(0).after(this).remove();
});
};
$.widget("ui.slider",{_init:function(){
var _2=this;
this.element.addClass("ui-slider");
this._initBoundaries();
this.handle=$(this.options.handle,this.element);
if(!this.handle.length){
_2.handle=_2.generated=$(_2.options.handles||[0]).map(function(){
var _3=$("<div/>").addClass("ui-slider-handle").appendTo(_2.element);
if(this.id){
_3.attr("id",this.id);
}
return _3[0];
});
}
var _4=function(el){
this.element=$(el);
this.element.data("mouse",this);
this.options=_2.options;
this.element.bind("mousedown",function(){
if(_2.currentHandle){
this.blur(_2.currentHandle);
}
_2._focus(this,true);
});
this._mouseInit();
};
$.extend(_4.prototype,$.ui.mouse,{_mouseCapture:function(){
return true;
},_mouseStart:function(_5){
return _2._start.call(_2,_5,this.element[0]);
},_mouseDrag:function(_6){
return _2._drag.call(_2,_6,this.element[0]);
},_mouseStop:function(_7){
return _2._stop.call(_2,_7,this.element[0]);
},trigger:function(_8){
this._mouseDown(_8);
}});
$(this.handle).each(function(){
new _4(this);
}).wrap("<a href=\"#\" style=\"outline:none;border:none;\"></a>").parent().bind("click",function(){
return false;
}).bind("focus",function(_9){
_2._focus(this.firstChild);
}).bind("blur",function(_a){
_2._blur(this.firstChild);
}).bind("keydown",function(_b){
if(!_2.options.noKeyboard){
return _2._keydown(_b.keyCode,this.firstChild);
}
});
this.element.bind("mousedown.slider",function(_c){
if($(_c.target).is(".ui-slider-handle")){
return;
}
_2._click.apply(_2,[_c]);
_2.currentHandle.data("mouse").trigger(_c);
_2.firstValue=_2.firstValue+1;
});
$.each(this.options.handles||[],function(_d,_e){
_2.moveTo(_e.start,_d,true);
});
if(!isNaN(this.options.startValue)){
this.moveTo(this.options.startValue,0,true);
}
this.previousHandle=$(this.handle[0]);
if(this.handle.length==2&&this.options.range){
this._createRange();
}
},destroy:function(){
this.element.removeClass("ui-slider ui-slider-disabled").removeData("slider").unbind(".slider");
if(this.handle&&this.handle.length){
this.handle.unwrap("a");
this.handle.each(function(){
var _f=$(this).data("mouse");
_f&&_f._mouseDestroy();
});
}
this.generated&&this.generated.remove();
},_start:function(_10,_11){
var o=this.options;
if(o.disabled){
return false;
}
this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};
if(!this.currentHandle){
this._focus(this.previousHandle,true);
}
this.offset=this.element.offset();
this.handleOffset=this.currentHandle.offset();
this.clickOffset={top:_10.pageY-this.handleOffset.top,left:_10.pageX-this.handleOffset.left};
this.firstValue=this.value();
this._propagate("start",_10);
this._drag(_10,_11);
return true;
},_drag:function(_12,_13){
var o=this.options;
var _14={top:_12.pageY-this.offset.top-this.clickOffset.top,left:_12.pageX-this.offset.left-this.clickOffset.left};
if(!this.currentHandle){
this._focus(this.previousHandle,true);
}
_14.left=this._translateLimits(_14.left,"x");
_14.top=this._translateLimits(_14.top,"y");
if(o.stepping.x){
var _15=this._convertValue(_14.left,"x");
_15=this._round(_15/o.stepping.x)*o.stepping.x;
_14.left=this._translateValue(_15,"x");
}
if(o.stepping.y){
var _15=this._convertValue(_14.top,"y");
_15=this._round(_15/o.stepping.y)*o.stepping.y;
_14.top=this._translateValue(_15,"y");
}
_14.left=this._translateRange(_14.left,"x");
_14.top=this._translateRange(_14.top,"y");
if(o.axis!="vertical"){
this.currentHandle.css({left:_14.left});
}
if(o.axis!="horizontal"){
this.currentHandle.css({top:_14.top});
}
this.currentHandle.data("mouse").sliderValue={x:this._round(this._convertValue(_14.left,"x"))||0,y:this._round(this._convertValue(_14.top,"y"))||0};
if(this.rangeElement){
this._updateRange();
}
this._propagate("slide",_12);
return false;
},_stop:function(_16){
this._propagate("stop",_16);
if(this.firstValue!=this.value()){
this._propagate("change",_16);
}
this._focus(this.currentHandle,true);
return false;
},_round:function(_17){
return this.options.round?parseInt(_17,10):parseFloat(_17);
},_setData:function(key,_18){
$.widget.prototype._setData.apply(this,arguments);
if(/min|max|steps/.test(key)){
this._initBoundaries();
}
if(key=="range"){
_18?this.handle.length==2&&this._createRange():this._removeRange();
}
},_initBoundaries:function(){
var _19=this.element[0],o=this.options;
this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};
$.extend(o,{axis:o.axis||(_19.offsetWidth<_19.offsetHeight?"vertical":"horizontal"),max:!isNaN(parseInt(o.max,10))?{x:parseInt(o.max,10),y:parseInt(o.max,10)}:({x:o.max&&o.max.x||100,y:o.max&&o.max.y||100}),min:!isNaN(parseInt(o.min,10))?{x:parseInt(o.min,10),y:parseInt(o.min,10)}:({x:o.min&&o.min.x||0,y:o.min&&o.min.y||0})});
o.realMax={x:o.max.x-o.min.x,y:o.max.y-o.min.y};
o.stepping={x:o.stepping&&o.stepping.x||parseInt(o.stepping,10)||(o.steps?o.realMax.x/(o.steps.x||parseInt(o.steps,10)||o.realMax.x):0),y:o.stepping&&o.stepping.y||parseInt(o.stepping,10)||(o.steps?o.realMax.y/(o.steps.y||parseInt(o.steps,10)||o.realMax.y):0)};
},_keydown:function(_1a,_1b){
if(this.options.disabled){
return;
}
var k=_1a;
if(/(33|34|35|36|37|38|39|40)/.test(k)){
var o=this.options,_1c,_1d;
if(/(35|36)/.test(k)){
_1c=(k==35)?o.max.x:o.min.x;
_1d=(k==35)?o.max.y:o.min.y;
}else{
var _1e=/(34|37|40)/.test(k)?"-=":"+=";
var _1f=/(37|38|39|40)/.test(k)?"_oneStep":"_pageStep";
_1c=_1e+this[_1f]("x");
_1d=_1e+this[_1f]("y");
}
this.moveTo({x:_1c,y:_1d},_1b);
return false;
}
return true;
},_focus:function(_20,_21){
this.currentHandle=$(_20).addClass("ui-slider-handle-active");
if(_21){
this.currentHandle.parent()[0].focus();
}
},_blur:function(_22){
$(_22).removeClass("ui-slider-handle-active");
if(this.currentHandle&&this.currentHandle[0]==_22){
this.previousHandle=this.currentHandle;
this.currentHandle=null;
}
},_click:function(_23){
var _24=[_23.pageX,_23.pageY];
var _25=false;
this.handle.each(function(){
if(this==_23.target){
_25=true;
}
});
if(_25||this.options.disabled||!(this.currentHandle||this.previousHandle)){
return;
}
if(!this.currentHandle&&this.previousHandle){
this._focus(this.previousHandle,true);
}
this.offset=this.element.offset();
this.moveTo({y:this._convertValue(_23.pageY-this.offset.top-this.currentHandle[0].offsetHeight/2,"y"),x:this._convertValue(_23.pageX-this.offset.left-this.currentHandle[0].offsetWidth/2,"x")},null,!this.options.distance);
},_createRange:function(){
if(this.rangeElement){
return;
}
this.rangeElement=$("<div></div>").addClass("ui-slider-range").css({position:"absolute"}).appendTo(this.element);
this._updateRange();
},_removeRange:function(){
this.rangeElement.remove();
this.rangeElement=null;
},_updateRange:function(){
var _26=this.options.axis=="vertical"?"top":"left";
var _27=this.options.axis=="vertical"?"height":"width";
this.rangeElement.css(_26,(this._round($(this.handle[0]).css(_26))||0)+this._handleSize(0,this.options.axis=="vertical"?"y":"x")/2);
this.rangeElement.css(_27,(this._round($(this.handle[1]).css(_26))||0)-(this._round($(this.handle[0]).css(_26))||0));
},_getRange:function(){
return this.rangeElement?this._convertValue(this._round(this.rangeElement.css(this.options.axis=="vertical"?"height":"width")),this.options.axis=="vertical"?"y":"x"):null;
},_handleIndex:function(){
return this.handle.index(this.currentHandle[0]);
},value:function(_28,_29){
if(this.handle.length==1){
this.currentHandle=this.handle;
}
if(!_29){
_29=this.options.axis=="vertical"?"y":"x";
}
var _2a=$(_28!=undefined&&_28!==null?this.handle[_28]||_28:this.currentHandle);
if(_2a.data("mouse").sliderValue){
return this._round(_2a.data("mouse").sliderValue[_29]);
}else{
return this._round(((this._round(_2a.css(_29=="x"?"left":"top"))/(this.actualSize[_29=="x"?"width":"height"]-this._handleSize(_28,_29)))*this.options.realMax[_29])+this.options.min[_29]);
}
},_convertValue:function(_2b,_2c){
return this.options.min[_2c]+(_2b/(this.actualSize[_2c=="x"?"width":"height"]-this._handleSize(null,_2c)))*this.options.realMax[_2c];
},_translateValue:function(_2d,_2e){
return ((_2d-this.options.min[_2e])/this.options.realMax[_2e])*(this.actualSize[_2e=="x"?"width":"height"]-this._handleSize(null,_2e));
},_translateRange:function(_2f,_30){
if(this.rangeElement){
if(this.currentHandle[0]==this.handle[0]&&_2f>=this._translateValue(this.value(1),_30)){
_2f=this._translateValue(this.value(1,_30)-this._oneStep(_30),_30);
}
if(this.currentHandle[0]==this.handle[1]&&_2f<=this._translateValue(this.value(0),_30)){
_2f=this._translateValue(this.value(0,_30)+this._oneStep(_30),_30);
}
}
if(this.options.handles){
var _31=this.options.handles[this._handleIndex()];
if(_2f<this._translateValue(_31.min,_30)){
_2f=this._translateValue(_31.min,_30);
}else{
if(_2f>this._translateValue(_31.max,_30)){
_2f=this._translateValue(_31.max,_30);
}
}
}
return _2f;
},_translateLimits:function(_32,_33){
if(_32>=this.actualSize[_33=="x"?"width":"height"]-this._handleSize(null,_33)){
_32=this.actualSize[_33=="x"?"width":"height"]-this._handleSize(null,_33);
}
if(_32<=0){
_32=0;
}
return _32;
},_handleSize:function(_34,_35){
return $(_34!=undefined&&_34!==null?this.handle[_34]:this.currentHandle)[0]["offset"+(_35=="x"?"Width":"Height")];
},_oneStep:function(_36){
return this.options.stepping[_36]||1;
},_pageStep:function(_37){
return 10;
},moveTo:function(_38,_39,_3a){
var o=this.options;
this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};
if(_39==undefined&&!this.currentHandle&&this.handle.length!=1){
return false;
}
if(_39==undefined&&!this.currentHandle){
_39=0;
}
if(_39!=undefined){
this.currentHandle=this.previousHandle=$(this.handle[_39]||_39);
}
if(_38.x!==undefined&&_38.y!==undefined){
var x=_38.x,y=_38.y;
}else{
var x=_38,y=_38;
}
if(x!==undefined&&x.constructor!=Number){
var me=/^\-\=/.test(x),pe=/^\+\=/.test(x);
if(me||pe){
x=this.value(null,"x")+this._round(x.replace(me?"=":"+=",""));
}else{
x=isNaN(this._round(x))?undefined:this._round(x);
}
}
if(y!==undefined&&y.constructor!=Number){
var me=/^\-\=/.test(y),pe=/^\+\=/.test(y);
if(me||pe){
y=this.value(null,"y")+this._round(y.replace(me?"=":"+=",""));
}else{
y=isNaN(this._round(y))?undefined:this._round(y);
}
}
if(o.axis!="vertical"&&x!==undefined){
if(o.stepping.x){
x=this._round(x/o.stepping.x)*o.stepping.x;
}
x=this._translateValue(x,"x");
x=this._translateLimits(x,"x");
x=this._translateRange(x,"x");
o.animate?this.currentHandle.stop().animate({left:x},(Math.abs(parseInt(this.currentHandle.css("left"),10)-x))*(!isNaN(parseInt(o.animate,10))?o.animate:5)):this.currentHandle.css({left:x});
}
if(o.axis!="horizontal"&&y!==undefined){
if(o.stepping.y){
y=this._round(y/o.stepping.y)*o.stepping.y;
}
y=this._translateValue(y,"y");
y=this._translateLimits(y,"y");
y=this._translateRange(y,"y");
o.animate?this.currentHandle.stop().animate({top:y},(Math.abs(parseInt(this.currentHandle.css("top"),10)-y))*(!isNaN(parseInt(o.animate,10))?o.animate:5)):this.currentHandle.css({top:y});
}
if(this.rangeElement){
this._updateRange();
}
this.currentHandle.data("mouse").sliderValue={x:this._round(this._convertValue(x,"x"))||0,y:this._round(this._convertValue(y,"y"))||0};
if(!_3a){
this._propagate("start",null);
this._propagate("slide",null);
this._propagate("stop",null);
this._propagate("change",null);
}
},_propagate:function(n,_3b){
$.ui.plugin.call(this,n,[_3b,this.ui()]);
this.element.triggerHandler(n=="slide"?n:"slide"+n,[_3b,this.ui()],this.options[n]);
},plugins:{},ui:function(_3c){
return {options:this.options,handle:this.currentHandle,value:this.options.axis!="both"||!this.options.axis?this._round(this.value(null,this.options.axis=="vertical"?"y":"x")):{x:this._round(this.value(null,"x")),y:this._round(this.value(null,"y"))},range:this._getRange()};
}});
$.extend($.ui.slider,{getter:"value",version:"1.6",defaults:{animate:false,distance:1,handle:".ui-slider-handle",round:true}});
})(jQuery);

