event-min.js revision 773ea81b58454b01a90ed69d8a100ce5078404c1
(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,async: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.stopped=1;};this.stopImmediatePropagation=function(){if(H.stopImmediatePropagation){H.stopImmediatePropagation();}else{this.stopPropagation();}E.stopped=2;this.stopped=2;};this.preventDefault=function(Q){if(H.preventDefault){H.preventDefault();}H.returnValue=Q||false;E.prevented=1;this.prevented=1;};this.halt=function(Q){if(Q){this.stopImmediatePropagation();}else{this.stopPropagation();}this.preventDefault();};if(this._touch){this._touch(H,F,E);}};})();(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,Y=J.plugins;if(!S){return null;}if(T){if(Y[V]&&Y[V].eventDef){T+="_synth";}if(S[T]){U.push(S[T]);}T+="native";if(S[T]){U.push(S[T]);}}else{A.each(S,function(a,Z){U.push(a);});}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(G){var D=G.Array,B=G.Lang,A=B.isString,F=G.Selector.test,C=G.Env.evt.handles;function E(Q,S,J,I){var O=D(arguments,0,true),P=A(J)?J:null,N=Q.split(/\|/),L,H,K,R,M;if(N.length>1){R=N.shift();Q=N.shift();}L=G.Node.DOM_EVENTS[Q];if(B.isObject(L)&&L.delegate){M=L.delegate.apply(L,arguments);}if(!M){if(!Q||!S||!J||!I){return;}H=(P)?G.Selector.query(P,null,true):J;if(!H&&A(J)){M=G.on("available",function(){G.mix(M,G.delegate.apply(G,O),true);},J);}if(!M&&H){O.splice(2,2,H);if(A(I)){I=G.delegate.compileFilter(I);}M=G.on.apply(G,O);M.sub.filter=I;M.sub._notify=E.notifySub;}}if(M&&R){K=C[R]||(C[R]={});K=K[Q]||(K[Q]=[]);K.push(M);}return M;}E.notifySub=function(K,P,I){P=P.slice();if(this.args){P.push.apply(P,this.args);}var N=P[0],J=E._applyFilter(this.filter,P),H=N.currentTarget,L,O,M;if(J){J=D(J);for(L=J.length-1;L>=0;--L){M=J[L];P[0]=new G.DOMEventFacade(N,M,I);P[0].container=H;K=this.context||M;O=this.fn.apply(K,P);if(O===false){break;}}return O;}};E.compileFilter=G.cached(function(H){return function(J,I){return F(J._node,H,I.currentTarget._node);};});E._applyFilter=function(K,J){var M=J[0],H=M.currentTarget,L=M.target,I=[];J.unshift(L);while(L&&L!==H){if(K.apply(L,J)){I.push(L);}J[0]=L=L.get("parentNode");}if(I.length<=1){I=I[0];}J.shift();return I;};G.delegate=G.Event.delegate=E;},"@VERSION@",{requires:["node-base"]});YUI.add("event-synthetic",function(B){var H=B.Env.evt.dom_map,D=B.Array,G=B.Lang,J=G.isObject,C=G.isString,E=B.Selector.query,I=function(){};function F(L,K){this.handle=L;this.emitFacade=K;}F.prototype.fire=function(Q){var K=D(arguments,0,true),O=this.handle,P=O.evt,M=O.sub,R=M.context,L=M.filter,N=Q||{};if(this.emitFacade){if(!Q||!Q.preventDefault){N=P._getFacade();if(J(Q)&&!Q.preventDefault){B.mix(N,Q,true);K[0]=N;}else{K.unshift(N);}}N.type=P.type;N.details=K.slice();if(L){N.container=P.host;}}else{if(L&&J(Q)&&Q.currentTarget){K.shift();}}M.context=R||N.currentTarget||P.host;P.fire.apply(P,K);M.context=R;};function A(){this._init.apply(this,arguments);}B.mix(A,{Notifier:F,getRegistry:function(Q,P,N){var O=Q._node,M=B.stamp(O),L="event:"+M+P+"_synth",K=H[M]||(H[M]={});if(!K[L]&&N){K[L]={type:"_synth",fn:I,capture:false,el:O,key:L,domkey:M,notifiers:[],detachAll:function(){var R=this.notifiers,S=R.length;while(--S>=0){R[S].detach();}}};}return(K[L])?K[L].notifiers:null;},_deleteSub:function(L){if(L&&L.fn){var K=this.eventDef,M=(L.filter)?"detachDelegate":"detach";this.subscribers={};this.subCount=0;K[M](L.node,L,this.notifier,L.filter);K._unregisterSub(L);delete L.fn;delete L.node;delete L.context;}},prototype:{constructor:A,_init:function(){var K=this.publishConfig||(this.publishConfig={});this.emitFacade=("emitFacade" in K)?K.emitFacade:true;K.emitFacade=false;},processArgs:I,on:I,detach:I,delegate:I,detachDelegate:I,_on:function(M,O){var N=[],K=M[2],Q=O?"delegate":"on",L,P;L=(C(K))?E(K):D(K);if(!L.length&&C(K)){P=B.on("available",function(){B.mix(P,B[Q].apply(B,M),true);},K);return P;}B.each(L,function(T){var U=M.slice(),R,S;T=B.one(T);if(T){R=this.processArgs(U,O);if(O){S=U.splice(3,1)[0];}U.splice(0,4,U[1],U[3]);if(!this.preventDups||!this.getSubs(T,M,null,true)){P=this._getNotifier(T,U,R,S);this[Q](T,P.sub,P.notifier,S);N.push(P);}}},this);return(N.length===1)?N[0]:new B.EventHandle(N);},_getNotifier:function(N,Q,O,M){var S=new B.CustomEvent(this.type,this.publishConfig),P=S.on.apply(S,Q),R=new F(P,this.emitFacade),L=A.getRegistry(N,this.type,true),K=P.sub;
P.notifier=R;K.node=N;K.filter=M;K._extra=O;B.mix(S,{eventDef:this,notifier:R,host:N,currentTarget:N,target:N,el:N._node,_delete:A._deleteSub},true);L.push(P);return P;},_unregisterSub:function(M){var K=A.getRegistry(M.node,this.type),L;if(K){for(L=K.length-1;L>=0;--L){if(K[L].sub===M){K.splice(L,1);break;}}}},_detach:function(M){var R=M[2],P=(C(R))?E(R):D(R),Q,O,K,N,L;M.splice(2,1);for(O=0,K=P.length;O<K;++O){Q=B.one(P[O]);if(Q){N=this.getSubs(Q,M);if(N){for(L=N.length-1;L>=0;--L){N[L].detach();}}}}},getSubs:function(L,Q,K,N){var R=A.getRegistry(L,this.type),S=[],M,P,O;if(R){if(!K){K=this.subMatch;}for(M=0,P=R.length;M<P;++M){O=R[M];if(K.call(this,O.sub,Q)){if(N){return O;}else{S.push(R[M]);}}}}return S.length&&S;},subMatch:function(L,K){return !K[1]||L.fn===K[1];}}},true);B.SyntheticEvent=A;B.Event.define=function(M,L,O){if(!L){L={};}var N=(J(M))?M:B.merge({type:M},L),P,K;if(O||!B.Node.DOM_EVENTS[N.type]){P=function(){A.apply(this,arguments);};B.extend(P,A,N);K=new P();M=K.type;B.Node.DOM_EVENTS[M]=B.Env.evt.plugins[M]={eventDef:K,on:function(){return K._on(D(arguments));},delegate:function(){return K._on(D(arguments),true);},detach:function(){return K._detach(D(arguments));}};}return K;};},"@VERSION@",{requires:["node-base","event-custom"]});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(C){function B(G,D){var F=G.currentTarget,E=G.relatedTarget;if(F!==E&&!F.contains(E)){D.fire(G);}}var A={proxyType:"mouseover",on:function(F,D,E){D.onHandle=F.on(this.proxyType,B,null,E);},detach:function(E,D){D.onHandle.detach();},delegate:function(G,E,F,D){E.delegateHandle=C.delegate(this.proxyType,B,G,D,null,F);},detachDelegate:function(E,D){D.delegateHandle.detach();}};C.Event.define("mouseenter",A,true);C.Event.define("mouseleave",C.merge(A,{proxyType:"mouseout"}),true);},"@VERSION@",{requires:["event-synthetic"]});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(E){var D=E.Event,C=E.Lang,A=C.isString,B=C.isFunction(E.DOM.create('<p onbeforeactivate=";">').onbeforeactivate);function F(H,G,J){var I="_"+H+"Notifiers";E.Event.define(H,{_attach:function(L,M,K){if(E.DOM.isWindow(L)){return D._attach([H,function(N){M.fire(N);},L]);}else{return D._attach([G,this._proxy,L,this,M,K],{capture:true});}},_proxy:function(O,S,P){var M=O.target,Q=M.getData(I),T=E.stamp(O.currentTarget._node),K=(B||O.target!==O.currentTarget),L=S.handle.sub,R=[M,O].concat(L.args||[]),N;S.currentTarget=(P)?M:O.currentTarget;S.container=(P)?O.currentTarget:null;if(!L.filter||L.filter.apply(M,R)){if(!Q){Q={};M.setData(I,Q);if(K){N=D._attach([J,this._notify,M._node]).sub;N.once=true;}}if(!Q[T]){Q[T]=[];}Q[T].push(S);if(!K){this._notify(O);}}},_notify:function(P,L){var M=P.currentTarget,R=M.getData(I),S=M.get("ownerDocument")||M,Q=M,K=[],T,N,O;if(R){while(Q&&Q!==S){K.push.apply(K,R[E.stamp(Q)]||[]);Q=Q.get("parentNode");}K.push.apply(K,R[E.stamp(S)]||[]);for(N=0,O=K.length;N<O;++N){T=K[N];P.currentTarget=K[N].currentTarget;if(T.container){P.container=T.container;}else{delete P.container;}T.fire(P);}M.clearData(I);}},on:function(M,K,L){K.onHandle=this._attach(M._node,L);},detach:function(L,K){K.onHandle.detach();},delegate:function(N,L,M,K){if(A(K)){L.filter=E.delegate.compileFilter(K);}L.delegateHandle=this._attach(N._node,M,true);},detachDelegate:function(L,K){K.delegateHandle.detach();}},true);}if(B){F("focus","beforeactivate","focusin");F("blur","beforedeactivate","focusout");}else{F("focus","focus","focus");F("blur","blur","blur");}},"@VERSION@",{requires:["event-synthetic"]});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-synthetic","event-mousewheel","event-mouseenter","event-key","event-focus","event-resize"]});