event-custom-min.js revision 5af2618af73bd3f008ef0e9b5f982f560c64059b
YUI.add("event-custom",function(E){(function(){var F=E.Lang,G=E.after;E.Env.eventAdaptors={};E.on=function(I,J,K){var H=E.Env.eventAdaptors[I];if(H&&H.on){return H.on.apply(E,arguments);}else{if(H||I.indexOf(":")>-1){return E.subscribe.apply(E,arguments);}else{return E.Event.attach.apply(E.Event,arguments);}}};E.detach=function(I,J,K){var H=E.Env.eventAdaptors[I];if(F.isObject(I)&&I.detach){return I.detach();}else{if(H&&H.detach){return H.detach.apply(E,arguments);}else{if(H||I.indexOf(":")>-1){return E.unsubscribe.apply(E,arguments);}else{return E.Event.detach.apply(E.Event,arguments);}}}};E.before=function(H,I,J){if(F.isFunction(H)){return E.Do.before.apply(E.Do,arguments);}else{return E.on.apply(E,arguments);}};E.after=function(H,I,J){if(F.isFunction(H)){return E.Do.after.apply(E.Do,arguments);}else{return G.apply(E,arguments);}};})();(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 B="_event:onsub",D="after",A=["broadcast","bubbles","context","configured","currentTarget","defaultFn","details","emitFacade","fireOnce","host","preventable","preventedFn","queuable","silent","stoppedFn","target","type"],C=9;E.EventHandle=function(F,G){this.evt=F;this.sub=G;};E.EventHandle.prototype={detach:function(){if(this.evt){this.evt._delete(this.sub);}}};E.CustomEvent=function(F,G){G=G||{};this.id=E.stamp(this);this.type=F;this.context=E;this.logSystem=(F=="yui:log");this.broadcast=0;this.silent=this.logSystem;this.queuable=false;this.subscribers={};this.afters={};this.fired=false;this.fireOnce=false;this.stopped=0;this.prevented=0;this.host=null;this.defaultFn=null;this.stoppedFn=null;this.preventedFn=null;this.preventable=true;this.bubbles=true;this.signature=C;this.emitFacade=false;this.applyConfig(G,true);this.log("Creating "+this.type);if(F!==B){this.subscribeEvent=new E.CustomEvent(B,{context:this,silent:true});}};E.CustomEvent.prototype={_YUI_EVENT:true,applyConfig:function(G,F){if(G){E.mix(this,G,F,A);}},_subscribe:function(J,H,G,F){if(!J){E.error("Invalid callback for CE: "+this.type);}var K=this.subscribeEvent,I;if(K){K.fire.apply(K,G);}I=new E.Subscriber(J,H,G,F);if(this.fireOnce&&this.fired){E.later(0,this,this._notify,I);}if(F==D){this.afters[I.id]=I;}else{this.subscribers[I.id]=I;}return new E.EventHandle(this,I);},subscribe:function(G,F){return this._subscribe(G,F,arguments,true);},after:function(G,F){return this._subscribe(G,F,arguments,D);},unsubscribe:function(J,H){if(J&&J.detach){return J.detach();}if(!J){return this.unsubscribeAll();}var K=false,G=this.subscribers,F,I;for(F in G){if(G.hasOwnProperty(F)){I=G[F];if(I&&I.contains(J,H)){this._delete(I);K=true;}}}return K;},_getFacade:function(G){var F=this._facade,H;if(!F){F=new E.EventFacade(this,this.currentTarget);}H=G&&G[0];if(E.Lang.isObject(H,true)&&!H._yuifacade){E.mix(F,H,true);}F.details=this.details;F.target=this.target;F.currentTarget=this.currentTarget;F.stopped=0;F.prevented=0;this._facade=F;return this._facade;},_notify:function(J,H,F){this.log(this.type+"->"+": "+J);var G,I;if(this.emitFacade){if(!F){F=this._getFacade(H);H[0]=F;}}I=(H&&E.Lang.isObject(H[0])&&H[0].currentTarget);G=J.notify(I||this.context,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(){var O=E.Env._eventstack,H,P,N,I,J,F,K,G,L,M=true;if(O){if(this.queuable&&this.type!=O.next.type){this.log("queue "+this.type);O.queue.push([this,arguments]);return true;}}else{E.Env._eventstack={id:this.id,next:this,silent:this.silent,logging:(this.type==="yui:log"),stopped:0,prevented:0,queue:[]};O=E.Env._eventstack;}if(this.fireOnce&&this.fired){this.log("fireOnce event: "+this.type+" already fired");}else{H=E.merge(this.subscribers);N=E.Array(arguments,0,true);this.stopped=0;this.prevented=0;this.target=this.target||this.host;this.currentTarget=this.host||this.currentTarget;this.fired=true;this.details=N.slice();this.log("Firing "+this.type);L=false;O.lastLogState=O.logging;J=null;if(this.emitFacade){this._facade=null;J=this._getFacade(N);N[0]=J;}for(I in H){if(H.hasOwnProperty(I)){if(!L){O.logging=(O.logging||(this.type==="yui:log"));L=true;}if(this.stopped==2){break;}P=H[I];if(P&&P.fn){M=this._notify(P,N,J);if(false===M){this.stopped=2;}}}}O.logging=(O.lastLogState);if(this.bubbles&&this.host&&!this.stopped){O.stopped=0;O.prevented=0;
M=this.host.bubble(this);this.stopped=Math.max(this.stopped,O.stopped);this.prevented=Math.max(this.prevented,O.prevented);}if(this.defaultFn&&!this.prevented){this.defaultFn.apply(this.host||this,N);}if(!this.prevented&&this.stopped<2){H=E.merge(this.afters);for(I in H){if(H.hasOwnProperty(I)){if(!L){O.logging=(O.logging||(this.type==="yui:log"));L=true;}if(this.stopped==2){break;}P=H[I];if(P&&P.fn){M=this._notify(P,N,J);if(false===M){this.stopped=2;}}}}}}if(O.id===this.id){K=O.queue;while(K.length){F=K.pop();G=F[0];O.stopped=0;O.prevented=0;O.next=G;M=G.fire.apply(G,F[1]);}E.Env._eventstack=null;}return(M!==false);},unsubscribeAll:function(){var H=this.subscribers,G,F=0;for(G in H){if(H.hasOwnProperty(G)){this._delete(H[G]);F++;}}this.subscribers={};return F;},_delete:function(F){if(F){delete F.fn;delete F.context;delete this.subscribers[F.id];delete this.afters[F.id];}},toString:function(){return this.type;},stopPropagation:function(){this.stopped=1;E.Env._eventstack.stopped=1;if(this.stoppedFn){this.stoppedFn.call(this.host||this,this);}},stopImmediatePropagation:function(){this.stopped=2;E.Env._eventstack.stopped=2;if(this.stoppedFn){this.stoppedFn.call(this.host||this,this);}},preventDefault:function(){if(this.preventable){this.prevented=1;E.Env._eventstack.prevented=1;}if(this.preventedFn){this.preventedFn.call(this.host||this,this);}}};E.Subscriber=function(H,G,F){this.fn=H;this.context=G;this.id=E.stamp(this);this.wrappedFn=H;if(G){this.wrappedFn=E.rbind.apply(E,F);}};E.Subscriber.prototype={notify:function(F,H,K){var L=this.context||F,G=true,I=function(){switch(K.signature){case 0:G=this.fn.call(L,K.type,H,this.context);break;case 1:G=this.fn.call(L,H[0]||null,this.context);break;default:G=this.wrappedFn.apply(L,H||[]);}};if(E.config.throwFail){I.call(this);}else{try{I.call(this);}catch(J){E.error(this+" failed: "+J.message,J);}}return G;},contains:function(G,F){if(F){return((this.fn==G)&&this.context==F);}else{return(this.fn==G);}},toString:function(){return"Subscriber "+this.id;}};(function(){var F=E.Lang,G=function(H){var I=(F.isObject(H))?H:{};this._yuievt={events:{},targets:{},config:I,defaults:{context:this,host:this,emitFacade:I.emitFacade||false,bubbles:("bubbles" in I)?I.bubbles:true}};};G.prototype={subscribe:function(L,K,J){var M,O,I,H,N;if(F.isObject(L)){M=K;O=J;I=E.Array(arguments,0,true);H={};E.each(L,function(Q,P){if(Q){M=Q.fn||M;O=Q.context||O;}I[0]=P;I[1]=M;I[2]=O;H[P]=this.subscribe.apply(this,I);},this);return H;}N=this._yuievt.events[L]||this.publish(L);I=E.Array(arguments,1,true);return N.subscribe.apply(N,I);},unsubscribe:function(M,L,K){if(F.isObject(M)&&M.detach){return M.detach();}var H=this._yuievt.events,N,J,I=true;if(M){N=H[M];if(N){return N.unsubscribe(L,K);}}else{for(J in H){if(H.hasOwnProperty(J)){I=I&&H[J].unsubscribe(L,K);}}return I;}return false;},unsubscribeAll:function(H){return this.unsubscribe(H);},publish:function(J,K){var I,L,H,M;if(F.isObject(J)){H={};E.each(J,function(O,N){H[N]=this.publish(N,O||K);},this);return H;}I=this._yuievt.events;L=I[J];if(L){L.applyConfig(K,true);}else{M=K||{};E.mix(M,this._yuievt.defaults);L=new E.CustomEvent(J,M);I[J]=L;if(M.onSubscribeCallback){L.subscribeEvent.subscribe(M.onSubscribeCallback);}}return I[J];},addTarget:function(H){this._yuievt.targets[E.stamp(H)]=H;this._yuievt.hasTargets=true;},removeTarget:function(H){delete this._yuievt.targets[E.stamp(H)];},fire:function(K){var M=F.isString(K),J=(M)?K:(K&&K.type),L=this.getEvent(J),H,I;if(!L){if(this._yuievt.hasTargets){L=this.publish(J);L.details=E.Array(arguments,(M)?1:0,true);return this.bubble(L);}return true;}H=E.Array(arguments,(M)?1:0,true);I=L.fire.apply(L,H);L.target=null;return I;},getEvent:function(H){var I=this._yuievt.events;return(I&&H in I)?I[H]:null;},bubble:function(I){var N=this._yuievt.targets,J=true,L,M,O,H,K;if(!I.stopped&&N){for(K in N){if(N.hasOwnProperty(K)){L=N[K];M=I.type;O=L.getEvent(M);H=I.target||this;if(!O){O=L.publish(M,I);O.context=(I.host===I.context)?L:I.context;O.host=L;O.defaultFn=null;O.preventedFn=null;O.stoppedFn=null;}O.target=H;O.currentTarget=L;J=J&&O.fire.apply(O,I.details);if(O.stopped){break;}}}}return J;},after:function(J,I){if(F.isFunction(J)){return E.Do.after.apply(E.Do,arguments);}else{var K=this._yuievt.events[J]||this.publish(J),H=E.Array(arguments,1,true);return K.after.apply(K,H);}},before:function(I,H){if(F.isFunction(I)){return E.Do.after.apply(E.Do,arguments);}else{return this.subscribe.apply(this,arguments);}}};E.EventTarget=G;E.mix(E,G.prototype,false,false,{bubbles:false});G.call(E);})();(function(){var H={"altKey":1,"cancelBubble":1,"ctrlKey":1,"clientX":1,"clientY":1,"detail":1,"keyCode":1,"metaKey":1,"shiftKey":1,"type":1,"x":1,"y":1},G=E.UA,F={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9},I=function(K){if(!K){return null;}try{if(G.webkit&&3==K.nodeType){K=K.parentNode;}}catch(J){}return E.Node.get(K);};E.EventFacade=function(T,L,K,J){var P=T,N=L,Q=E.config.doc,U=Q.body,V=P.pageX,S=P.pageY,M=(T._YUI_EVENT),O,R,W;for(O in H){if(H.hasOwnProperty(O)){this[O]=P[O];}}if(!V&&0!==V){V=P.clientX||0;S=P.clientY||0;if(G.ie){V+=Math.max(Q.documentElement.scrollLeft,U.scrollLeft);S+=Math.max(Q.documentElement.scrollTop,U.scrollTop);}}this._yuifacade=true;this.pageX=V;this.pageY=S;R=P.keyCode||P.charCode||0;if(G.webkit&&(R in F)){R=F[R];}this.keyCode=R;this.charCode=R;this.button=P.which||P.button;this.which=this.button;this.details=J;this.time=P.time||new Date().getTime();this.target=(M)?P.target:I(P.target||P.srcElement);this.currentTarget=(M)?N:I(N);W=P.relatedTarget;if(!W){if(P.type=="mouseout"){W=P.toElement;}else{if(P.type=="mouseover"){W=P.fromElement;}}}this.relatedTarget=(M)?W:I(W);this.stopPropagation=function(){if(P.stopPropagation){P.stopPropagation();}else{P.cancelBubble=true;}if(K){K.stopPropagation();}};this.stopImmediatePropagation=function(){if(P.stopImmediatePropagation){P.stopImmediatePropagation();}else{this.stopPropagation();}if(K){K.stopImmediatePropagation();}};this.preventDefault=function(){if(P.preventDefault){P.preventDefault();
}else{P.returnValue=false;}if(K){K.preventDefault();}};this.halt=function(X){if(X){this.stopImmediatePropagation();}else{this.stopPropagation();}this.preventDefault();};};})();},"@VERSION@");