(function(){zul.inp.Slider=zk.$extends(zul.Widget,{_orient:"horizontal",_curpos:0,_minpos:0,_maxpos:100,_slidingtext:"{0}",_pageIncrement:-1,_step:-1,_mode:"integer",$define:{orient:function(){this.rerender()},curpos:function(){this.desktop&&this._fixPos()},minpos:function(a){this._curpos<a&&(this._curpos=a);this._fixStep();this.desktop&&this._fixPos()},maxpos:function(a){this._curpos>a&&(this._curpos=a);this._fixStep();this.desktop&&this._fixPos()},slidingtext:null,pageIncrement:null,step:function(){this._fixStep()},
name:function(){this.efield&&(this.efield.name=this._name)},mode:function(){this._fixStep();this.desktop&&this._fixPos()}},setWidth:function(a){this.$supers("setWidth",arguments);if(this.desktop&&"knob"!=this._mold)this.onSize()},setHeight:function(a){this.$supers("setHeight",arguments);if(this.desktop&&"knob"!=this._mold)this.onSize()},domClass_:function(){var a=this.$supers("domClass_",arguments);if("knob"==this._mold)return a;var b=this.isVertical();a=b?a+(" "+this.$s("vertical")):a+(" "+this.$s("horizontal"));
this.inSphereMold()?a+=" "+this.$s("sphere"):this.inScaleMold()&&!b&&(a+=" "+this.$s("scale"));return a},onup_:function(a){a=zul.inp.Slider.down_btn;var b;a&&(b=zk.Widget.$(a));zul.inp.Slider.down_btn=null;b&&jq(document).unbind("zmouseup",b.onup_)},doMouseDown_:function(a){"knob"!=this._mold&&(jq(document).bind("zmouseup",this.onup_),zul.inp.Slider.down_btn=this.$n("btn"));this.$supers("doMouseDown_",arguments)},doClick_:function(a){if("knob"==this._mold)this.$supers("doClick_",arguments);else{var b=
jq(this.$n("btn")),c=b.zk.revisedOffset(),d=this,e=this._pageIncrement,f=0>e&&0>this.$class._getStep(this),h=this.isVertical(),k=this._getHeight(),l=this._getWidth(),g=h?a.pageY-c[1]:a.pageX-c[0];if(b[0]&&!b.is(":animated")){f||(this._curpos=0<e?this.$class._roundDecimal(this._constraintPos(this._curpos+(0<g?e:-e)),this.$class._digitsAfterDecimal(e)):this._getSteppedPos(g/(h?k:l)*(this._maxpos-this._minpos)+this._curpos),g=null);if(null!=g){e=this.$n();e=h?e.clientHeight:e.clientWidth;var n=e/(this._maxpos-
this._minpos),m=Math.floor(Math.abs(g/n));1>m&&(m=1);g=e?m*n*(0<=g?1:-1):0}g=this.$class._getNextPos(this,g);e=b.zk.getAnimationSpeed("slow");h&&zk.parseInt(g.top)>k&&(g.top=jq.px0(k));!h&&zk.parseInt(g.left)>l&&(g.left=jq.px0(l));b.animate(g,e,function(){c=f?d._realpos():d._curpos;c=d._constraintPos(c);d.fire("onScroll",d.isDecimal()?{decimal:c}:c)});jq(this.$n("area")).animate(h?{height:g.top}:{width:g.left},e);this.$supers("doClick_",arguments)}}},_makeDraggable:function(){var a={constraint:this._orient||
"horizontal",starteffect:this._startDrag,snap:a,change:this._dragging,endeffect:this._endDrag};0<this.$class._getStep(this)&&(a.snap=this._getStepOffset());this._drag=new zk.Draggable(this,this.$n("btn"),a)},_snap:function(a,b){var c=this.$n("btn");var d=zk(this.$n()).cmOffset();d=zk(c).toStyleOffset(d[0],d[1]);a<=d[0]?a=d[0]:(c=d[0]+this._getWidth(),a>c&&(a=c));b<=d[1]?b=d[1]:(c=d[1]+this._getHeight(),b>c&&(b=c));return[a,b]},_startDrag:function(a){a=a.control;var b=a.getSclass();a.$n("btn").title=
"";a.slidepos=a._curpos;vert=a.isVertical();jq(document.body).append('<div id="zul_slidetip" class="'+a.$s("popup")+(b?" "+b+'">':'">')+a._slidingtext.replace(/\{0\}/g,a.slidepos)+"</div>");a.slidetip=jq("#zul_slidetip")[0];a.slidetip&&(a=a.slidetip.style,zk.webkit&&(a.top="0px",a.left="0px"))},_dragging:function(a){a=a.control;var b=a.isDecimal(),c=a._realpos();if(c!=a.slidepos){a.slidepos=c=a._constraintPos(c);var d=b?c.toFixed(a.$class._digitsAfterDecimal(a.$class._getStep(a))):c;a.slidetip&&(a.slidetip.innerHTML=
a._slidingtext.replace(/\{0\}/g,d));a.fire("onScrolling",b?{decimal:c}:c)}a._fixPos()},_endDrag:function(a){a=a.control;var b=a._constraintPos(a._realpos());a.fire("onScroll",a.isDecimal()?{decimal:b}:b);a._fixPos();jq(a.slidetip).remove();a.slidetip=null},_realpos:function(a){var b=zk(this.$n("btn")).revisedOffset(),c=zk(this.$n()).revisedOffset(),d=this._maxpos;a=this._minpos;var e=this.$class._getStep(this);if(this.isVertical()){var f=this._getHeight();b=f?(b[1]-c[1])*(d-a)/f:0}else b=(f=this._getWidth())?
(b[0]-c[0])*(d-a)/f:0;this.isDecimal()||(b=Math.round(b));return 0<e?this._curpos=0<b?this.$class._roundDecimal(b+a,this.$class._digitsAfterDecimal(e)):a:this._curpos=(0<b?b:0)+a},_constraintPos:function(a){var b=this.$class._getStep(this),c=this._maxpos;return a=a<c?a-(a-this._minpos)%b:c},_getSteppedPos:function(a){var b=this._minpos,c=this.$class._getStep(this),d=1;a-=b;this.isDecimal()&&(d=Math.pow(10,this.$class._digitsAfterDecimal(c)),a*=d,c*=d);var e=a%c;return(a-e+Math.round(e/c)*c)/d+b},
_getWidth:function(){return this.$n().clientWidth-this.$n("btn").offsetWidth},_getHeight:function(){return this.$n().clientHeight-this.$n("btn").offsetHeight},_getStepOffset:function(){var a=this.isVertical()?this._getHeight():this._getWidth(),b=this.$class._getStep(this),c=[0,0];b&&(c[this.isVertical()?1:0]=0<a?a*b/(this._maxpos-this._minpos):0);return c},_fixSize:function(){var a=this.$n(),b=this.$n("btn"),c=this.$n("inner").style;this.isVertical()?(b.style.top="-"+b.offsetHeight/2+"px",a=a.clientHeight,
c.height=jq.px0(0<a?a:this._height-b.offsetHeight)):(b.style.left="-"+b.offsetWidth/2+"px",a=a.clientWidth,c.width=jq.px0(0<a?a:this._width-b.offsetWidth))},_fixPos:function(){var a=this.$n("btn"),b=this.isVertical(),c=jq.px0(this.$class._getBtnNewPos(this));this.$n("area").style[b?"height":"width"]=c;a.style[b?"top":"left"]=c;this.slidetip&&zk(this.slidetip).position(a,b?"end_before":"before_start")},_fixStep:function(){var a=this.$class._getStep(this);this._drag&&(0>=a?this._drag.opts.snap&&delete this._drag.opts.snap:
this._drag.opts.snap=this._getStepOffset())},onSize:function(){this._fixSize();this._fixPos()},inScaleMold:function(){return"scale"==this.getMold()},inSphereMold:function(){return"sphere"==this.getMold()},isVertical:function(){return"vertical"==this._orient},isDecimal:function(){return"decimal"==this._mode},updateFormData:function(a){this._name&&(a=a||0,this.efield?this.efield.value=a:this.efield=jq.newHidden(this._name,a,this.$n()))},onShow:function(){this._drag||this._makeDraggable()},setFlexSize_:function(a,
b){this.$supers("setFlexSize_",arguments);if("knob"!=this._mold)this.onSize()},bind_:function(){this.$supers(zul.inp.Slider,"bind_",arguments);"knob"!=this._mold&&(this._fixSize(),this.isRealVisible()&&this._makeDraggable(),zWatch.listen({onSize:this,onShow:this}),this.updateFormData(this._curpos),this._fixPos())},unbind_:function(){"knob"!=this._mold&&(this.efield=null,this._drag&&(this._drag.destroy(),this._drag=null),zWatch.unlisten({onSize:this,onShow:this}));this.$supers(zul.inp.Slider,"unbind_",
arguments)}},{_digitsAfterDecimal:function(a){a=""+a;var b=a.indexOf(".");return 0>b?0:a.length-b-1},_roundDecimal:function(a,b){b=Math.pow(10,b);return Math.round(a*b)/b},_getBtnNewPos:function(a){var b=a.$n("btn"),c=a._curpos,d=a.isDecimal();b.title=d?c.toFixed(a.$class._digitsAfterDecimal(a.$class._getStep(a))):c;a.updateFormData(c);var e=a.isVertical(),f=zk(a.$n()).cmOffset(),h=e?a._getHeight():a._getWidth();c=0<h?(c-a._minpos)*h/(a._maxpos-a._minpos):0;d||(c=Math.round(c));f=zk(b).toStyleOffset(f[0],
f[1]);f=e?[0,f[1]+c]:[f[0]+c,0];f=a._snap(f[0],f[1]);return f[e?1:0]},_getNextPos:function(a,b){var c=jq(a.$n("btn")),d=a.isVertical()?["top","height"]:["left","width"],e={};e[d[0]]=jq.px0(b?b+zk.parseInt(c.css(d[0]))-c[d[1]]()/2:a.$class._getBtnNewPos(a));return e},_getStep:function(a){var b=a._step;return a.isDecimal()&&-1==b?.1:b}})})();
