scrollview-paginator-min.js revision 7dff9877fcd73e6db005c517f14a66bf2a9bf82e
YUI.add("scrollview-paginator",function(a){var b=(a.ScrollView)?a.ScrollView.UI_SRC:"ui",c="index",i="prevIndex",f="scrollX",e="scrollY",d="total",g="boundingBox",h="contentBox";function j(){j.superclass.constructor.apply(this,arguments);}j.NAME="pluginScrollViewPaginator";j.NS="pages";j.ATTRS={selector:{value:null},index:{value:0},prevIndex:{value:0},prevIndex:{value:0},total:{value:0}};a.extend(j,a.Plugin.Base,{initializer:function(){var k=this;k._host=this.get("host");k.beforeHostMethod("_flickFrame",k._flickFrame);k.afterHostMethod("_uiDimensionsChange",k._calcOffsets);k.afterHostEvent("scrollEnd",k._scrollEnded);k.afterHostEvent("render",k._afterRender);k.after("indexChange",k._afterIndexChange);},_calcOffsets:function(){var t=this._host,n=t.get(h),r=t.get(g),p=t._scrollsVertical,u=(p)?t._scrollHeight:t._scrollWidth,s=this.get("selector"),l,m;l=s?n.all(s):n.get("children");this.set(d,l.size());this._pageOffsets=l.get((p)?"offsetTop":"offsetLeft");var k=3;var q=this.get(c);this.set(i,q);this.slideNodes=l;n.empty(true);for(var o=0;o<k;o++){n.append(this.slideNodes.item(q+o));}},_getTargetOffset:function(l){var n=this.get(i),o=this.get(c),k=(n<o)?true:false,m=this._pageOffsets;if(k){if(l>1){return m[2];}else{return m[1];}}else{return m[0];}},_flickFrame:function(){var n=this._host,m=n._currentVelocity,o=m<0,k=this.get(c),l=this.get(d);if(m){if(o&&k<l-1){this.next();}else{if(!o&&k>0){this.prev();}}}return this._prevent;},_afterRender:function(l){var k=this._host;k.get("boundingBox").addClass(k.getClassName("paged"));},_scrollEnded:function(o){var n=this._host,k=this.get(c),l=this.get(d),m=j.SNAP_TO_CURRENT;if(o.onGestureMoveEnd&&!n._flicking){if(n._scrolledHalfway){if(n._scrolledForward&&k<l-1){this.next();}else{if(k>0){this.prev();}else{this.snapToCurrent(m.duration,m.easing);}}}else{this.snapToCurrent(m.duration,m.easing);}}if(o.details.length===0){this._manageDOM();}},_manageDOM:function(){var r,q,p,t=this._host,n=t.get(h),o=this.get(c),k=this.get(i),s=(k<o)?true:false,l=n.get("children"),m=this.slideNodes;if(s){r=m.item(o+1);q=n.append;}else{r=m.item(o-1);q=n.prepend;}if(l.indexOf(r)===-1){q.call(n,r);}l=n.get("children");if(l.size()>3){p=(s)?n.one("li:first-of-type"):n.one("li:last-of-type");p.remove();t.set("scrollX",300);}this.set(i,o);},_afterIndexChange:function(k){if(k.src!==b){this._uiIndex(k.newVal);}},_uiIndex:function(k){this.scrollTo(k,350,"ease-out");},next:function(){var k=this.get(c);if(k<this.get(d)-1){this.set(c,k+1);}},prev:function(){var k=this.get(c);if(k>0){this.set(c,k-1);}},scrollTo:function(l,o,q){var n=this._host,k=n._scrollsVertical,m=(k)?e:f,p=this._getTargetOffset(l);n.set(m,p,{duration:o,easing:q});},snapToCurrent:function(m,n){var l=this._host,k=l._scrollsVertical;l._killTimer();l.set((k)?e:f,this._getTargetOffset(this.get(c)),{duration:m,easing:n});},_prevent:new a.Do.Prevent()});j.SNAP_TO_CURRENT={duration:300,easing:"ease-out"};a.namespace("Plugin").ScrollViewPaginator=j;},"@VERSION@",{requires:["plugin"]});