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