event-base-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"]});