event-min.js revision c2e6a0e082fcb34905724d27cc7f6be467e1a6bc
(function(){var stateChangeListener,GLOBAL_ENV=YUI.Env,config=YUI.config,doc=config.doc,docElement=doc&&doc.documentElement,doScrollCap=docElement&&docElement.doScroll,add=YUI.Env.add,remove=YUI.Env.remove,targetEvent=(doScrollCap)?"onreadystatechange":"DOMContentLoaded",pollInterval=config.pollInterval||40,_ready=function(e){GLOBAL_ENV._ready();};if(!GLOBAL_ENV._ready){GLOBAL_ENV._ready=function(){if(!GLOBAL_ENV.DOMReady){GLOBAL_ENV.DOMReady=true;remove(doc,targetEvent,_ready);}};
/* DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */
if(doScrollCap){if(self!==self.top){stateChangeListener=function(){if(doc.readyState=="complete"){remove(doc,targetEvent,stateChangeListener);_ready();}};add(doc,targetEvent,stateChangeListener);}else{GLOBAL_ENV._dri=setInterval(function(){try{docElement.doScroll("left");clearInterval(GLOBAL_ENV._dri);GLOBAL_ENV._dri=null;_ready();}catch(domNotReady){}},pollInterval);}}else{add(doc,targetEvent,_ready);}}})();YUI.add("event-base",function(A){(function(){var C=YUI.Env,B=function(){A.fire("domready");};A.publish("domready",{fireOnce:true});if(C.DOMReady){B();}else{A.before(B,C,"_ready");}})();(function(){var C=A.UA,B={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9,63272:46,63273:36,63275:35},D=function(F){try{if(F&&3==F.nodeType){F=F.parentNode;}}catch(E){return null;}return A.one(F);};A.DOMEventFacade=function(L,F,E){E=E||{};var H=L,G=F,I=A.config.doc,M=I.body,N=H.pageX,K=H.pageY,J,P,O=E.overrides||{};this.altKey=H.altKey;this.ctrlKey=H.ctrlKey;this.metaKey=H.metaKey;this.shiftKey=H.shiftKey;this.type=O.type||H.type;this.clientX=H.clientX;this.clientY=H.clientY;if(!N&&0!==N){N=H.clientX||0;K=H.clientY||0;if(C.ie){N+=Math.max(I.documentElement.scrollLeft,M.scrollLeft);K+=Math.max(I.documentElement.scrollTop,M.scrollTop);}}this._yuifacade=true;this._event=H;this.pageX=N;this.pageY=K;J=H.keyCode||H.charCode||0;if(C.webkit&&(J in B)){J=B[J];}this.keyCode=J;this.charCode=J;this.button=H.which||H.button;this.which=this.button;this.target=D(H.target||H.srcElement);this.currentTarget=D(G);P=H.relatedTarget;if(!P){if(H.type=="mouseout"){P=H.toElement;}else{if(H.type=="mouseover"){P=H.fromElement;}}}this.relatedTarget=D(P);if(H.type=="mousewheel"||H.type=="DOMMouseScroll"){this.wheelDelta=(H.detail)?(H.detail*-1):Math.round(H.wheelDelta/80)||((H.wheelDelta<0)?-1:1);}this.stopPropagation=function(){if(H.stopPropagation){H.stopPropagation();}else{H.cancelBubble=true;}E.stopped=1;};this.stopImmediatePropagation=function(){if(H.stopImmediatePropagation){H.stopImmediatePropagation();}else{this.stopPropagation();}E.stopped=2;};this.preventDefault=function(Q){if(H.preventDefault){H.preventDefault();}H.returnValue=Q||false;E.prevented=1;};this.halt=function(Q){if(Q){this.stopImmediatePropagation();}else{this.stopPropagation();}this.preventDefault();};};})();(function(){A.Env.evt.dom_wrappers={};A.Env.evt.dom_map={};var J=A.Env.evt,C=A.config,G=C.win,L=YUI.Env.add,E=YUI.Env.remove,I=function(){YUI.Env.windowLoaded=true;A.Event._load();E(G,"load",I);},B=function(){A.Event._unload();E(G,"unload",B);},D="domready",F="~yui|2|compat~",H=function(N){try{return(N&&typeof N!=="string"&&A.Lang.isNumber(N.length)&&!N.tagName&&!N.alert);}catch(M){return false;}},K=function(){var O=false,P=0,N=[],Q=J.dom_wrappers,M=null,R=J.dom_map;return{POLL_RETRYS:1000,POLL_INTERVAL:40,lastError:null,_interval:null,_dri:null,DOMReady:false,startInterval:function(){if(!K._interval){K._interval=setInterval(A.bind(K._poll,K),K.POLL_INTERVAL);}},onAvailable:function(S,W,b,T,X,Z){var Y=A.Array(S),U,V;for(U=0;U<Y.length;U=U+1){N.push({id:Y[U],fn:W,obj:b,override:T,checkReady:X,compat:Z});}P=this.POLL_RETRYS;setTimeout(A.bind(K._poll,K),0);V=new A.EventHandle({_delete:function(){if(V.handle){V.handle.detach();return;}var c,a;for(c=0;c<Y.length;c++){for(a=0;a<N.length;a++){if(Y[c]===N[a].id){N.splice(a,1);}}}}});return V;},onContentReady:function(W,T,V,U,S){return this.onAvailable(W,T,V,U,true,S);},attach:function(V,U,T,S){return K._attach(A.Array(arguments,0,true));},_createWrapper:function(Y,X,S,T,W){var V,Z=A.stamp(Y),U="event:"+Z+X;if(false===W){U+="native";}if(S){U+="capture";}V=Q[U];if(!V){V=A.publish(U,{silent:true,bubbles:false,contextFn:function(){if(T){return V.el;}else{V.nodeRef=V.nodeRef||A.one(V.el);return V.nodeRef;}}});V.overrides={};V.el=Y;V.key=U;V.domkey=Z;V.type=X;V.fn=function(a){V.fire(K.getEvent(a,Y,(T||(false===W))));};V.capture=S;if(Y==G&&X=="load"){V.fireOnce=true;M=U;}Q[U]=V;R[Z]=R[Z]||{};R[Z][U]=V;L(Y,X,V.fn,S);}return V;},_attach:function(Y,X){var d,f,V,c,S,U=false,W,Z=Y[0],a=Y[1],T=Y[2]||G,g=X&&X.facade,e=X&&X.capture,b=X&&X.overrides;if(Y[Y.length-1]===F){d=true;}if(!a||!a.call){return false;}if(H(T)){f=[];A.each(T,function(i,h){Y[2]=i;f.push(K._attach(Y,X));});return new A.EventHandle(f);}else{if(A.Lang.isString(T)){if(d){V=A.DOM.byId(T);}else{V=A.Selector.query(T);switch(V.length){case 0:V=null;break;case 1:V=V[0];break;default:Y[2]=V;return K._attach(Y,X);}}if(V){T=V;}else{W=this.onAvailable(T,function(){W.handle=K._attach(Y,X);},K,true,false,d);return W;}}}if(!T){return false;}if(A.Node&&T instanceof A.Node){T=A.Node.getDOMNode(T);}c=this._createWrapper(T,Z,e,d,g);if(b){A.mix(c.overrides,b);}if(T==G&&Z=="load"){if(YUI.Env.windowLoaded){U=true;}}if(d){Y.pop();}S=Y[3];W=c._on(a,S,(Y.length>4)?Y.slice(4):null);if(U){c.fire();}return W;},detach:function(Z,a,U,X){var Y=A.Array(arguments,0,true),c,V,b,W,S,T;if(Y[Y.length-1]===F){c=true;}if(Z&&Z.detach){return Z.detach();}if(typeof U=="string"){if(c){U=A.DOM.byId(U);}else{U=A.Selector.query(U);V=U.length;if(V<1){U=null;}else{if(V==1){U=U[0];}}}}if(!U){return false;}if(U.detach){Y.splice(2,1);return U.detach.apply(U,Y);}else{if(H(U)){b=true;for(W=0,V=U.length;W<V;++W){Y[2]=U[W];b=(A.Event.detach.apply(A.Event,Y)&&b);}return b;}}if(!Z||!a||!a.call){return this.purgeElement(U,false,Z);}S="event:"+A.stamp(U)+Z;T=Q[S];if(T){return T.detach(a);}else{return false;}},getEvent:function(V,T,S){var U=V||G.event;
return(S)?U:new A.DOMEventFacade(U,T,Q["event:"+A.stamp(T)+V.type]);},generateId:function(S){var T=S.id;if(!T){T=A.stamp(S);S.id=T;}return T;},_isValidCollection:H,_load:function(S){if(!O){O=true;if(A.fire){A.fire(D);}K._poll();}},_poll:function(){if(this.locked){return;}if(A.UA.ie&&!YUI.Env.DOMReady){this.startInterval();return;}this.locked=true;var T,S,X,U,W,Y,V=!O;if(!V){V=(P>0);}W=[];Y=function(b,c){var a,Z=c.override;if(c.compat){if(c.override){if(Z===true){a=c.obj;}else{a=Z;}}else{a=b;}c.fn.call(a,c.obj);}else{a=c.obj||A.one(b);c.fn.apply(a,(A.Lang.isArray(Z))?Z:[]);}};for(T=0,S=N.length;T<S;++T){X=N[T];if(X&&!X.checkReady){U=(X.compat)?A.DOM.byId(X.id):A.Selector.query(X.id,null,true);if(U){Y(U,X);N[T]=null;}else{W.push(X);}}}for(T=0,S=N.length;T<S;++T){X=N[T];if(X&&X.checkReady){U=(X.compat)?A.DOM.byId(X.id):A.Selector.query(X.id,null,true);if(U){if(O||(U.get&&U.get("nextSibling"))||U.nextSibling){Y(U,X);N[T]=null;}}else{W.push(X);}}}P=(W.length===0)?0:P-1;if(V){this.startInterval();}else{clearInterval(this._interval);this._interval=null;}this.locked=false;return;},purgeElement:function(V,S,Z){var X=(A.Lang.isString(V))?A.Selector.query(V,null,true):V,b=this.getListeners(X,Z),W,Y,a,U,T;if(S&&X){b=b||[];U=A.Selector.query("*",X);W=0;Y=U.length;for(;W<Y;++W){T=this.getListeners(U[W],Z);if(T){b=b.concat(T);}}}if(b){W=0;Y=b.length;for(;W<Y;++W){a=b[W];a.detachAll();E(a.el,a.type,a.fn,a.capture);delete Q[a.key];delete R[a.domkey][a.key];}}},getListeners:function(W,V){var X=A.stamp(W,true),S=R[X],U=[],T=(V)?"event:"+X+V:null;if(!S){return null;}if(T){if(S[T]){U.push(S[T]);}T+="native";if(S[T]){U.push(S[T]);}}else{A.each(S,function(Z,Y){U.push(Z);});}return(U.length)?U:null;},_unload:function(S){A.each(Q,function(U,T){U.detachAll();E(U.el,U.type,U.fn,U.capture);delete Q[T];delete R[U.domkey][T];});},nativeAdd:L,nativeRemove:E};}();A.Event=K;if(C.injected||YUI.Env.windowLoaded){I();}else{L(G,"load",I);}if(A.UA.ie){A.on(D,K._poll,K,true);}A.on("unload",B);K.Custom=A.CustomEvent;K.Subscriber=A.Subscriber;K.Target=A.EventTarget;K.Handle=A.EventHandle;K.Facade=A.EventFacade;K._poll();})();A.Env.evt.plugins.available={on:function(D,C,F,E){var B=arguments.length>4?A.Array(arguments,4,true):[];return A.Event.onAvailable.call(A.Event,F,C,E,B);}};A.Env.evt.plugins.contentready={on:function(D,C,F,E){var B=arguments.length>4?A.Array(arguments,4,true):[];return A.Event.onContentReady.call(A.Event,F,C,E,B);}};},"@VERSION@",{requires:["event-custom-base"]});YUI.add("event-delegate",function(B){var I=B.Event,F=B.Lang,E={},A={mouseenter:"mouseover",mouseleave:"mouseout"},H=function(K){try{if(K&&3==K.nodeType){return K.parentNode;}}catch(J){}return K;},D=function(K,P,M){var Q=H((P.target||P.srcElement)),N=E[K],T,O,L,S,R;var J=function(X,U,V){var W;if(!X||X===V){W=false;}else{W=B.Selector.test(X,U,V)?X:J(X.parentNode,U,V);}return W;};for(T in N){if(N.hasOwnProperty(T)){O=N[T];S=N.fn;L=null;if(B.Selector.test(Q,T,M)){L=Q;}else{if(B.Selector.test(Q,((T.replace(/,/gi," *,"))+" *"),M)){L=J(Q,T,M);}}if(L){if(!R){R=new B.DOMEventFacade(P,M);R.container=R.currentTarget;}R.currentTarget=B.one(L);B.publish(O,{contextFn:function(){return R.currentTarget;}});if(S){S(R,O);}else{B.fire(O,R);}}}}},G=function(M,L,K){var O={focus:I._attachFocus,blur:I._attachBlur},N=O[M],J=[M,function(P){D(L,(P||B.config.win.event),K);},K];if(N){return N(J,{capture:true,facade:false});}else{return I._attach(J,{facade:false});}},C=B.cached(function(J){return J.replace(/[|,:]/g,"~");});I.delegate=function(R,U,K,W){if(!W){return false;}var O=B.Array(arguments,0,true),M=K,N;if(F.isString(K)){M=B.Selector.query(K,null,true);if(!M){N=I.onAvailable(K,function(){N.handle=I.delegate.apply(I,O);},I,true,false);return N;}}M=B.Node.getDOMNode(M);var S=B.stamp(M),L="delegate:"+S+R+C(W),J=R+S,Q=E[J],T,V,P;if(!Q){Q={};if(A[R]){if(!I._fireMouseEnter){return false;}R=A[R];Q.fn=I._fireMouseEnter;}T=G(R,J,M);B.after(function(X){if(T.sub==X){delete E[J];B.detachAll(L);}},T.evt,"_delete");Q.handle=T;E[J]=Q;}P=Q.listeners;Q.listeners=P?(P+1):1;Q[W]=L;O[0]=L;O.splice(2,2);V=B.on.apply(B,O);B.after(function(){Q.listeners=(Q.listeners-1);if(Q.listeners===0){Q.handle.detach();}},V,"detach");return V;};B.delegate=I.delegate;},"@VERSION@",{requires:["node-base"]});YUI.add("event-mousewheel",function(C){var B="DOMMouseScroll",A=function(E){var D=C.Array(E,0,true),F;if(C.UA.gecko){D[0]=B;F=C.config.win;}else{F=C.config.doc;}if(D.length<3){D[2]=F;}else{D.splice(2,0,F);}return D;};C.Env.evt.plugins.mousewheel={on:function(){return C.Event._attach(A(arguments));},detach:function(){return C.Event.detach.apply(C.Event,A(arguments));}};},"@VERSION@",{requires:["node-base"]});YUI.add("event-mouseenter",function(F){var C=F.Event,E=F.Lang,B=F.Env.evt.plugins,D={},A={on:function(M,O,H){var L=F.Array(arguments,0,true),J=H,K;if(E.isString(H)){J=F.all(H);if(J.size()===0){K=C.onAvailable(H,function(){K.handle=F.on.apply(F,L);},C,true,false);return K;}}var R=(M==="mouseenter")?"mouseover":"mouseout",Q=M+":"+F.stamp(J)+R,I=D[Q],N,P,G;if(!I){N=F.on(R,F.rbind(C._fireMouseEnter,F,Q),J);F.after(function(S){if(N.sub==S){delete D[Q];F.detachAll(Q);}},N.evt,"_delete");I={};I.handle=N;D[Q]=I;}G=I.count;I.count=G?(G+1):1;L[0]=Q;L.splice(2,1);P=F.on.apply(F,L);F.after(function(){I.count=(I.count-1);if(I.count===0){I.handle.detach();}},P,"detach");return P;}};C._fireMouseEnter=function(J,H){var G=J.relatedTarget,I=J.currentTarget;if(I!==G&&!I.contains(G)){F.publish(H,{contextFn:function(){return I;}});F.fire(H,J);}};B.mouseenter=A;B.mouseleave=A;},"@VERSION@",{requires:["node-base"]});YUI.add("event-key",function(A){A.Env.evt.plugins.key={on:function(E,G,B,K,C){var I=A.Array(arguments,0,true),F,J,H,D;F=K&&K.split(":");if(!K||K.indexOf(":")==-1||!F[1]){I[0]="key"+((F&&F[0])||"press");return A.on.apply(A,I);}J=F[0];H=(F[1])?F[1].split(/,|\+/):null;D=(A.Lang.isString(B)?B:A.stamp(B))+K;D=D.replace(/,/g,"_");if(!A.getEvent(D)){A.on(E+J,function(P){var Q=false,M=false,N,L,O;for(N=0;N<H.length;N=N+1){L=H[N];
O=parseInt(L,10);if(A.Lang.isNumber(O)){if(P.charCode===O){Q=true;}else{M=true;}}else{if(Q||!M){Q=(P[L+"Key"]);M=!Q;}}}if(Q){A.fire(D,P);}},B);}I.splice(2,2);I[0]=D;return A.on.apply(A,I);}};},"@VERSION@",{requires:["node-base"]});YUI.add("event-focus",function(A){(function(){var I=A.UA,J=A.Event,E=A.Env.evt.plugins,C=I.ie,F=(I.opera||I.webkit),D={focus:(C?"focusin":(F?"DOMFocusIn":"focus")),blur:(C?"focusout":(F?"DOMFocusOut":"blur"))},G={capture:(I.gecko?true:false)},H=function(M,L){var K=A.Array(M,0,true),N=M[2];L.overrides=L.overrides||{};L.overrides.type=M[0];if(N){if(A.DOM.isWindow(N)){L.capture=false;}else{K[0]=D[K[0]];}}return J._attach(K,L);},B={on:function(){return H(arguments,G);}};J._attachFocus=H;J._attachBlur=H;E.focus=B;E.blur=B;})();},"@VERSION@",{requires:["node-base"]});YUI.add("event-resize",function(A){(function(){var C,B,E="window:resize",D=function(F){if(A.UA.gecko){A.fire(E,F);}else{if(B){B.cancel();}B=A.later(A.config.windowResizeDelay||40,A,function(){A.fire(E,F);});}};A.Env.evt.plugins.windowresize={on:function(H,G){if(!C){C=A.Event._attach(["resize",D]);}var F=A.Array(arguments,0,true);F[0]=E;return A.on.apply(A,F);}};})();},"@VERSION@",{requires:["node-base"]});YUI.add("event",function(A){},"@VERSION@",{use:["event-base","event-delegate","event-mousewheel","event-mouseenter","event-key","event-focus","event-resize"]});