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