scrollview-scrollbars-min.js revision cc438feb3ca2316f1b8ece51eed4ae6eabe5b61d
YUI.add("scrollview-scrollbars",function(F){var A=F.ClassNameManager.getClassName,D=F.Transition.useNative,C,B="scrollbar",E="scrollview";function G(){G.superclass.constructor.apply(this,arguments);}G.CLASS_NAMES={showing:A(E,B,"showing"),scrollbar:A(E,B),scrollbarV:A(E,B,"vert"),scrollbarH:A(E,B,"horiz"),scrollbarVB:A(E,B,"vert","basic"),scrollbarHB:A(E,B,"horiz","basic"),child:A(E,"child"),first:A(E,"first"),middle:A(E,"middle"),last:A(E,"last")};C=G.CLASS_NAMES;G.NAME="pluginScrollViewScrollbars";G.NS="scrollbars";G.SCROLLBAR_TEMPLATE=["<div>",'<span class="'+C.child+" "+C.first+'"></span>','<span class="'+C.child+" "+C.middle+'"></span>','<span class="'+C.child+" "+C.last+'"></span>',"</div>"].join("");G.ATTRS={verticalNode:{setter:"_setVerticalNode",value:F.Node.create(G.SCROLLBAR_TEMPLATE)},horizontalNode:{setter:"_setHorizontalNode",value:F.Node.create(G.SCROLLBAR_TEMPLATE)}};F.namespace("Plugin").ScrollViewScrollbars=F.extend(G,F.Plugin.Base,{initializer:function(){this._host=this.get("host");this.afterHostMethod("_uiScrollY",this._update);this.afterHostMethod("_uiScrollX",this._update);this.afterHostMethod("_uiDimensionsChange",this._hostDimensionsChange);this.doAfter("scrollEnd",this.flash);},_hostDimensionsChange:function(){var L=this._host,J=L.get("boundingBox"),I=this.get("verticalNode"),M=this.get("horizontalNode"),K=I.inDoc(),H=M.inDoc();if(L._scrollsVertical&&!K){J.append(I);if(this._basic){I.addClass(C.scrollbarVB);}}else{if(!L._scrollsVertical&&K){I.remove();}}if(L._scrollsHorizontal&&!H){J.append(M);if(this._basic){M.addClass(C.scrollbarHB);}}else{if(!L._scrollsHorizontal&&H){M.remove();}}this._update();F.later(500,this,"flash",true);},_update:function(a,H,S){var O=this._host,K=this._basic,R=O.get("contentBox"),J=0,X=1,N,c,b,Z,P,Q=O.get("height"),T=O.get("width"),Y=O._scrollHeight||R.get("scrollHeight"),M=O._scrollWidth||R.get("scrollWidth"),I=this.get("verticalNode"),L=this.get("horizontalNode"),W=O.get("scrollX")*-1,V=O.get("scrollY")*-1,U;if(!this._showingScrollBars){this.show();}if(L&&Y<=Q){this.hide();return;}if(I){J=Math.floor(Q*(Q/Y));X=Math.floor((V/(Y-Q))*(Q-J))*-1;if(J>Q){J=1;}if(D){N="translate(0, "+X+"px)";}else{c=0;b=X;}if(X>(Q-J)){J=J-(X-(Q-J));}if(X<0){if(D){N="translate(0,0)";}else{c=0;b=0;}J=J+X;}H=H||0;P=(J-8);if(this.verticalScrollSize!=(P)){this.verticalScrollSize=(P);U=I.get("children").item(1);Z={duration:H/1000};if(D){Z.transform="translate(0,0) scaleY("+(P)+")";}else{if(!K){Z.top=4;}Z.height=P;}U.transition(Z);}Z={duration:H/1000};if(D){Z.transform=N;}else{Z.top=b;}I.transition(Z);Z={duration:H/1000};if(D){Z.transform="translate(0,"+(J-10)+"px)";}else{if(!K){Z.top=J-4;}}I.get("children").item(2).transition(Z);}if(L){J=Math.floor(T*(T/M));X=Math.floor((W/(M-T))*(T-J))*-1;if(J>T){J=1;}if(D){N="translate("+X+"px, 0)";}else{c=X;b=0;}if(X>(T-J)){J=J-(X-(T-J));}if(X<0){if(D){N="translate(0,0)";}else{c=0;b=0;}J=J+X;}H=H||0;P=(J-16);if(this.horizontalScrollSize!=(P)){this.horizontalScrollSize=P;U=L.get("children").item(1);Z={duration:H/1000};if(D){Z.transform="translate(0,0) scaleX("+(P)+")";}else{if(!K){Z.left=4;}Z.width=(P);}U.transition(Z);}Z={duration:H/1000};if(D){Z.transform=N;}else{Z.left=c;}L.transition(Z);Z={duration:H/1000};if(D){Z.transform="translate("+(J-12)+"px,0)";}else{Z.left=J-12;}if(!K){L.get("children").item(2).transition(Z);}}},show:function(H){this._show(true,H);},hide:function(H){this._show(false,H);},_show:function(H,J){var I=this.get("verticalNode"),K=this.get("horizontalNode"),L={duration:(J)?0.6:0,opacity:(H)?1:0};this._showingScrollBars=H;if(this._flashTimer){this._flashTimer.cancel();}if(I){I.transition(L);}if(K){K.transition(L);}},flash:function(){var H=false,I=this._host;if(I._scrollsVertical&&(I._scrollHeight>I.get("height"))){H=true;}if(I._scrollsHorizontal&&(I._scrollWidth>this.get("host").get("width"))){H=true;}if(H){this.show(true);this._flashTimer=F.later(800,this,"hide",true);}},_setVerticalNode:function(H){H=F.one(H);if(H){H.addClass(C.scrollbar);H.addClass(C.scrollbarV);}return H;},_setHorizontalNode:function(H){H=F.one(H);if(H){H.addClass(C.scrollbar);H.addClass(C.scrollbarH);}return H;},_basic:F.UA.ie&&F.UA.ie<=8});},"@VERSION@",{skinnable:true,requires:["plugin"]});