0byt3m1n1
Path:
/
data
/
applications
/
aps
/
gallery
/
2.2-08
/
htdocs
/
lib
/
yui
/
[
Home
]
File: slider-min.js
/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.11.0 */ YAHOO.widget.Slider=function(_1,_2,_3,_4){if(_1){this.type=_4;this.init(_1,_2,true);var _5=this;this.thumb=_3;_3.onChange=function(){_5.onThumbChange();};this.isTarget=false;this.animate=YAHOO.widget.Slider.ANIM_AVAIL;this.backgroundEnabled=true;this.tickPause=40;if(_3._isHoriz&&_3.xTicks&&_3.xTicks.length){this.tickPause=Math.round(360/_3.xTicks.length);}else{if(_3.yTicks&&_3.yTicks.length){this.tickPause=Math.round(360/_3.yTicks.length);}}_3.onMouseDown=function(){return _5.focus();};_3.onMouseUp=function(){_5.thumbMouseUp();};_3.onDrag=function(){_5.fireEvents();};_3.onAvailable=function(){return _5.setStartSliderState();};}};YAHOO.extend(YAHOO.widget.Slider,YAHOO.util.DragDrop);YAHOO.widget.Slider.getHorizSlider=function(_6,_7,_8,_9,_10){return new YAHOO.widget.Slider(_6,_6,new YAHOO.widget.SliderThumb(_7,_6,_8,_9,0,0,_10),"horiz");};YAHOO.widget.Slider.getVertSlider=function(_11,_12,iUp,_14,_15){return new YAHOO.widget.Slider(_11,_11,new YAHOO.widget.SliderThumb(_12,_11,0,0,iUp,_14,_15),"vert");};YAHOO.widget.Slider.getSliderRegion=function(_16,_17,_18,_19,iUp,_20,_21){return new YAHOO.widget.Slider(_16,_16,new YAHOO.widget.SliderThumb(_17,_16,_18,_19,iUp,_20,_21),"region");};YAHOO.widget.Slider.ANIM_AVAIL=true;YAHOO.widget.Slider.prototype.setStartSliderState=function(){this.setThumbCenterPoint();this.baselinePos=YAHOO.util.Dom.getXY(this.getEl());this.thumb.startOffset=this.thumb.getOffsetFromParent(this.baselinePos);if(this.thumb._isRegion){if(this.deferredSetRegionValue){this.setRegionValue.apply(this,this.deferredSetRegionValue,true);}else{this.setRegionValue(0,0,true);}}else{if(this.deferredSetValue){this.setValue.apply(this,this.deferredSetValue,true);}else{this.setValue(0,true,true);}}};YAHOO.widget.Slider.prototype.setThumbCenterPoint=function(){var el=this.thumb.getEl();if(el){this.thumbCenterPoint={x:parseInt(el.offsetWidth/2,10),y:parseInt(el.offsetHeight/2,10)};}};YAHOO.widget.Slider.prototype.lock=function(){this.thumb.lock();this.locked=true;};YAHOO.widget.Slider.prototype.unlock=function(){this.thumb.unlock();this.locked=false;};YAHOO.widget.Slider.prototype.thumbMouseUp=function(){if(!this.isLocked()&&!this.moveComplete){this.endMove();}};YAHOO.widget.Slider.prototype.getThumb=function(){return this.thumb;};YAHOO.widget.Slider.prototype.focus=function(){var el=this.getEl();if(el.focus){el.focus();}this.verifyOffset();if(this.isLocked()){return false;}else{this.onSlideStart();return true;}};YAHOO.widget.Slider.prototype.onChange=function(_23,_24){};YAHOO.widget.Slider.prototype.onSlideStart=function(){};YAHOO.widget.Slider.prototype.onSlideEnd=function(){};YAHOO.widget.Slider.prototype.getValue=function(){return this.thumb.getValue();};YAHOO.widget.Slider.prototype.getXValue=function(){return this.thumb.getXValue();};YAHOO.widget.Slider.prototype.getYValue=function(){return this.thumb.getYValue();};YAHOO.widget.Slider.prototype.onThumbChange=function(){var t=this.thumb;if(t._isRegion){t.onChange(t.getXValue(),t.getYValue());}else{t.onChange(t.getValue());}};YAHOO.widget.Slider.prototype.setValue=function(_26,_27,_28){if(!this.thumb.available){this.deferredSetValue=arguments;return false;}if(this.isLocked()&&!_28){return false;}if(isNaN(_26)){return false;}var t=this.thumb;var _29,newY;this.verifyOffset();if(t._isRegion){return false;}else{if(t._isHoriz){this.onSlideStart();_29=t.initPageX+_26+this.thumbCenterPoint.x;this.moveThumb(_29,t.initPageY,_27);}else{this.onSlideStart();newY=t.initPageY+_26+this.thumbCenterPoint.y;this.moveThumb(t.initPageX,newY,_27);}}return true;};YAHOO.widget.Slider.prototype.setRegionValue=function(_30,_31,_32){if(!this.thumb.available){this.deferredSetRegionValue=arguments;return false;}if(this.isLocked()&&!force){return false;}if(isNaN(_30)){return false;}var t=this.thumb;if(t._isRegion){this.onSlideStart();var _33=t.initPageX+_30+this.thumbCenterPoint.x;var _34=t.initPageY+_31+this.thumbCenterPoint.y;this.moveThumb(_33,_34,_32);return true;}return false;};YAHOO.widget.Slider.prototype.verifyOffset=function(){var _35=YAHOO.util.Dom.getXY(this.getEl());if(_35[0]!=this.baselinePos[0]||_35[1]!=this.baselinePos[1]){this.thumb.resetConstraints();this.baselinePos=_35;return false;}return true;};YAHOO.widget.Slider.prototype.moveThumb=function(x,y,_38){var t=this.thumb;var _39=this;if(!t.available){return;}t.setDelta(this.thumbCenterPoint.x,this.thumbCenterPoint.y);var _p=t.getTargetCoord(x,y);var p=[_p.x,_p.y];if(this.animate&&YAHOO.widget.Slider.ANIM_AVAIL&&t._graduated&&!_38){this.lock();setTimeout(function(){_39.moveOneTick(p);},this.tickPause);}else{if(this.animate&&YAHOO.widget.Slider.ANIM_AVAIL&&!_38){this.lock();var _42=new YAHOO.util.Motion(t.id,{points:{to:p}},0.4,YAHOO.util.Easing.easeOut);_42.onComplete.subscribe(function(){_39.endMove();});_42.animate();}else{t.setDragElPos(x,y);this.endMove();}}};YAHOO.widget.Slider.prototype.moveOneTick=function(_43){var t=this.thumb;var _44=YAHOO.util.Dom.getXY(t.getEl());var tmp;var _46=null;if(t._isRegion){_46=this._getNextX(_44,_43);var _47=(_46)?_46[0]:_44[0];_46=this._getNextY([_47,_44[1]],_43);}else{if(t._isHoriz){_46=this._getNextX(_44,_43);}else{_46=this._getNextY(_44,_43);}}if(_46){this.thumb.alignElWithMouse(t.getEl(),_46[0],_46[1]);if(!(_46[0]==_43[0]&&_46[1]==_43[1])){var _48=this;setTimeout(function(){_48.moveOneTick(_43);},this.tickPause);}else{this.endMove();}}else{this.endMove();}};YAHOO.widget.Slider.prototype._getNextX=function(_49,_50){var t=this.thumb;var _51;var tmp=[];var _52=null;if(_49[0]>_50[0]){_51=t.tickSize-this.thumbCenterPoint.x;tmp=t.getTargetCoord(_49[0]-_51,_49[1]);_52=[tmp.x,tmp.y];}else{if(_49[0]<_50[0]){_51=t.tickSize+this.thumbCenterPoint.x;tmp=t.getTargetCoord(_49[0]+_51,_49[1]);_52=[tmp.x,tmp.y];}else{}}return _52;};YAHOO.widget.Slider.prototype._getNextY=function(_53,_54){var t=this.thumb;var _55;var tmp=[];var _56=null;if(_53[1]>_54[1]){_55=t.tickSize-this.thumbCenterPoint.y;tmp=t.getTargetCoord(_53[0],_53[1]-_55);_56=[tmp.x,tmp.y];}else{if(_53[1]<_54[1]){_55=t.tickSize+this.thumbCenterPoint.y;tmp=t.getTargetCoord(_53[0],_53[1]+_55);_56=[tmp.x,tmp.y];}else{}}return _56;};YAHOO.widget.Slider.prototype.b4MouseDown=function(e){this.thumb.autoOffset();this.thumb.resetConstraints();};YAHOO.widget.Slider.prototype.onMouseDown=function(e){if(!this.isLocked()&&this.backgroundEnabled){var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.focus();this.moveThumb(x,y);}};YAHOO.widget.Slider.prototype.onDrag=function(e){if(!this.isLocked()){var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.moveThumb(x,y,true);}};YAHOO.widget.Slider.prototype.endMove=function(){this.unlock();this.moveComplete=true;this.fireEvents();};YAHOO.widget.Slider.prototype.fireEvents=function(){var t=this.thumb;t.cachePosition();if(!this.isLocked()){if(t._isRegion){var _58=t.getXValue();var _59=t.getYValue();if(_58!=this.previousX||_59!=this.previousY){this.onChange(_58,_59);}this.previousX=_58;this.previousY=_59;}else{var _60=t.getValue();if(_60!=this.previousVal){this.onChange(_60);}this.previousVal=_60;}if(this.moveComplete){this.onSlideEnd();this.moveComplete=false;}}};YAHOO.widget.Slider.prototype.toString=function(){return ("Slider ("+this.type+") "+this.id);};YAHOO.widget.SliderThumb=function(id,_62,_63,_64,iUp,_65,_66){if(id){this.init(id,_62);this.parentElId=_62;}this.isTarget=false;this.tickSize=_66;this.maintainOffset=true;this.initSlider(_63,_64,iUp,_65,_66);this.scroll=false;};YAHOO.extend(YAHOO.widget.SliderThumb,YAHOO.util.DD);YAHOO.widget.SliderThumb.prototype.getOffsetFromParent=function(_67){var _68=YAHOO.util.Dom.getXY(this.getEl());var _69=_67||YAHOO.util.Dom.getXY(this.parentElId);return [(_68[0]-_69[0]),(_68[1]-_69[1])];};YAHOO.widget.SliderThumb.prototype.startOffset=null;YAHOO.widget.SliderThumb.prototype._isHoriz=false;YAHOO.widget.SliderThumb.prototype._prevVal=0;YAHOO.widget.SliderThumb.prototype._graduated=false;YAHOO.widget.SliderThumb.prototype.initSlider=function(_70,_71,iUp,_72,_73){this.setXConstraint(_70,_71,_73);this.setYConstraint(iUp,_72,_73);if(_73&&_73>1){this._graduated=true;}this._isHoriz=(_70>0||_71>0);this._isVert=(iUp>0||_72>0);this._isRegion=(this._isHoriz&&this._isVert);};YAHOO.widget.SliderThumb.prototype.clearTicks=function(){YAHOO.widget.SliderThumb.superclass.clearTicks.call(this);this._graduated=false;};YAHOO.widget.SliderThumb.prototype.getValue=function(){if(!this.available){return 0;}var val=(this._isHoriz)?this.getXValue():this.getYValue();return val;};YAHOO.widget.SliderThumb.prototype.getXValue=function(){if(!this.available){return 0;}var _75=this.getOffsetFromParent();return (_75[0]-this.startOffset[0]);};YAHOO.widget.SliderThumb.prototype.getYValue=function(){if(!this.available){return 0;}var _76=this.getOffsetFromParent();return (_76[1]-this.startOffset[1]);};YAHOO.widget.SliderThumb.prototype.toString=function(){return "SliderThumb "+this.id;};YAHOO.widget.SliderThumb.prototype.onChange=function(x,y){};if("undefined"==typeof YAHOO.util.Anim){YAHOO.widget.Slider.ANIM_AVAIL=false;}