transition-min.js revision 2e49faa8717cc2acbd7ab2aac237061848568a6c
YUI.add("transition-native",function(b){var i="",h="",f=b.config.doc,r="documentElement",s="transition",k="Transition",m,j,p,a,n,c,l,t,q={},g=["Webkit","Moz"],e={Webkit:"webkitTransitionEnd"},d=function(){this.init.apply(this,arguments);};d._toCamel=function(u){u=u.replace(/-([a-z])/gi,function(w,v){return v.toUpperCase();});return u;};d.SHOW_TRANSITION="fadeIn";d.HIDE_TRANSITION="fadeOut";d._toHyphen=function(u){u=u.replace(/([A-Z]?)([a-z]+)([A-Z]?)/g,function(y,x,w,v){var z="";if(x){z+="-"+x.toLowerCase();}z+=w;if(v){z+="-"+v.toLowerCase();}return z;});return u;};d.useNative=false;b.Array.each(g,function(v){var u=v+k;if(u in f[r].style){i=v;h=d._toHyphen(v)+"-";d.useNative=true;d.supported=true;}});k=i+"Transition";m=i+"TransitionProperty";j=h+"transition-property";p=h+"transition-duration";a=h+"transition-timing-function";n=h+"transition-delay";c="transitionend";l="on"+i.toLowerCase()+"transitionend";c=e[i]||c;t=i+"Transform";d.fx={};d.toggles={};d._hasEnd={};d._reKeywords=/^(?:node|duration|iterations|easing|delay|on|onstart|onend)$/i;b.Node.DOM_EVENTS[c]=1;d.NAME="transition";d.DEFAULT_EASING="ease";d.DEFAULT_DURATION=0.5;d.DEFAULT_DELAY=0;d._nodeAttrs={};d.prototype={constructor:d,init:function(v,u){var w=this;w._node=v;if(!w._running&&u){w._config=u;v._transition=w;w._duration=("duration" in u)?u.duration:w.constructor.DEFAULT_DURATION;w._delay=("delay" in u)?u.delay:w.constructor.DEFAULT_DELAY;w._easing=u.easing||w.constructor.DEFAULT_EASING;w._count=0;w._running=false;}return w;},addProperty:function(v,x){var A=this,y=this._node,C=b.stamp(y),B=b.one(y),F=d._nodeAttrs[C],z,E,u,D,w;if(!F){F=d._nodeAttrs[C]={};}D=F[v];if(x&&x.value!==undefined){w=x.value;}else{if(x!==undefined){w=x;x=q;}}if(typeof w==="function"){w=w.call(B,B);}if(D&&D.transition){if(D.transition!==A){D.transition._count--;}}A._count++;u=((typeof x.duration!="undefined")?x.duration:A._duration)||0.0001;F[v]={value:w,duration:u,delay:(typeof x.delay!="undefined")?x.delay:A._delay,easing:x.easing||A._easing,transition:A};z=b.DOM.getComputedStyle(y,v);E=(typeof w==="string")?z:parseFloat(z);if(d.useNative&&E===w){setTimeout(function(){A._onNativeEnd.call(y,{propertyName:v,elapsedTime:u});},u*1000);}},removeProperty:function(w){var v=this,u=d._nodeAttrs[b.stamp(v._node)];if(u&&u[w]){delete u[w];v._count--;}},initAttrs:function(v){var u,w=this._node;if(v.transform&&!v[t]){v[t]=v.transform;delete v.transform;}for(u in v){if(v.hasOwnProperty(u)&&!d._reKeywords.test(u)){this.addProperty(u,v[u]);if(w.style[u]===""){b.DOM.setStyle(w,u,b.DOM.getComputedStyle(w,u));}}}},run:function(y){var x=this,v=x._node,u=x._config,w={type:"transition:start",config:u};if(!x._running){x._running=true;if(u.on&&u.on.start){u.on.start.call(b.one(v),w);}x.initAttrs(x._config);x._callback=y;x._start();}return x;},_start:function(){this._runNative();},_prepDur:function(u){u=parseFloat(u);return u+"s";},_runNative:function(w){var C=this,x=C._node,E=b.stamp(x),v=x.style,A=getComputedStyle(x),I=d._nodeAttrs[E],y="",J=A[d._toCamel(j)],H=j+": ",B=p+": ",G=a+": ",D=n+": ",z,F,u;if(J!=="all"){H+=J+",";B+=A[d._toCamel(p)]+",";G+=A[d._toCamel(a)]+",";D+=A[d._toCamel(n)]+",";}for(u in I){z=d._toHyphen(u);F=I[u];if(I.hasOwnProperty(u)&&F.transition===C){if(u in x.style){B+=C._prepDur(F.duration)+",";D+=C._prepDur(F.delay)+",";G+=(F.easing)+",";H+=z+",";y+=z+": "+F.value+"; ";}else{this.removeProperty(u);}}}H=H.replace(/,$/,";");B=B.replace(/,$/,";");G=G.replace(/,$/,";");D=D.replace(/,$/,";");if(!d._hasEnd[E]){x.addEventListener(c,C._onNativeEnd,"");d._hasEnd[E]=true;}v.cssText+=H+B+G+D+y;},_end:function(u){var y=this,w=y._node,A=y._callback,v=y._config,x={type:"transition:end",config:v,elapsedTime:u},z=b.one(w);y._running=false;y._callback=null;if(w){if(v.on&&v.on.end){setTimeout(function(){v.on.end.call(z,x);if(A){A.call(z,x);}},1);}else{if(A){setTimeout(function(){A.call(z,x);},1);}}}},_endNative:function(u){var v=this._node,w=v.ownerDocument.defaultView.getComputedStyle(v,"")[d._toCamel(j)];if(typeof w==="string"){w=w.replace(new RegExp("(?:^|,\\s)"+u+",?"),",");w=w.replace(/^,|,$/,"");v.style[k]=w;}},_onNativeEnd:function(B){var x=this,A=b.stamp(x),u=B,v=d._toCamel(u.propertyName),E=u.elapsedTime,D=d._nodeAttrs[A],C=D[v],y=(C)?C.transition:null,z,w;if(y){y.removeProperty(v);y._endNative(v);w=y._config[v];z={type:"propertyEnd",propertyName:v,elapsedTime:E,config:w};if(w&&w.on&&w.on.end){w.on.end.call(b.one(x),z);}if(y._count<=0){y._end(E);}}},destroy:function(){var u=this;node.removeEventListener(c,u._onNativeEnd,false);u._node=null;}};b.Transition=d;b.TransitionNative=d;b.Node.prototype.transition=function(w,v,A){var u=d._nodeAttrs[b.stamp(this._node)],y=(u)?u.transition||null:null,x,z;if(typeof w==="string"){if(typeof v==="function"){A=v;v=null;}x=d.fx[w];if(v&&typeof v!=="boolean"){v=b.clone(v);for(z in x){if(x.hasOwnProperty(z)){if(!(z in v)){v[z]=x[z];}}}}else{v=x;}}else{A=v;v=w;}if(y&&!y._running){y.init(this,v);}else{y=new d(this._node,v);}y.run(A);return this;};b.Node.prototype.show=function(v,u,w){this._show();if(v&&b.Transition){if(typeof v!=="string"&&!v.push){if(typeof u==="function"){w=u;u=v;}v=d.SHOW_TRANSITION;}this.transition(v,u,w);}return this;};var o=function(v,u,w){return function(){if(u){u.call(v);}if(w){w.apply(v._node,arguments);}};};b.Node.prototype.hide=function(v,u,w){if(v&&b.Transition){if(typeof u==="function"){w=u;u=null;}w=o(this,this._hide,w);if(typeof v!=="string"&&!v.push){if(typeof u==="function"){w=u;u=v;}v=d.HIDE_TRANSITION;}this.transition(v,u,w);}else{this._hide();}return this;};b.NodeList.prototype.transition=function(v,y){var u=this._nodes,w=0,x;while((x=u[w++])){b.one(x).transition(v,y);}return this;};b.Node.prototype.toggleView=function(v,u,w){this._toggles=this._toggles||[];w=arguments[arguments.length-1];if(typeof v=="boolean"){u=v;v=null;}v=v||b.Transition.DEFAULT_TOGGLE;if(typeof u=="undefined"&&v in this._toggles){u=!this._toggles[v];}u=(u)?1:0;if(u){this._show();}else{w=o(this,this._hide,w);}this._toggles[v]=u;
this.transition(b.Transition.toggles[v][u],w);return this;};b.NodeList.prototype.toggleView=function(w,u,z){var v=this._nodes,x=0,y;while((y=v[x++])){b.one(y).toggleView(w,u,z);}return this;};b.mix(d.fx,{fadeOut:{opacity:0,duration:0.5,easing:"ease-out"},fadeIn:{opacity:1,duration:0.5,easing:"ease-in"},sizeOut:{height:0,width:0,duration:0.75,easing:"ease-out"},sizeIn:{height:function(u){return u.get("scrollHeight")+"px";},width:function(u){return u.get("scrollWidth")+"px";},duration:0.5,easing:"ease-in",on:{start:function(){var u=this.getStyle("overflow");if(u!=="hidden"){this.setStyle("overflow","hidden");this._transitionOverflow=u;}},end:function(){if(this._transitionOverflow){this.setStyle("overflow",this._transitionOverflow);delete this._transitionOverflow;}}}}});b.mix(d.toggles,{size:["sizeOut","sizeIn"],fade:["fadeOut","fadeIn"]});d.DEFAULT_TOGGLE="fade";},"@VERSION@",{requires:["node-base"]});YUI.add("transition-timer",function(b){var a=b.Transition;b.mix(a.prototype,{_start:function(){if(a.useNative){this._runNative();}else{this._runTimer();}},_runTimer:function(){var c=this;c._initAttrs();a._running[b.stamp(c)]=c;c._startTime=new Date();a._startTimer();},_endTimer:function(){var c=this;delete a._running[b.stamp(c)];c._startTime=null;},_runFrame:function(){var c=new Date()-this._startTime;this._runAttrs(c);},_runAttrs:function(e){var o=this,n=o._node,u=o._config,f=b.stamp(n),m=a._nodeAttrs[f],h=a.behaviors,l=false,g=false,v,w,j,q,c,s,r,k,p;for(w in m){j=m[w];if((j&&j.transition===o)){r=j.duration;s=j.delay;c=(e-s)/1000;k=e;v={type:"propertyEnd",propertyName:w,config:u,elapsedTime:c};q=(p in h&&"set" in h[p])?h[p].set:a.DEFAULT_SETTER;l=(k>=r);if(k>r){k=r;}if(!s||e>=s){q(o,w,j.from,j.to,k-s,r-s,j.easing,j.unit);if(l){delete m[w];o._count--;if(u[w]&&u[w].on&&u[w].on.end){u[w].on.end.call(b.one(n),v);}if(!g&&o._count<=0){g=true;o._end(c);o._endTimer();}}}}}},_initAttrs:function(){var j=this,e=a.behaviors,l=b.stamp(j._node),q=a._nodeAttrs[l],d,i,k,n,g,c,m,o,p,f,h;for(c in q){d=q[c];if(q.hasOwnProperty(c)&&(d&&d.transition===j)){i=d.duration*1000;k=d.delay*1000;n=d.easing;g=d.value;if(c in j._node.style||c in b.DOM.CUSTOM_STYLES){f=(c in e&&"get" in e[c])?e[c].get(j,c):a.DEFAULT_GETTER(j,c);o=a.RE_UNITS.exec(f);m=a.RE_UNITS.exec(g);f=o?o[1]:f;h=m?m[1]:g;p=m?m[2]:o?o[2]:"";if(!p&&a.RE_DEFAULT_UNIT.test(c)){p=a.DEFAULT_UNIT;}if(typeof n==="string"){if(n.indexOf("cubic-bezier")>-1){n=n.substring(13,n.length-1).split(",");}else{if(a.easings[n]){n=a.easings[n];}}}d.from=Number(f);d.to=Number(h);d.unit=p;d.easing=n;d.duration=i+k;d.delay=k;}else{delete q[c];j._count--;}}}},destroy:function(){this.detachAll();this._node=null;}},true);b.mix(b.Transition,{_runtimeAttrs:{},RE_DEFAULT_UNIT:/^width|height|top|right|bottom|left|margin.*|padding.*|border.*$/i,DEFAULT_UNIT:"px",intervalTime:20,behaviors:{left:{get:function(d,c){return b.DOM._getAttrOffset(d._node,c);}}},DEFAULT_SETTER:function(f,g,i,j,l,e,h,k){i=Number(i);j=Number(j);var d=f._node,c=a.cubicBezier(h,l/e);c=i+c[0]*(j-i);if(d){if(g in d.style||g in b.DOM.CUSTOM_STYLES){k=k||"";b.DOM.setStyle(d,g,c+k);}}else{f._end();}},DEFAULT_GETTER:function(e,c){var d=e._node,f="";if(c in d.style||c in b.DOM.CUSTOM_STYLES){f=b.DOM.getComputedStyle(d,c);}return f;},_startTimer:function(){if(!a._timer){a._timer=setInterval(a._runFrame,a.intervalTime);}},_stopTimer:function(){clearInterval(a._timer);a._timer=null;},_runFrame:function(){var c=true,d;for(d in a._running){if(a._running[d]._runFrame){c=false;a._running[d]._runFrame();}}if(c){a._stopTimer();}},cubicBezier:function(s,m){var z=0,f=0,w=s[0],e=s[1],v=s[2],d=s[3],u=1,c=0,r=u-3*v+3*w-z,q=3*v-6*w+3*z,o=3*w-3*z,n=z,l=c-3*d+3*e-f,k=3*d-6*e+3*f,j=3*e-3*f,i=f,h=(((r*m)+q)*m+o)*m+n,g=(((l*m)+k)*m+j)*m+i;return[h,g];},easings:{ease:[0.25,0,1,0.25],linear:[0,0,1,1],"ease-in":[0.42,0,1,1],"ease-out":[0,0,0.58,1],"ease-in-out":[0.42,0,0.58,1]},_running:{},_timer:null,RE_UNITS:/^(-?\d*\.?\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)*$/},true);a.behaviors.top=a.behaviors.bottom=a.behaviors.right=a.behaviors.left;b.Transition=a;},"@VERSION@",{requires:["transition-native","node-style"]});YUI.add("transition",function(a){},"@VERSION@",{use:["transition-native","transition-timer"]});