scrollview-scrollbars-min.js revision 32d32b83f2e174763a26d56665e5df697fc174e2
YUI.add("scrollview-scrollbars",function(C){var B=C.ScrollView.CLASS_NAMES,A=C.TransitionNative.supported;function D(){D.superclass.constructor.apply(this,arguments);}D.NAME="scrollbars-plugin";D.NS="scrollbars";D.SCROLLBAR_TEMPLATE=["<div>",'<span class="'+B.child+" "+B.top+'"></span>','<span class="'+B.child+" "+B.middle+'"></span>','<span class="'+B.child+" "+B.bottom+'"></span>',"</div>"].join("");D.ATTRS={verticalNode:{setter:"_setVerticalNode",value:C.Node.create(D.SCROLLBAR_TEMPLATE)},horizontalNode:{setter:"_setHorizontalNode",value:C.Node.create(D.SCROLLBAR_TEMPLATE)}};C.namespace("Plugin").ScrollViewScrollbars=C.extend(D,C.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 I=this._host,G=I.get("boundingBox"),F=this.get("verticalNode"),J=this.get("horizontalNode"),H=F.inDoc(),E=J.inDoc();if(I._scrollsVertical&&!H){G.append(F);}else{if(!I._scrollsVertical&&H){F.remove();}}if(I._scrollsHorizontal&&!E){G.append(J);}else{if(!I._scrollsHorizontal&&E){J.remove();}}this._update();C.later(500,this,"flash",true);},_update:function(V,E,N){var K=this._host,M=K.get("contentBox"),G=0,S=1,J,X,W,U,L=K.get("height"),O=K.get("width"),T=K._scrollHeight||M.get("scrollHeight"),I=K._scrollWidth||M.get("scrollWidth"),F=this.get("verticalNode"),H=this.get("horizontalNode"),R=K.get("scrollX")*-1,Q=K.get("scrollY")*-1,P;if(!this._showingScrollBars){this.show();}if(H&&T<=L){this.hide();return;}if(F){G=Math.floor(L*(L/T));S=Math.floor((Q/(T-L))*(L-G))*-1;if(G>L){G=1;}if(A){J="translate(0, "+S+"px)";}else{X=0;W=S;}if(S>(L-G)){G=G-(S-(L-G));}if(S<0){if(A){J="translate(0,0)";}else{X=0;W=0;}G=G+S;}E=E||0;if(this.verticalScrollSize!=(G-8)){this.verticalScrollSize=(G-8);P=F.get("children").item(1);U={duration:E/1000};if(A){U.transform="translate(0,0) scaleY("+(G-8)+")";}else{U.top=4;U.right=0;U.height=(G-8);}P.transition(U);}U={duration:E/1000};if(A){U.transform=J;}else{U.right=X;U.top=W;}F.transition(U);U={duration:E/1000};if(A){U.transform="translate(0,"+(G-10)+"px)";}else{U.right=0;U.top=G-4;}F.get("children").item(2).transition(U);}if(H){G=Math.floor(O*(O/I));S=Math.floor((R/(I-O))*(O-G))*-1;if(G>O){G=1;}if(A){J="translate("+S+"px, 0)";}else{X=S;W=0;}if(S>(O-G)){G=G-(S-(O-G));}if(S<0){if(A){J="translate(0,0)";}else{X=0;W=0;}G=G+S;}E=E||0;if(this.horizontalScrollSize!=(G-16)){this.horizontalScrollSize=(G-16);P=H.get("children").item(1);U={duration:E/1000};if(A){U.transform="translate(0,0) scaleX("+(G-16)+")";}else{U.bottom=0;U.left=4;U.width=(G-16);}P.transition(U);}U={duration:E/1000};if(A){U.transform=J;}else{U.bottom=W;U.left=X;}H.transition(U);U={duration:E/1000};if(A){U.transform="translate("+(G-12)+"px,0)";}else{U.bottom=0;U.left=G-12;}H.get("children").item(2).transition(U);}},show:function(E){this._show(true,E);},hide:function(E){this._show(false,E);},_show:function(E,G){var F=this.get("verticalNode"),H=this.get("horizontalNode"),I={duration:(G)?0.6:0,opacity:(E)?1:0};this._showingScrollBars=E;if(this._flashTimer){this._flashTimer.cancel();}if(F){F.transition(I);}if(H){H.transition(I);}},flash:function(){var E=false,F=this._host;if(F._scrollsVertical&&(F._scrollHeight>F.get("height"))){E=true;}if(F._scrollsHorizontal&&(F._scrollWidth>this.get("host").get("width"))){E=true;}if(E){this.show(true);this._flashTimer=C.later(800,this,"hide",true);}},_setVerticalNode:function(E){E=C.one(E);if(E){E.addClass(B.scrollbar);E.addClass(B.vertical);}return E;},_setHorizontalNode:function(E){E=C.one(E);if(E){E.addClass(B.scrollbar);E.addClass(B.horizontal);}return E;}});},"@VERSION@",{skinnable:true,requires:["plugin"]});