event-min.js revision f699a6a8ba96e55770b2434f4b2299c8d1a83b32
(function(){var E=YUI.Env,G=YUI.config,F=G.doc,B=G.pollInterval||20,A=function(C){E._ready();};if(!E._ready){E.windowLoaded=false;E._ready=function(){if(!E.DOMReady){E.DOMReady=true;if(F.removeEventListener){F.removeEventListener("DOMContentLoaded",A,false);}}};if(navigator.userAgent.match(/MSIE/)){E._dri=setInterval(function(){try{document.documentElement.doScroll("left");clearInterval(E._dri);E._dri=null;A();}catch(C){}},B);}else{F.addEventListener("DOMContentLoaded",A,false);}}})();YUI.add("event",function(E){(function(){var G=YUI.Env,F=function(){E.fire("domready");};E.mix(E.Env.eventAdaptors,{domready:{},"event:ready":{on:function(){var H=E.Array(arguments,0,true);H[0]="domready";return E.subscribe.apply(E,H);},detach:function(){var H=E.Array(arguments,0,true);H[0]="domready";return E.unsubscribe.apply(E,H);}}});E.publish("domready",{fireOnce:true});if(G.DOMReady){F();}else{E.before(F,G,"_ready");}})();(function(){var L=function(Q,P,O,N){if(Q.addEventListener){Q.addEventListener(P,O,!!N);}else{if(Q.attachEvent){Q.attachEvent("on"+P,O);}}},F=function(Q,P,O,N){if(Q.removeEventListener){Q.removeEventListener(P,O,!!N);}else{if(Q.detachEvent){Q.detachEvent("on"+P,O);}}},I=function(){YUI.Env.windowLoaded=true;E.Event._load();F(window,"load",I);},H=function(){E.Event._unload();F(window,"unload",H);},M="domready",K="~yui|2|compat~",J="capture_",G=function(){var P=false,Q=0,O=[],R={},N=null,S={};return{POLL_RETRYS:2000,POLL_INTERVAL:20,lastError:null,_interval:null,_dri:null,DOMReady:false,startInterval:function(){var T=E.Event;if(!T._interval){T._interval=setInterval(E.bind(T._tryPreloadAttach,T),T.POLL_INTERVAL);}},onAvailable:function(b,W,Z,Y,X,U){var T=E.Array(b),V;for(V=0;V<T.length;V=V+1){O.push({id:T[V],fn:W,obj:Z,override:Y,checkReady:X,compat:U});}Q=this.POLL_RETRYS;setTimeout(E.bind(E.Event._tryPreloadAttach,E.Event),0);return new E.EventHandle();},onContentReady:function(X,U,W,V,T){return this.onAvailable(X,U,W,V,true,T);},attach:function(Z,a,U,X){U=U||E.config.win;var Y=E.Array(arguments,0,true),d=Y.slice(1),e,i=E.Event,g=false,f,W,h,V,c,b,T;if(Z.indexOf(J)>-1){Z=Z.substr(J.length);g=true;}if(d[d.length-1]===K){e=true;d.pop();}if(!a||!a.call){return false;}if(this._isValidCollection(U)){f=[];E.each(U,function(l,j){Y[2]=l;f.push(i.attach.apply(i,Y));});return(f.length===1)?f[0]:f;}else{if(E.Lang.isString(U)){W=(e)?E.DOM.byId(U):E.all(U);if(W&&(W instanceof E.NodeList)&&W.size()>0){h=W.size();if(h>1){Y[2]=W;return i.attach.apply(i,Y);}else{U=W.item(0);}}else{if(W){U=W;}else{return this.onAvailable(U,function(){i.attach.apply(i,Y);},i,true,false,e);}}}}if(!U){return false;}V=E.stamp(U);c="event:"+V+Z;b=R[c];if(!b){b=E.publish(c,{silent:true,bubbles:false});b.el=U;b.type=Z;b.fn=function(j){b.fire(i.getEvent(j,U,e));};if(U==E.config.win&&Z=="load"){b.fireOnce=true;N=c;if(YUI.Env.windowLoaded){b.fire();}}R[c]=b;S[V]=S[V]||{};S[V][c]=b;L(U,Z,b.fn,g);}T=d[2]||((e)?U:E.get(U));d[1]=T;d.splice(2,1);return b.subscribe.apply(b,d);},detach:function(a,c,V,W){var Z=E.Array(arguments,0,true),d,X,Y,b,T,U;if(Z[Z.length-1]===K){d=true;}if(a&&a.detach){return a.detach();}if(typeof V=="string"){V=(d)?E.DOM.byId(V):E.all(V);}else{if(this._isValidCollection(V)){b=true;for(X=0,Y=V.length;X<Y;++X){Z[2]=V[X];b=(E.Event.detach.apply(E.Event,Z)&&b);}return b;}}if(!c||!c.call){return this.purgeElement(V,false,a);}T="event:"+E.stamp(V)+a;U=R[T];if(U){return U.unsubscribe(c);}else{return false;}},getEvent:function(W,U,T){var V=W||window.event;return(T)?V:new E.Event.Facade(V,U,R["event:"+E.stamp(U)+W.type]);},generateId:function(T){var U=T.id;if(!U){U=E.stamp(T);T.id=U;}return U;},_isValidCollection:function(U){try{return(U&&typeof U!=="string"&&(U.length&&((!U.size)||(U.size()>1)))&&!U.tagName&&!U.alert&&(U.item||typeof U[0]!=="undefined"));}catch(T){return false;}},_load:function(T){if(!P){P=true;if(E.fire){E.fire(M);}E.Event._tryPreloadAttach();}},_tryPreloadAttach:function(){if(this.locked){return;}if(E.UA.ie&&!YUI.Env.DOMReady){this.startInterval();return;}this.locked=true;var Y=!P,X,Z,U,T,W,V;if(!Y){Y=(Q>0);}X=[];Z=function(c,d){var b,a=d.override;if(d.compat){if(d.override){if(a===true){b=d.obj;}else{b=a;}}else{b=c;}d.fn.call(b,d.obj);}else{b=d.obj||E.get(c);d.fn.apply(b,(E.Lang.isArray(a))?a:[]);}};for(U=0,T=O.length;U<T;++U){W=O[U];if(W&&!W.checkReady){V=(W.compat)?E.DOM.byId(W.id):E.get(W.id);if(V){Z(V,W);O[U]=null;}else{X.push(W);}}}for(U=0,T=O.length;U<T;++U){W=O[U];if(W&&W.checkReady){V=(W.compat)?E.DOM.byId(W.id):E.get(W.id);if(V){if(P||(V.get&&V.get("nextSibling"))||V.nextSibling){Z(V,W);O[U]=null;}}else{X.push(W);}}}Q=(X.length===0)?0:Q-1;if(Y){this.startInterval();}else{clearInterval(this._interval);this._interval=null;}this.locked=false;return;},purgeElement:function(Y,Z,X){var V=(E.Lang.isString(Y))?E.get(Y):Y,U=this.getListeners(V,X),W,T;if(U){for(W=0,T=U.length;W<T;++W){U[W].unsubscribeAll();}}if(Z&&V&&V.childNodes){for(W=0,T=V.childNodes.length;W<T;++W){this.purgeElement(V.childNodes[W],Z,X);}}},getListeners:function(X,W){var Y=E.stamp(X,true),T=S[Y],V=[],U=(W)?"event:"+W:null;if(!T){return null;}if(U){if(T[U]){V.push(T[U]);}}else{E.each(T,function(a,Z){V.push(a);});}return(V.length)?V:null;},_unload:function(U){var T=E.Event;E.each(R,function(W,V){W.unsubscribeAll();F(W.el,W.type,W.fn);delete R[V];});F(window,"load",T._load);F(window,"unload",T._unload);},nativeAdd:L,nativeRemove:F};}();L(window,"load",I);L(window,"unload",H);E.Event=G;if(E.UA.ie&&E.on){E.on(M,G._tryPreloadAttach,G,true);}G.Custom=E.CustomEvent;G.Subscriber=E.Subscriber;G.Target=E.EventTarget;G.Handle=E.EventHandle;G.Facade=E.EventFacade;G._tryPreloadAttach();})();E.Env.eventAdaptors.available={on:function(H,G,J,I){var F=arguments.length>4?E.Array(arguments,4,true):[];return E.Event.onAvailable.call(E.Event,J,G,I,F);}};E.Env.eventAdaptors.contentready={on:function(H,G,J,I){var F=arguments.length>4?E.Array(arguments,4,true):[];return E.Event.onContentReady.call(E.Event,J,G,I,F);}};(function(){var G=E.UA.ie?"focusin":"focus",H=E.UA.ie?"focusout":"blur",I="capture_",F=E.Env.eventAdaptors;
F.focus={on:function(){var J=E.Array(arguments,0,true);J[0]=I+G;return E.Event.attach.apply(E.Event,J);},detach:function(){var J=E.Array(arguments,0,true);J[0]=I+G;return E.Event.detach.apply(E.Event,J);}};F.blur={on:function(){var J=E.Array(arguments,0,true);J[0]=I+H;return E.Event.attach.apply(E.Event,J);},detach:function(){var J=E.Array(arguments,0,true);J[0]=I+H;return E.Event.detach.apply(E.Event,J);}};})();E.Env.eventAdaptors.key={on:function(I,K,F,O,G){var M=E.Array(arguments,0,true),J,N,L,H;if(!O||O.indexOf(":")==-1){M[0]="keypress";return E.on.apply(E,M);}J=O.split(":");N=J[0];L=(J[1])?J[1].split(/,|\+/):null;H=(E.Lang.isString(F)?F:E.stamp(F))+O;H=H.replace(/,/g,"_");if(!E.getEvent(H)){E.on(I+N,function(T){var U=false,Q=false,R,P,S;for(R=0;R<L.length;R=R+1){P=L[R];S=parseInt(P,10);if(E.Lang.isNumber(S)){if(T.charCode===S){U=true;}else{Q=true;}}else{if(U||!Q){U=(T[P+"Key"]);Q=!U;}}}if(U){E.fire(H,T);}},F);}M.splice(2,2);M[0]=H;return E.on.apply(E,M);}};E.Env.eventAdaptors.delegate={on:function(K,J,I,L,G,M){var H="delegate:"+(E.Lang.isString(I)?I:E.stamp(I))+L+G,F=E.Array(arguments,0,true);if(!E.getEvent(H)){E.on(L,function(P){var N=P.currentTarget.queryAll(G),O=P.target,Q=false;if(N){N.each(function(S,R){if((!Q)&&(S==O)){E.fire(H,P);Q=true;}});}},I);}F[0]=H;F.splice(2,3);return E.on.apply(E,F);}};var B,A,D="window:resize",C=function(F){if(E.UA.gecko){E.fire(D,F);}else{if(A){A.cancel();}A=E.later(40,E,function(){E.fire(D,F);});}};E.Env.eventAdaptors.windowresize={on:function(H,G){if(!B){B=E.on("resize",C);}var F=E.Array(arguments,0,true);F[0]=D;return E.on.apply(E,F);}};},"@VERSION@");