event-custom-min.js revision 30b21a3d9ff745a71ec2a53e31cd2ec9abc68161
YUI.add("event-custom",function(G){G.Env.evt={handles:{},plugins:{}};(function(){var H=0,I=1;G.Do={objs:{},before:function(K,M,N,O){var L=K,J;if(O){J=[K,O].concat(G.Array(arguments,4,true));L=G.rbind.apply(G,J);}return this._inject(H,L,M,N);},after:function(K,M,N,O){var L=K,J;if(O){J=[K,O].concat(G.Array(arguments,4,true));L=G.rbind.apply(G,J);}return this._inject(I,L,M,N);},_inject:function(J,L,M,O){var P=G.stamp(M),N,K;if(!this.objs[P]){this.objs[P]={};}N=this.objs[P];if(!N[O]){N[O]=new G.Do.Method(M,O);M[O]=function(){return N[O].exec.apply(N[O],arguments);};}K=P+G.stamp(L)+O;N[O].register(K,L,J);return new G.EventHandle(N[O],K);},detach:function(J){if(J.detach){J.detach();}},_unload:function(K,J){}};G.Do.Method=function(J,K){this.obj=J;this.methodName=K;this.method=J[K];this.before={};this.after={};};G.Do.Method.prototype.register=function(K,L,J){if(J){this.after[K]=L;}else{this.before[K]=L;}};G.Do.Method.prototype._delete=function(J){delete this.before[J];delete this.after[J];};G.Do.Method.prototype.exec=function(){var L=G.Array(arguments,0,true),M,K,P,N=this.before,J=this.after,O=false;for(M in N){if(N.hasOwnProperty(M)){K=N[M].apply(this.obj,L);if(K){switch(K.constructor){case G.Do.Halt:return K.retVal;case G.Do.AlterArgs:L=K.newArgs;break;case G.Do.Prevent:O=true;break;default:}}}}if(!O){K=this.method.apply(this.obj,L);}for(M in J){if(J.hasOwnProperty(M)){P=J[M].apply(this.obj,L);if(P&&P.constructor==G.Do.Halt){return P.retVal;}else{if(P&&P.constructor==G.Do.AlterReturn){K=P.newRetVal;}}}}return K;};G.Do.AlterArgs=function(K,J){this.msg=K;this.newArgs=J;};G.Do.AlterReturn=function(K,J){this.msg=K;this.newRetVal=J;};G.Do.Halt=function(K,J){this.msg=K;this.retVal=J;};G.Do.Prevent=function(J){this.msg=J;};G.Do.Error=G.Do.Halt;})();(function(){G.EventFacade=function(I,H){I=I||{};this.details=I.details;this.type=I.type;this.target=I.target;this.currentTarget=H;this.relatedTarget=I.relatedTarget;this.stopPropagation=function(){I.stopPropagation();};this.stopImmediatePropagation=function(){I.stopImmediatePropagation();};this.preventDefault=function(){I.preventDefault();};this.halt=function(J){I.halt(J);};};})();var F="after",C=["broadcast","bubbles","context","contextFn","configured","currentTarget","defaultFn","details","emitFacade","fireOnce","host","preventable","preventedFn","queuable","silent","stoppedFn","target","type"],A=new G.EventFacade(),D=G.Object.keys(A),E=9,B="yui:log";G.EventHandle=function(H,I){this.evt=H;this.sub=I;};G.EventHandle.prototype={detach:function(){if(this.evt){this.evt._delete(this.sub);}}};G.CustomEvent=function(H,I){I=I||{};this.id=G.stamp(this);this.type=H;this.context=G;this.logSystem=(H==B);this.silent=this.logSystem;this.subscribers={};this.afters={};this.preventable=true;this.bubbles=true;this.signature=E;this.applyConfig(I,true);};G.CustomEvent.prototype={_YUI_EVENT:true,applyConfig:function(I,H){if(I){G.mix(this,I,H,C);}},_on:function(L,J,I,H){if(!L){G.error("Invalid callback for CE: "+this.type);}var K=new G.Subscriber(L,J,I,H);if(this.fireOnce&&this.fired){G.later(0,this,this._notify,K);}if(H==F){this.afters[K.id]=K;this.hasAfters=true;}else{this.subscribers[K.id]=K;this.hasSubscribers=true;}return new G.EventHandle(this,K);},subscribe:function(J,I){var H=(arguments.length>2)?G.Array(arguments,2,true):null;return this._on(J,I,H,true);},on:function(J,I){var H=(arguments.length>2)?G.Array(arguments,2,true):null;return this._on(J,I,H,true);},after:function(J,I){var H=(arguments.length>2)?G.Array(arguments,2,true):null;return this._on(J,I,H,F);},detach:function(L,J){if(L&&L.detach){return L.detach();}if(!L){return this.unsubscribeAll();}var M=false,I=this.subscribers,H,K;for(H in I){if(I.hasOwnProperty(H)){K=I[H];if(K&&K.contains(L,J)){this._delete(K);M=true;}}}return M;},unsubscribe:function(){return this.detach.apply(this,arguments);},_getFacade:function(){var H=this._facade,K,I=this.details,J;if(!H){H=new G.EventFacade(this,this.currentTarget);}K=I&&I[0];if(G.Lang.isObject(K,true)){J={};G.mix(J,H,true,D);G.mix(H,K,true);G.mix(H,J,true,D);}H.details=this.details;H.target=this.target;H.currentTarget=this.currentTarget;H.stopped=0;H.prevented=0;this._facade=H;return this._facade;},_notify:function(K,J,H){this.log(this.type+"->"+": "+K);var I;if(this.emitFacade){if(!H){H=this._getFacade(J);if(G.Lang.isObject(J[0])){J[0]=H;}else{J.unshift(H);}}}I=K.notify(J,this);if(false===I||this.stopped>1){this.log(this.type+" cancelled by subscriber");return false;}return true;},log:function(I,H){if(!this.silent){}},fire:function(){var Q=G.Env._eventstack,J,S,P,K,L,H,M,I,N,O=true,R;if(Q){if(this.queuable&&this.type!=Q.next.type){this.log("queue "+this.type);Q.queue.push([this,arguments]);return true;}}else{G.Env._eventstack={id:this.id,next:this,silent:this.silent,logging:(this.type===B),stopped:0,prevented:0,queue:[]};Q=G.Env._eventstack;}if(this.fireOnce&&this.fired){this.log("fireOnce event: "+this.type+" already fired");}else{P=G.Array(arguments,0,true);this.stopped=0;this.prevented=0;this.target=this.target||this.host;R=new G.EventTarget({fireOnce:true,context:this.host});this.events=R;if(this.preventedFn){R.on("prevented",this.preventedFn);}if(this.stoppedFn){R.on("stopped",this.stoppedFn);}this.currentTarget=this.host||this.currentTarget;this.fired=true;this.details=P.slice();this.log("Firing "+this.type);N=false;Q.lastLogState=Q.logging;L=null;if(this.emitFacade){this._facade=null;L=this._getFacade(P);if(G.Lang.isObject(P[0])){P[0]=L;}else{P.unshift(L);}}if(this.hasSubscribers){J=G.merge(this.subscribers);for(K in J){if(J.hasOwnProperty(K)){if(!N){Q.logging=(Q.logging||(this.type===B));N=true;}if(this.stopped==2){break;}S=J[K];if(S&&S.fn){O=this._notify(S,P,L);if(false===O){this.stopped=2;}}}}}Q.logging=(Q.lastLogState);if(this.bubbles&&this.host&&!this.stopped){Q.stopped=0;Q.prevented=0;O=this.host.bubble(this);this.stopped=Math.max(this.stopped,Q.stopped);this.prevented=Math.max(this.prevented,Q.prevented);}if(this.defaultFn&&!this.prevented){this.defaultFn.apply(this.host||this,P);
}if(!this.stopped&&this.broadcast){if(this.host!==G){G.fire.apply(G,P);}if(this.broadcast==2){G.Global.fire.apply(G.Global,P);}}if(this.hasAfters&&!this.prevented&&this.stopped<2){J=G.merge(this.afters);for(K in J){if(J.hasOwnProperty(K)){if(!N){Q.logging=(Q.logging||(this.type===B));N=true;}if(this.stopped==2){break;}S=J[K];if(S&&S.fn){O=this._notify(S,P,L);if(false===O){this.stopped=2;}}}}}}if(Q.id===this.id){M=Q.queue;while(M.length){H=M.pop();I=H[0];Q.stopped=0;Q.prevented=0;Q.next=I;O=I.fire.apply(I,H[1]);}G.Env._eventstack=null;}return this.stopped?false:true;},unsubscribeAll:function(){return this.detachAll.apply(this,arguments);},detachAll:function(){var J=this.subscribers,I,H=0;for(I in J){if(J.hasOwnProperty(I)){this._delete(J[I]);H++;}}this.subscribers={};return H;},_delete:function(H){if(H){delete H.fn;delete H.context;delete this.subscribers[H.id];delete this.afters[H.id];}},toString:function(){return this.type;},stopPropagation:function(){this.stopped=1;G.Env._eventstack.stopped=1;this.events.fire("stopped",this);},stopImmediatePropagation:function(){this.stopped=2;G.Env._eventstack.stopped=2;this.events.fire("stopped",this);},preventDefault:function(){if(this.preventable){this.prevented=1;G.Env._eventstack.prevented=1;this.events.fire("prevented",this);}},halt:function(H){if(H){this.stopImmediatePropagation();}else{this.stopPropagation();}this.preventDefault();}};G.Subscriber=function(J,I,H){this.fn=J;this.context=I;this.id=G.stamp(this);this.args=H;this.events=null;};G.Subscriber.prototype={_notify:function(L,J,K){var H=this.args,I;switch(K.signature){case 0:I=this.fn.call(L,K.type,J,L);break;case 1:I=this.fn.call(L,J[0]||null,L);break;default:if(H||J){J=J||[];H=(H)?J.concat(H):J;I=this.fn.apply(L,H);}else{I=this.fn.call(L);}}return I;},notify:function(I,K){var L=this.context,H=true;if(!L){L=(K.contextFn)?K.contextFn():K.context;}if(G.config.throwFail){H=this._notify(L,I,K);}else{try{H=this._notify(L,I,K);}catch(J){G.error(this+" failed: "+J.message,J);}}return H;},contains:function(I,H){if(H){return((this.fn==I)&&this.context==H);}else{return(this.fn==I);}},toString:function(){return"Subscriber "+this.id;}};(function(){var H=G.Lang,J=":",K="|",M="~AFTER~",N=G.cached(function(L,P){if(!P||!H.isString(L)||L.indexOf(J)>-1){return L;}return P+J+L;}),I=G.cached(function(Q,T){var P=Q,R,U,L,S;if(!H.isString(P)){return P;}L=P.indexOf(M);if(L>-1){U=true;P=P.substr(M.length);}L=P.indexOf(K);if(L>-1){R=P.substr(0,(L));P=P.substr(L+1);if(P=="*"){P=null;}}S=N(P,T);return[R,S,U,P];}),O=function(L){var P=(H.isObject(L))?L:{};this._yuievt={id:G.guid(),events:{},targets:{},config:P,chain:("chain" in P)?P.chain:G.config.chain,defaults:{context:P.context||this,host:this,emitFacade:P.emitFacade,fireOnce:P.fireOnce,queuable:P.queuable,broadcast:P.broadcast,bubbles:("bubbles" in P)?P.bubbles:true}};};O.prototype={on:function(S,V,Q,W){var a=I(S,this._yuievt.config.prefix),b,d,P,h,Y,X,e,T=G.Env.evt.handles,R,L,U,g=G.Node,Z;if(H.isObject(S,true)){b=V;d=Q;P=G.Array(arguments,0,true);h={};R=S._after;delete S._after;G.each(S,function(f,c){if(f){b=f.fn||((G.Lang.isFunction(f))?f:b);d=f.context||d;}P[0]=(R)?M+c:c;P[1]=b;P[2]=d;h[c]=this.on.apply(this,P);},this);return(this._yuievt.chain)?this:h;}else{if(H.isFunction(S)){return G.Do.before.apply(G.Do,arguments);}}X=a[0];R=a[2];U=a[3];if(g&&(this instanceof g)&&(U in g.DOM_EVENTS)){P=G.Array(arguments,0,true);P.splice(2,0,g.getDOMNode(this));return G.on.apply(G,P);}S=a[1];if(this instanceof YUI){L=G.Env.evt.plugins[S];P=G.Array(arguments,0,true);P[0]=U;Z=P[2];if(L&&L.on){if(g&&Z&&(Z instanceof g)){P[2]=g.getDOMNode(Z);}e=L.on.apply(G,P);}else{if((!S)||(!L&&g&&(U in g.DOM_EVENTS))){if(Z instanceof g){P[2]=g.getDOMNode(Z);}e=G.Event._attach(P);}}}if(!e){Y=this._yuievt.events[S]||this.publish(S);e=Y._on(V,Q,(arguments.length>3)?G.Array(arguments,3,true):null,(R)?"after":true);}if(X){T[X]=T[X]||{};T[X][S]=T[X][S]||[];T[X][S].push(e);}return(this._yuievt.chain)?this:e;},subscribe:function(){return this.on.apply(this,arguments);},detach:function(Y,a,L){var R=I(Y,this._yuievt.config.prefix),X=H.isArray(R)?R[0]:null,d=(R)?R[3]:null,T,U,b=G.Env.evt.handles,Z,W,c=this._yuievt.events,Q,S,V=true,P=function(g,f){var e=g[f];if(e){while(e.length){T=e.pop();T.detach();}}};if(X){Z=b[X];Y=R[1];if(Z){if(Y){P(Z,Y);}else{for(S in Z){if(Z.hasOwnProperty(S)){P(Z,S);}}}return(this._yuievt.chain)?this:true;}}else{if(H.isObject(Y)&&Y.detach){V=Y.detach();return(this._yuievt.chain)?this:true;}else{if(G.Node&&(this instanceof G.Node)&&((!d)||(d in G.Node.DOM_EVENTS))){W=G.Array(arguments,0,true);W[2]=G.Node.getDOMNode(this);return G.detach.apply(G,W);}}}U=G.Env.evt.plugins[d];if(this instanceof YUI){W=G.Array(arguments,0,true);if(U&&U.detach){return U.detach.apply(G,W);}else{if(!Y||(!U&&Y.indexOf(":")==-1)){W[0]=Y;return G.Event.detach.apply(G.Event,W);}}}if(Y){Q=c[Y];if(Q){return Q.detach(a,L);}}else{for(S in c){if(c.hasOwnProperty(S)){V=V&&c[S].detach(a,L);}}return V;}return(this._yuievt.chain)?this:false;},unsubscribe:function(){return this.detach.apply(this,arguments);},detachAll:function(L){L=N(L,this._yuievt.config.prefix);return this.detach(L);},unsubscribeAll:function(){return this.detachAll.apply(this,arguments);},publish:function(Q,R){Q=N(Q,this._yuievt.config.prefix);var P,S,L,T;if(H.isObject(Q)){L={};G.each(Q,function(V,U){L[U]=this.publish(U,V||R);},this);return L;}P=this._yuievt.events;S=P[Q];if(S){if(R){S.applyConfig(R,true);}}else{T=(R)?G.mix(R,this._yuievt.defaults):this._yuievt.defaults;S=new G.CustomEvent(Q,T);P[Q]=S;}if(R instanceof G.CustomEvent){P[Q].broadcast=false;}return P[Q];},addTarget:function(L){this._yuievt.targets[G.stamp(L)]=L;this._yuievt.hasTargets=true;},removeTarget:function(L){delete this._yuievt.targets[G.stamp(L)];},fire:function(R){var T=H.isString(R),Q=(T)?R:(R&&R.type),S,L,P;Q=N(Q,this._yuievt.config.prefix);S=this.getEvent(Q);if(!S){if(this._yuievt.hasTargets){L=(T)?arguments:G.Array(arguments,0,true).unshift(Q);return this.bubble(null,L,this);
}P=true;}else{L=G.Array(arguments,(T)?1:0,true);P=S.fire.apply(S,L);S.target=null;}return(this._yuievt.chain)?this:P;},getEvent:function(L){L=N(L,this._yuievt.config.prefix);var P=this._yuievt.events;return(P&&L in P)?P[L]:null;},bubble:function(V,T,R){var Q=this._yuievt.targets,S=true,W,U,L,P;if(!V||((!V.stopped)&&Q)){for(P in Q){if(Q.hasOwnProperty(P)){W=Q[P];U=V&&V.type;L=W.getEvent(U);if(!L){if(W._yuievt.hasTargets){W.bubble.call(W,V,T,R);}}else{L.target=R||(V&&V.target)||this;L.currentTarget=W;S=S&&L.fire.apply(L,T||V.details);if(L.stopped){break;}}}}}return S;},after:function(Q,P){var L=G.Array(arguments,0,true);switch(H.type(Q)){case"function":return G.Do.after.apply(G.Do,arguments);case"object":L[0]._after=true;break;default:L[0]=M+Q;}return this.on.apply(this,L);},before:function(){return this.on.apply(this,arguments);}};G.EventTarget=O;G.mix(G,O.prototype,false,false,{bubbles:false});O.call(G);YUI.Env.globalEvents=YUI.Env.globalEvents||new O();G.Global=YUI.Env.globalEvents;})();},"@VERSION@",{requires:["oop"]});