int-value-range-min.js revision b254fc4c7a1279a919a5b56b2c07136ff8a00d1e
YUI.add("int-value-range",function(F){var A="min",E="max",D="value",B=Math.round;function C(){this._initIntValueRange();}F.IntValueRange=F.mix(C,{prototype:{_offsetXY:null,_factor:1,_initIntValueRange:function(){this._key=this._key||{};F.mix(this._key,(this.axis==="y")?{minEdge:"top",maxEdge:"bottom",xyIndex:1}:{minEdge:"left",maxEdge:"right",xyIndex:0});},_bindValueLogic:function(){this.after({minChange:this._afterMinChange,maxChange:this._afterMaxChange,valueChange:this._afterValueChange});},_syncThumbPosition:function(){this._cacheRailOffset();this._calculateFactor();this._setPosition(this.get(D));},_cacheRailOffset:function(){var G=this._dd.con.getRegion();this._offsetXY=G[this._key.minEdge];},_calculateFactor:function(){var G=this._dd.con.getRegion(true);this._factor=(this.get(E)-this.get(A))/(G[this._key.maxEdge]-G[this._key.minEdge]);},_defThumbMoveFn:function(J){var H=this.get(D),G=this._dd.actXY[this._key.xyIndex],I=this._offsetToValue(G);if(H!==I){this.set(D,I,{ddEvent:J.ddEvent});}},_offsetToValue:function(H){H-=this._offsetXY;var G=B(H*this._factor)+this.get(A);return this._nearestValue(G);},_valueToOffset:function(G){G-=this.get(A);return B(G/this._factor)+this._offsetXY;},_afterMinChange:function(G){this._verifyValue();this._syncThumbPosition();},_afterMaxChange:function(G){this._verifyValue();this._syncThumbPosition();},_verifyValue:function(){var H=this.get(D),G=this._nearestValue(H);if(H!==G){this.set(D,G);}},_afterValueChange:function(G){if(!G.ddEvent){this._setPosition(G.newVal);}},_setPosition:function(H){var G=this._dd;if(!G.deltaXY){G.actXY=G.get("dragNode").getXY();G._setStartPosition(G.actXY);}G.actXY[this._key.xyIndex]=this._valueToOffset(H);G._moveNode();},_validateNewMin:function(G){return F.Lang.isNumber(G);},_validateNewMax:function(G){return F.Lang.isNumber(G);},_validateNewValue:function(G){return(G===this._nearestValue(G));},_nearestValue:function(J){var I=this.get(A),G=this.get(E),H;H=(G>I)?G:I;I=(G>I)?I:G;G=H;return(J<I)?I:(J>G)?G:J;}},ATTRS:{min:{value:0,validator:"_validateNewMin"},max:{value:100,validator:"_validateNewMax"},value:{value:0,validator:"_validateNewValue"}}},true);},"@VERSION@",{requires:["base-build","node-base"]});