event-min.js revision 1aaea0dfa7ac4cfd069af68144b0d2314953cf17
var GLOBAL_ENV=YUI.Env;if(!GLOBAL_ENV._ready){GLOBAL_ENV._ready=function(){GLOBAL_ENV.DOMReady=true;GLOBAL_ENV.remove(YUI.config.doc,"DOMContentLoaded",GLOBAL_ENV._ready);};GLOBAL_ENV.add(YUI.config.doc,"DOMContentLoaded",GLOBAL_ENV._ready);}YUI.add("event-base",function(e){e.publish("domready",{fireOnce:true,async:true});if(GLOBAL_ENV.DOMReady){e.fire("domready");}else{e.Do.before(function(){e.fire("domready");},YUI.Env,"_ready");}var b=e.UA,d={},a={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9,63272:46,63273:36,63275:35},c=function(h){if(!h){return h;}try{if(h&&3==h.nodeType){h=h.parentNode;}}catch(g){return null;}return e.one(h);},f=function(g,h,i){this._event=g;this._currentTarget=h;this._wrapper=i||d;this.init();};e.extend(f,Object,{init:function(){var i=this._event,j=this._wrapper.overrides,g=i.pageX,l=i.pageY,k,h=this._currentTarget;this.altKey=i.altKey;this.ctrlKey=i.ctrlKey;this.metaKey=i.metaKey;this.shiftKey=i.shiftKey;this.type=(j&&j.type)||i.type;this.clientX=i.clientX;this.clientY=i.clientY;this.pageX=g;this.pageY=l;k=i.keyCode||i.charCode;if(b.webkit&&(k in a)){k=a[k];}this.keyCode=k;this.charCode=k;this.which=i.which||i.charCode||k;this.button=this.which;this.target=c(i.target);this.currentTarget=c(h);this.relatedTarget=c(i.relatedTarget);if(i.type=="mousewheel"||i.type=="DOMMouseScroll"){this.wheelDelta=(i.detail)?(i.detail*-1):Math.round(i.wheelDelta/80)||((i.wheelDelta<0)?-1:1);}if(this._touch){this._touch(i,h,this._wrapper);}},stopPropagation:function(){this._event.stopPropagation();this._wrapper.stopped=1;this.stopped=1;},stopImmediatePropagation:function(){var g=this._event;if(g.stopImmediatePropagation){g.stopImmediatePropagation();}else{this.stopPropagation();}this._wrapper.stopped=2;this.stopped=2;},preventDefault:function(g){var h=this._event;h.preventDefault();h.returnValue=g||false;this._wrapper.prevented=1;this.prevented=1;},halt:function(g){if(g){this.stopImmediatePropagation();}else{this.stopPropagation();}this.preventDefault();}});f.resolve=c;e.DOM2EventFacade=f;e.DOMEventFacade=f;(function(){e.Env.evt.dom_wrappers={};e.Env.evt.dom_map={};var q=e.Env.evt,i=e.config,n=i.win,s=YUI.Env.add,l=YUI.Env.remove,p=function(){YUI.Env.windowLoaded=true;e.Event._load();l(n,"load",p);},g=function(){e.Event._unload();},j="domready",m="~yui|2|compat~",o=function(u){try{return(u&&typeof u!=="string"&&e.Lang.isNumber(u.length)&&!u.tagName&&!u.alert);}catch(t){return false;}},h=e.CustomEvent.prototype._delete,k=function(u){var t=h.apply(this,arguments);if(!this.subCount&&!this.afterCount){e.Event._clean(this);}return t;},r=function(){var v=false,w=0,u=[],x=q.dom_wrappers,t=null,y=q.dom_map;return{POLL_RETRYS:1000,POLL_INTERVAL:40,lastError:null,_interval:null,_dri:null,DOMReady:false,startInterval:function(){if(!r._interval){r._interval=setInterval(r._poll,r.POLL_INTERVAL);}},onAvailable:function(z,D,H,A,E,G){var F=e.Array(z),B,C;for(B=0;B<F.length;B=B+1){u.push({id:F[B],fn:D,obj:H,override:A,checkReady:E,compat:G});}w=this.POLL_RETRYS;setTimeout(r._poll,0);C=new e.EventHandle({_delete:function(){if(C.handle){C.handle.detach();return;}var J,I;for(J=0;J<F.length;J++){for(I=0;I<u.length;I++){if(F[J]===u[I].id){u.splice(I,1);}}}}});return C;},onContentReady:function(D,B,C,A,z){return r.onAvailable(D,B,C,A,true,z);},attach:function(C,B,A,z){return r._attach(e.Array(arguments,0,true));},_createWrapper:function(F,E,z,A,D){var C,G=e.stamp(F),B="event:"+G+E;if(false===D){B+="native";}if(z){B+="capture";}C=x[B];if(!C){C=e.publish(B,{silent:true,bubbles:false,contextFn:function(){if(A){return C.el;}else{C.nodeRef=C.nodeRef||e.one(C.el);return C.nodeRef;}}});C.overrides={};C.el=F;C.key=B;C.domkey=G;C.type=E;C.fn=function(H){C.fire(r.getEvent(H,F,(A||(false===D))));};C.capture=z;if(F==n&&E=="load"){C.fireOnce=true;t=B;}C._delete=k;x[B]=C;y[G]=y[G]||{};y[G][B]=C;s(F,E,C.fn,z);}return C;},_attach:function(F,E){var K,M,C,J,z,B=false,D,G=F[0],H=F[1],A=F[2]||n,N=E&&E.facade,L=E&&E.capture,I=E&&E.overrides;if(F[F.length-1]===m){K=true;}if(!H||!H.call){return false;}if(o(A)){M=[];e.each(A,function(P,O){F[2]=P;M.push(r._attach(F,E));});return new e.EventHandle(M);}else{if(e.Lang.isString(A)){if(K){C=e.DOM.byId(A);}else{C=e.Selector.query(A);switch(C.length){case 0:C=null;break;case 1:C=C[0];break;default:F[2]=C;return r._attach(F,E);}}if(C){A=C;}else{D=r.onAvailable(A,function(){D.handle=r._attach(F,E);},r,true,false,K);return D;}}}if(!A){return false;}if(e.Node&&e.instanceOf(A,e.Node)){A=e.Node.getDOMNode(A);}J=r._createWrapper(A,G,L,K,N);if(I){e.mix(J.overrides,I);}if(A==n&&G=="load"){if(YUI.Env.windowLoaded){B=true;}}if(K){F.pop();}z=F[3];D=J._on(H,z,(F.length>4)?F.slice(4):null);if(B){J.fire();}return D;},detach:function(G,H,B,E){var F=e.Array(arguments,0,true),J,C,I,D,z,A;if(F[F.length-1]===m){J=true;}if(G&&G.detach){return G.detach();}if(typeof B=="string"){if(J){B=e.DOM.byId(B);}else{B=e.Selector.query(B);C=B.length;if(C<1){B=null;}else{if(C==1){B=B[0];}}}}if(!B){return false;}if(B.detach){F.splice(2,1);return B.detach.apply(B,F);}else{if(o(B)){I=true;for(D=0,C=B.length;D<C;++D){F[2]=B[D];I=(e.Event.detach.apply(e.Event,F)&&I);}return I;}}if(!G||!H||!H.call){return r.purgeElement(B,false,G);}z="event:"+e.stamp(B)+G;A=x[z];if(A){return A.detach(H);}else{return false;}},getEvent:function(C,A,z){var B=C||n.event;return(z)?B:new e.DOMEventFacade(B,A,x["event:"+e.stamp(A)+C.type]);},generateId:function(z){return e.DOM.generateID(z);},_isValidCollection:o,_load:function(z){if(!v){v=true;if(e.fire){e.fire(j);}r._poll();}},_poll:function(){if(r.locked){return;}if(e.UA.ie&&!YUI.Env.DOMReady){r.startInterval();return;}r.locked=true;var A,z,E,B,D,F,C=!v;if(!C){C=(w>0);}D=[];F=function(I,J){var H,G=J.override;if(J.compat){if(J.override){if(G===true){H=J.obj;}else{H=G;}}else{H=I;}J.fn.call(H,J.obj);}else{H=J.obj||e.one(I);J.fn.apply(H,(e.Lang.isArray(G))?G:[]);}};for(A=0,z=u.length;A<z;++A){E=u[A];if(E&&!E.checkReady){B=(E.compat)?e.DOM.byId(E.id):e.Selector.query(E.id,null,true);if(B){F(B,E);
u[A]=null;}else{D.push(E);}}}for(A=0,z=u.length;A<z;++A){E=u[A];if(E&&E.checkReady){B=(E.compat)?e.DOM.byId(E.id):e.Selector.query(E.id,null,true);if(B){if(v||(B.get&&B.get("nextSibling"))||B.nextSibling){F(B,E);u[A]=null;}}else{D.push(E);}}}w=(D.length===0)?0:w-1;if(C){r.startInterval();}else{clearInterval(r._interval);r._interval=null;}r.locked=false;return;},purgeElement:function(B,z,G){var E=(e.Lang.isString(B))?e.Selector.query(B,null,true):B,H=r.getListeners(E,G),D,F,C,A;if(z&&E){H=H||[];C=e.Selector.query("*",E);D=0;F=C.length;for(;D<F;++D){A=r.getListeners(C[D],G);if(A){H=H.concat(A);}}}if(H){for(D=0,F=H.length;D<F;++D){e.Event._clean(H[D]);}}},_clean:function(B){var A=B.key,z=B.domkey;B.detachAll();l(B.el,B.type,B.fn,B.capture);delete x[A];delete y[z][A];delete e._yuievt.events[A];if(!e.Object.size(y[z])){delete y[z];}},getListeners:function(D,C){var E=e.stamp(D,true),z=y[E],B=[],A=(C)?"event:"+E+C:null,F=q.plugins;if(!z){return null;}if(A){if(F[C]&&F[C].eventDef){A+="_synth";}if(z[A]){B.push(z[A]);}A+="native";if(z[A]){B.push(z[A]);}}else{e.each(z,function(H,G){B.push(H);});}return(B.length)?B:null;},_unload:function(z){e.each(x,function(B,A){if(B.type=="unload"){B.fire(z);}B.detachAll();l(B.el,B.type,B.fn,B.capture);delete x[A];delete y[B.domkey][A];});l(n,"unload",g);},nativeAdd:s,nativeRemove:l};}();e.Event=r;if(i.injected||YUI.Env.windowLoaded){p();}else{s(n,"load",p);}if(e.UA.ie){e.on(j,r._poll);}s(n,"unload",g);r.Custom=e.CustomEvent;r.Subscriber=e.Subscriber;r.Target=e.EventTarget;r.Handle=e.EventHandle;r.Facade=e.EventFacade;r._poll();})();e.Env.evt.plugins.available={on:function(i,h,k,j){var g=arguments.length>4?e.Array(arguments,4,true):null;return e.Event.onAvailable.call(e.Event,k,h,j,g);}};e.Env.evt.plugins.contentready={on:function(i,h,k,j){var g=arguments.length>4?e.Array(arguments,4,true):null;return e.Event.onContentReady.call(e.Event,k,h,j,g);}};},"@VERSION@",{requires:["event-custom-base"]});YUI.add("event-delegate",function(a){var c=a.Array,h=a.Lang,b=h.isString,i=h.isObject,e=h.isArray,g=a.Selector.test,d=a.Env.evt.handles;function f(u,w,l,k){var s=c(arguments,0,true),t=b(l)?l:null,r,o,j,n,v,m,q,x,p;if(i(u)){x=[];if(e(u)){for(m=0,q=u.length;m<q;++m){s[0]=u[m];x.push(a.delegate.apply(a,s));}}else{s.unshift(null);for(m in u){if(u.hasOwnProperty(m)){s[0]=m;s[1]=u[m];x.push(a.delegate.apply(a,s));}}}return new a.EventHandle(x);}r=u.split(/\|/);if(r.length>1){v=r.shift();s[0]=u=r.shift();}o=a.Node.DOM_EVENTS[u];if(i(o)&&o.delegate){p=o.delegate.apply(o,arguments);}if(!p){if(!u||!w||!l||!k){return;}j=(t)?a.Selector.query(t,null,true):l;if(!j&&b(l)){p=a.on("available",function(){a.mix(p,a.delegate.apply(a,s),true);},l);}if(!p&&j){s.splice(2,2,j);p=a.Event._attach(s,{facade:false});p.sub.filter=k;p.sub._notify=f.notifySub;}}if(p&&v){n=d[v]||(d[v]={});n=n[u]||(n[u]=[]);n.push(p);}return p;}f.notifySub=function(q,l,p){l=l.slice();if(this.args){l.push.apply(l,this.args);}var o=f._applyFilter(this.filter,l,p),n,m,j,k;if(o){o=c(o);n=l[0]=new a.DOMEventFacade(l[0],p.el,p);n.container=a.one(p.el);for(m=0,j=o.length;m<j&&!n.stopped;++m){n.currentTarget=a.one(o[m]);k=this.fn.apply(this.context||n.currentTarget,l);if(k===false){break;}}return k;}};f.compileFilter=a.cached(function(j){return function(l,k){return g(l._node,j,k.currentTarget._node);};});f._applyFilter=function(n,l,q){var p=l[0],j=q.el,o=p.target||p.srcElement,k=[],m=false;if(o.nodeType===3){o=o.parentNode;}l.unshift(o);if(b(n)){while(o){m=(o===j);if(g(o,n,(m?null:j))){k.push(o);}if(m){break;}o=o.parentNode;}}else{l[0]=a.one(o);l[1]=new a.DOMEventFacade(p,j,q);while(o){if(n.apply(l[0],l)){k.push(o);}if(o===j){break;}o=o.parentNode;l[0]=a.one(o);}l[1]=p;}if(k.length<=1){k=k[0];}l.shift();return k;};a.delegate=a.Event.delegate=f;},"@VERSION@",{requires:["node-base"]});YUI.add("event-synthetic",function(b){var i=b.Env.evt.dom_map,d=b.Array,h=b.Lang,k=h.isObject,c=h.isString,e=h.isArray,f=b.Selector.query,j=function(){};function g(m,l){this.handle=m;this.emitFacade=l;}g.prototype.fire=function(r){var l=d(arguments,0,true),p=this.handle,q=p.evt,n=p.sub,s=n.context,m=n.filter,o=r||{};if(this.emitFacade){if(!r||!r.preventDefault){o=q._getFacade();if(k(r)&&!r.preventDefault){b.mix(o,r,true);l[0]=o;}else{l.unshift(o);}}o.type=q.type;o.details=l.slice();if(m){o.container=q.host;}}else{if(m&&k(r)&&r.currentTarget){l.shift();}}n.context=s||o.currentTarget||q.host;q.fire.apply(q,l);n.context=s;};function a(){this._init.apply(this,arguments);}b.mix(a,{Notifier:g,getRegistry:function(r,q,o){var p=r._node,n=b.stamp(p),m="event:"+n+q+"_synth",l=i[n]||(i[n]={});if(!l[m]&&o){l[m]={type:"_synth",fn:j,capture:false,el:p,key:m,domkey:n,notifiers:[],detachAll:function(){var s=this.notifiers,t=s.length;while(--t>=0){s[t].detach();}}};}return(l[m])?l[m].notifiers:null;},_deleteSub:function(m){if(m&&m.fn){var l=this.eventDef,n=(m.filter)?"detachDelegate":"detach";this.subscribers={};this.subCount=0;l[n](m.node,m,this.notifier,m.filter);l._unregisterSub(m);delete m.fn;delete m.node;delete m.context;}},prototype:{constructor:a,_init:function(){var l=this.publishConfig||(this.publishConfig={});this.emitFacade=("emitFacade" in l)?l.emitFacade:true;l.emitFacade=false;},processArgs:j,on:j,detach:j,delegate:j,detachDelegate:j,_on:function(o,q){var p=[],m=this.processArgs(o,q),l=o[2],s=q?"delegate":"on",n,r;n=(c(l))?f(l):d(l);if(!n.length&&c(l)){r=b.on("available",function(){b.mix(r,b[s].apply(b,o),true);},l);return r;}b.Array.each(n,function(u){var v=o.slice(),t;u=b.one(u);if(u){if(q){t=v.splice(3,1)[0];}v.splice(0,4,v[1],v[3]);if(!this.preventDups||!this.getSubs(u,o,null,true)){r=this._getNotifier(u,v,m,t);this[s](u,r.sub,r.notifier,t);p.push(r);}}},this);return(p.length===1)?p[0]:new b.EventHandle(p);},_getNotifier:function(o,r,p,n){var t=new b.CustomEvent(this.type,this.publishConfig),q=t.on.apply(t,r),s=new g(q,this.emitFacade),m=a.getRegistry(o,this.type,true),l=q.sub;q.notifier=s;l.node=o;l.filter=n;if(p){this.applyArgExtras(p,l);}b.mix(t,{eventDef:this,notifier:s,host:o,currentTarget:o,target:o,el:o._node,_delete:a._deleteSub},true);
m.push(q);return q;},applyArgExtras:function(l,m){m._extra=l;},_unregisterSub:function(n){var l=a.getRegistry(n.node,this.type),m;if(l){for(m=l.length-1;m>=0;--m){if(l[m].sub===n){l.splice(m,1);break;}}}},_detach:function(n){var s=n[2],q=(c(s))?f(s):d(s),r,p,l,o,m;n.splice(2,1);for(p=0,l=q.length;p<l;++p){r=b.one(q[p]);if(r){o=this.getSubs(r,n);if(o){for(m=o.length-1;m>=0;--m){o[m].detach();}}}}},getSubs:function(m,r,l,o){var s=a.getRegistry(m,this.type),t=[],n,q,p;if(s){if(!l){l=this.subMatch;}for(n=0,q=s.length;n<q;++n){p=s[n];if(l.call(this,p.sub,r)){if(o){return p;}else{t.push(s[n]);}}}}return t.length&&t;},subMatch:function(m,l){return !l[1]||m.fn===l[1];}}},true);b.SyntheticEvent=a;b.Event.define=function(n,m,p){var o,q,l;if(m){o=(k(n))?n:b.merge({type:n},m);if(p||!b.Node.DOM_EVENTS[o.type]){q=function(){a.apply(this,arguments);};b.extend(q,a,o);l=new q();n=l.type;b.Node.DOM_EVENTS[n]=b.Env.evt.plugins[n]={eventDef:l,on:function(){return l._on(d(arguments));},delegate:function(){return l._on(d(arguments),true);},detach:function(){return l._detach(d(arguments));}};}}else{if(c(n)||e(n)){b.Array.each(d(n),function(r){b.Node.DOM_EVENTS[r]=1;});}}return l;};},"@VERSION@",{requires:["node-base","event-custom"]});YUI.add("event-mousewheel",function(c){var b="DOMMouseScroll",a=function(e){var d=c.Array(e,0,true),f;if(c.UA.gecko){d[0]=b;f=c.config.win;}else{f=c.config.doc;}if(d.length<3){d[2]=f;}else{d.splice(2,0,f);}return d;};c.Env.evt.plugins.mousewheel={on:function(){return c.Event._attach(a(arguments));},detach:function(){return c.Event.detach.apply(c.Event,a(arguments));}};},"@VERSION@",{requires:["node-base"]});YUI.add("event-mouseenter",function(c){function b(h,d){var g=h.currentTarget,f=h.relatedTarget;if(g!==f&&!g.contains(f)){d.fire(h);}}var a={proxyType:"mouseover",on:function(f,d,e){d.onHandle=f.on(this.proxyType,b,null,e);},detach:function(e,d){d.onHandle.detach();},delegate:function(g,e,f,d){e.delegateHandle=c.delegate(this.proxyType,b,g,d,null,f);},detachDelegate:function(e,d){d.delegateHandle.detach();}};c.Event.define("mouseenter",a,true);c.Event.define("mouseleave",c.merge(a,{proxyType:"mouseout"}),true);},"@VERSION@",{requires:["event-synthetic"]});YUI.add("event-key",function(a){a.Env.evt.plugins.key={on:function(e,g,b,k,c){var i=a.Array(arguments,0,true),f,j,h,d;f=k&&k.split(":");if(!k||k.indexOf(":")==-1||!f[1]){i[0]="key"+((f&&f[0])||"press");return a.on.apply(a,i);}j=f[0];h=(f[1])?f[1].split(/,|\+/):null;d=(a.Lang.isString(b)?b:a.stamp(b))+k;d=d.replace(/,/g,"_");if(!a.getEvent(d)){a.on(e+j,function(p){var q=false,m=false,n,l,o;for(n=0;n<h.length;n=n+1){l=h[n];o=parseInt(l,10);if(a.Lang.isNumber(o)){if(p.charCode===o){q=true;}else{m=true;}}else{if(q||!m){q=(p[l+"Key"]);m=!q;}}}if(q){a.fire(d,p);}},b);}i.splice(2,2);i[0]=d;return a.on.apply(a,i);}};},"@VERSION@",{requires:["node-base"]});YUI.add("event-focus",function(e){var d=e.Event,c=e.Lang,a=c.isString,b=c.isFunction(e.DOM.create('<p onbeforeactivate=";"/>').onbeforeactivate);function f(h,g,j){var i="_"+h+"Notifiers";e.Event.define(h,{_attach:function(l,m,k){if(e.DOM.isWindow(l)){return d._attach([h,function(n){m.fire(n);},l]);}else{return d._attach([g,this._proxy,l,this,m,k],{capture:true});}},_proxy:function(o,s,p){var m=o.target,q=m.getData(i),t=e.stamp(o.currentTarget._node),k=(b||o.target!==o.currentTarget),l=s.handle.sub,r=[m,o].concat(l.args||[]),n;s.currentTarget=(p)?m:o.currentTarget;s.container=(p)?o.currentTarget:null;if(!l.filter||l.filter.apply(m,r)){if(!q){q={};m.setData(i,q);if(k){n=d._attach([j,this._notify,m._node]).sub;n.once=true;}}if(!q[t]){q[t]=[];}q[t].push(s);if(!k){this._notify(o);}}},_notify:function(p,l){var m=p.currentTarget,r=m.getData(i),s=m.get("ownerDocument")||m,q=m,k=[],t,n,o;if(r){while(q&&q!==s){k.push.apply(k,r[e.stamp(q)]||[]);q=q.get("parentNode");}k.push.apply(k,r[e.stamp(s)]||[]);for(n=0,o=k.length;n<o;++n){t=k[n];p.currentTarget=k[n].currentTarget;if(t.container){p.container=t.container;}t.fire(p);}m.clearData(i);}},on:function(m,k,l){k.onHandle=this._attach(m._node,l);},detach:function(l,k){k.onHandle.detach();},delegate:function(n,l,m,k){if(a(k)){l.filter=e.delegate.compileFilter(k);}l.delegateHandle=this._attach(n._node,m,true);},detachDelegate:function(l,k){k.delegateHandle.detach();}},true);}if(b){f("focus","beforeactivate","focusin");f("blur","beforedeactivate","focusout");}else{f("focus","focus","focus");f("blur","blur","blur");}},"@VERSION@",{requires:["event-synthetic"]});YUI.add("event-resize",function(a){(function(){var c,b,e="window:resize",d=function(f){if(a.UA.gecko){a.fire(e,f);}else{if(b){b.cancel();}b=a.later(a.config.windowResizeDelay||40,a,function(){a.fire(e,f);});}};a.Env.evt.plugins.windowresize={on:function(h,g){if(!c){c=a.Event._attach(["resize",d]);}var f=a.Array(arguments,0,true);f[0]=e;return a.on.apply(a,f);}};})();},"@VERSION@",{requires:["node-base"]});YUI.add("event-hover",function(d){var c=d.Lang.isFunction,b=function(){},a={processArgs:function(e){var f=c(e[2])?2:3;return(c(e[f]))?e.splice(f,1)[0]:b;},on:function(h,f,g,e){f._detach=h[(e)?"delegate":"on"]({mouseenter:function(i){i.phase="over";g.fire(i);},mouseleave:function(i){var j=f.context||this;i.type="hover";i.phase="out";f._extra.apply(j,[i].concat(f.args));}},e);},detach:function(g,e,f){e._detach.detach();}};a.delegate=a.on;a.detachDelegate=a.detach;d.Event.define("hover",a);},"@VERSION@",{requires:["event-mouseenter"]});YUI.add("event",function(a){},"@VERSION@",{use:["event-base","event-delegate","event-synthetic","event-mousewheel","event-mouseenter","event-key","event-focus","event-resize","event-hover"]});