event-min.js revision 22efc9d4ee55a01a5ab27b1bd8325e1bfc8e550a
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||0;if(b.webkit&&(k in a)){k=a[k];}this.keyCode=k;this.charCode=k;this.which=i.which;this.button=i.button;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 o=e.Env.evt,h=e.config,l=h.win,q=YUI.Env.add,j=YUI.Env.remove,n=function(){YUI.Env.windowLoaded=true;e.Event._load();j(l,"load",n);},g=function(){e.Event._unload();},i="domready",k="~yui|2|compat~",m=function(s){try{return(s&&typeof s!=="string"&&e.Lang.isNumber(s.length)&&!s.tagName&&!s.alert);}catch(r){return false;}},p=function(){var t=false,u=0,s=[],v=o.dom_wrappers,r=null,w=o.dom_map;return{POLL_RETRYS:1000,POLL_INTERVAL:40,lastError:null,_interval:null,_dri:null,DOMReady:false,startInterval:function(){if(!p._interval){p._interval=setInterval(p._poll,p.POLL_INTERVAL);}},onAvailable:function(x,B,F,y,C,E){var D=e.Array(x),z,A;for(z=0;z<D.length;z=z+1){s.push({id:D[z],fn:B,obj:F,override:y,checkReady:C,compat:E});}u=this.POLL_RETRYS;setTimeout(p._poll,0);A=new e.EventHandle({_delete:function(){if(A.handle){A.handle.detach();return;}var H,G;for(H=0;H<D.length;H++){for(G=0;G<s.length;G++){if(D[H]===s[G].id){s.splice(G,1);}}}}});return A;},onContentReady:function(B,z,A,y,x){return p.onAvailable(B,z,A,y,true,x);},attach:function(A,z,y,x){return p._attach(e.Array(arguments,0,true));},_createWrapper:function(D,C,x,y,B){var A,E=e.stamp(D),z="event:"+E+C;if(false===B){z+="native";}if(x){z+="capture";}A=v[z];if(!A){A=e.publish(z,{silent:true,bubbles:false,contextFn:function(){if(y){return A.el;}else{A.nodeRef=A.nodeRef||e.one(A.el);return A.nodeRef;}}});A.overrides={};A.el=D;A.key=z;A.domkey=E;A.type=C;A.fn=function(F){A.fire(p.getEvent(F,D,(y||(false===B))));};A.capture=x;if(D==l&&C=="load"){A.fireOnce=true;r=z;}v[z]=A;w[E]=w[E]||{};w[E][z]=A;q(D,C,A.fn,x);}return A;},_attach:function(D,C){var I,K,A,H,x,z=false,B,E=D[0],F=D[1],y=D[2]||l,L=C&&C.facade,J=C&&C.capture,G=C&&C.overrides;if(D[D.length-1]===k){I=true;}if(!F||!F.call){return false;}if(m(y)){K=[];e.each(y,function(N,M){D[2]=N;K.push(p._attach(D,C));});return new e.EventHandle(K);}else{if(e.Lang.isString(y)){if(I){A=e.DOM.byId(y);}else{A=e.Selector.query(y);switch(A.length){case 0:A=null;break;case 1:A=A[0];break;default:D[2]=A;return p._attach(D,C);}}if(A){y=A;}else{B=p.onAvailable(y,function(){B.handle=p._attach(D,C);},p,true,false,I);return B;}}}if(!y){return false;}if(e.Node&&e.instanceOf(y,e.Node)){y=e.Node.getDOMNode(y);}H=p._createWrapper(y,E,J,I,L);if(G){e.mix(H.overrides,G);}if(y==l&&E=="load"){if(YUI.Env.windowLoaded){z=true;}}if(I){D.pop();}x=D[3];B=H._on(F,x,(D.length>4)?D.slice(4):null);if(z){H.fire();}return B;},detach:function(E,F,z,C){var D=e.Array(arguments,0,true),H,A,G,B,x,y;if(D[D.length-1]===k){H=true;}if(E&&E.detach){return E.detach();}if(typeof z=="string"){if(H){z=e.DOM.byId(z);}else{z=e.Selector.query(z);A=z.length;if(A<1){z=null;}else{if(A==1){z=z[0];}}}}if(!z){return false;}if(z.detach){D.splice(2,1);return z.detach.apply(z,D);}else{if(m(z)){G=true;for(B=0,A=z.length;B<A;++B){D[2]=z[B];G=(e.Event.detach.apply(e.Event,D)&&G);}return G;}}if(!E||!F||!F.call){return p.purgeElement(z,false,E);}x="event:"+e.stamp(z)+E;y=v[x];if(y){return y.detach(F);}else{return false;}},getEvent:function(A,y,x){var z=A||l.event;return(x)?z:new e.DOMEventFacade(z,y,v["event:"+e.stamp(y)+A.type]);},generateId:function(x){var y=x.id;if(!y){y=e.stamp(x);x.id=y;}return y;},_isValidCollection:m,_load:function(x){if(!t){t=true;if(e.fire){e.fire(i);}p._poll();}},_poll:function(){if(p.locked){return;}if(e.UA.ie&&!YUI.Env.DOMReady){p.startInterval();return;}p.locked=true;var y,x,C,z,B,D,A=!t;if(!A){A=(u>0);}B=[];D=function(G,H){var F,E=H.override;if(H.compat){if(H.override){if(E===true){F=H.obj;}else{F=E;}}else{F=G;}H.fn.call(F,H.obj);}else{F=H.obj||e.one(G);H.fn.apply(F,(e.Lang.isArray(E))?E:[]);}};for(y=0,x=s.length;y<x;++y){C=s[y];if(C&&!C.checkReady){z=(C.compat)?e.DOM.byId(C.id):e.Selector.query(C.id,null,true);if(z){D(z,C);s[y]=null;}else{B.push(C);}}}for(y=0,x=s.length;y<x;++y){C=s[y];if(C&&C.checkReady){z=(C.compat)?e.DOM.byId(C.id):e.Selector.query(C.id,null,true);
if(z){if(t||(z.get&&z.get("nextSibling"))||z.nextSibling){D(z,C);s[y]=null;}}else{B.push(C);}}}u=(B.length===0)?0:u-1;if(A){p.startInterval();}else{clearInterval(p._interval);p._interval=null;}p.locked=false;return;},purgeElement:function(A,x,E){var C=(e.Lang.isString(A))?e.Selector.query(A,null,true):A,G=p.getListeners(C,E),B,D,F,z,y;if(x&&C){G=G||[];z=e.Selector.query("*",C);B=0;D=z.length;for(;B<D;++B){y=p.getListeners(z[B],E);if(y){G=G.concat(y);}}}if(G){B=0;D=G.length;for(;B<D;++B){F=G[B];F.detachAll();j(F.el,F.type,F.fn,F.capture);delete v[F.key];delete w[F.domkey][F.key];}}},getListeners:function(B,A){var C=e.stamp(B,true),x=w[C],z=[],y=(A)?"event:"+C+A:null,D=o.plugins;if(!x){return null;}if(y){if(D[A]&&D[A].eventDef){y+="_synth";}if(x[y]){z.push(x[y]);}y+="native";if(x[y]){z.push(x[y]);}}else{e.each(x,function(F,E){z.push(F);});}return(z.length)?z:null;},_unload:function(x){e.each(v,function(z,y){z.detachAll();j(z.el,z.type,z.fn,z.capture);delete v[y];delete w[z.domkey][y];});j(l,"unload",g);},nativeAdd:q,nativeRemove:j};}();e.Event=p;if(h.injected||YUI.Env.windowLoaded){n();}else{q(l,"load",n);}if(e.UA.ie){e.on(i,p._poll);}q(l,"unload",g);p.Custom=e.CustomEvent;p.Subscriber=e.Subscriber;p.Target=e.EventTarget;p.Handle=e.EventHandle;p.Facade=e.EventFacade;p._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(g){var d=g.Array,b=g.Lang,a=b.isString,f=g.Selector.test,c=g.Env.evt.handles;function e(q,s,j,i){var o=d(arguments,0,true),p=a(j)?j:null,n=q.split(/\|/),l,h,k,r,m;if(n.length>1){r=n.shift();q=n.shift();}l=g.Node.DOM_EVENTS[q];if(b.isObject(l)&&l.delegate){m=l.delegate.apply(l,arguments);}if(!m){if(!q||!s||!j||!i){return;}h=(p)?g.Selector.query(p,null,true):j;if(!h&&a(j)){m=g.on("available",function(){g.mix(m,g.delegate.apply(g,o),true);},j);}if(!m&&h){o.splice(2,2,h);m=g.Event._attach(o,{facade:false});m.sub.filter=i;m.sub._notify=e.notifySub;}}if(m&&r){k=c[r]||(c[r]={});k=k[q]||(k[q]=[]);k.push(m);}return m;}e.notifySub=function(p,k,o){k=k.slice();if(this.args){k.push.apply(k,this.args);}var n=e._applyFilter(this.filter,k,o),m,l,h,j;if(n){n=d(n);m=k[0]=new g.DOMEventFacade(k[0],o.el,o);m.container=g.one(o.el);for(l=0,h=n.length;l<h&&!m.stopped;++l){m.currentTarget=g.one(n[l]);j=this.fn.apply(this.context||m.currentTarget,k);if(j===false){break;}}return j;}};e.compileFilter=g.cached(function(h){return function(j,i){return f(j._node,h,i.currentTarget._node);};});e._applyFilter=function(k,j,n){var m=j[0],h=n.el,l=m.target||m.srcElement,i=[];if(l.nodeType===3){l=l.parentNode;}j.unshift(l);if(a(k)){while(l&&l!==h){if(f(l,k,h)){i.push(l);}l=l.parentNode;}}else{j[0]=g.one(l);j[1]=new g.DOMEventFacade(m,h,n);while(l&&l!==h){if(k.apply(j[0],j)){i.push(l);}l=l.parentNode;j[0]=g.one(l);}j[1]=m;}if(i.length<=1){i=i[0];}j.shift();return i;};g.delegate=g.Event.delegate=e;},"@VERSION@",{requires:["node-base"]});YUI.add("event-synthetic",function(b){var h=b.Env.evt.dom_map,d=b.Array,g=b.Lang,j=g.isObject,c=g.isString,e=b.Selector.query,i=function(){};function f(l,k){this.handle=l;this.emitFacade=k;}f.prototype.fire=function(q){var k=d(arguments,0,true),o=this.handle,p=o.evt,m=o.sub,r=m.context,l=m.filter,n=q||{};if(this.emitFacade){if(!q||!q.preventDefault){n=p._getFacade();if(j(q)&&!q.preventDefault){b.mix(n,q,true);k[0]=n;}else{k.unshift(n);}}n.type=p.type;n.details=k.slice();if(l){n.container=p.host;}}else{if(l&&j(q)&&q.currentTarget){k.shift();}}m.context=r||n.currentTarget||p.host;p.fire.apply(p,k);m.context=r;};function a(){this._init.apply(this,arguments);}b.mix(a,{Notifier:f,getRegistry:function(q,p,n){var o=q._node,m=b.stamp(o),l="event:"+m+p+"_synth",k=h[m]||(h[m]={});if(!k[l]&&n){k[l]={type:"_synth",fn:i,capture:false,el:o,key:l,domkey:m,notifiers:[],detachAll:function(){var r=this.notifiers,s=r.length;while(--s>=0){r[s].detach();}}};}return(k[l])?k[l].notifiers:null;},_deleteSub:function(l){if(l&&l.fn){var k=this.eventDef,m=(l.filter)?"detachDelegate":"detach";this.subscribers={};this.subCount=0;k[m](l.node,l,this.notifier,l.filter);k._unregisterSub(l);delete l.fn;delete l.node;delete l.context;}},prototype:{constructor:a,_init:function(){var k=this.publishConfig||(this.publishConfig={});this.emitFacade=("emitFacade" in k)?k.emitFacade:true;k.emitFacade=false;},processArgs:i,on:i,detach:i,delegate:i,detachDelegate:i,_on:function(m,o){var n=[],k=m[2],q=o?"delegate":"on",l,p;l=(c(k))?e(k):d(k);if(!l.length&&c(k)){p=b.on("available",function(){b.mix(p,b[q].apply(b,m),true);},k);return p;}b.each(l,function(t){var u=m.slice(),r,s;t=b.one(t);if(t){r=this.processArgs(u,o);if(o){s=u.splice(3,1)[0];}u.splice(0,4,u[1],u[3]);if(!this.preventDups||!this.getSubs(t,m,null,true)){p=this._getNotifier(t,u,r,s);this[q](t,p.sub,p.notifier,s);n.push(p);}}},this);return(n.length===1)?n[0]:new b.EventHandle(n);},_getNotifier:function(n,q,o,m){var s=new b.CustomEvent(this.type,this.publishConfig),p=s.on.apply(s,q),r=new f(p,this.emitFacade),l=a.getRegistry(n,this.type,true),k=p.sub;p.notifier=r;k.node=n;k.filter=m;k._extra=o;b.mix(s,{eventDef:this,notifier:r,host:n,currentTarget:n,target:n,el:n._node,_delete:a._deleteSub},true);l.push(p);return p;},_unregisterSub:function(m){var k=a.getRegistry(m.node,this.type),l;if(k){for(l=k.length-1;l>=0;--l){if(k[l].sub===m){k.splice(l,1);break;}}}},_detach:function(m){var r=m[2],p=(c(r))?e(r):d(r),q,o,k,n,l;m.splice(2,1);for(o=0,k=p.length;o<k;++o){q=b.one(p[o]);if(q){n=this.getSubs(q,m);if(n){for(l=n.length-1;l>=0;--l){n[l].detach();}}}}},getSubs:function(l,q,k,n){var r=a.getRegistry(l,this.type),s=[],m,p,o;if(r){if(!k){k=this.subMatch;}for(m=0,p=r.length;m<p;++m){o=r[m];if(k.call(this,o.sub,q)){if(n){return o;
}else{s.push(r[m]);}}}}return s.length&&s;},subMatch:function(l,k){return !k[1]||l.fn===k[1];}}},true);b.SyntheticEvent=a;b.Event.define=function(m,l,o){if(!l){l={};}var n=(j(m))?m:b.merge({type:m},l),p,k;if(o||!b.Node.DOM_EVENTS[n.type]){p=function(){a.apply(this,arguments);};b.extend(p,a,n);k=new p();m=k.type;b.Node.DOM_EVENTS[m]=b.Env.evt.plugins[m]={eventDef:k,on:function(){return k._on(d(arguments));},delegate:function(){return k._on(d(arguments),true);},detach:function(){return k._detach(d(arguments));}};}return k;};},"@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;}else{delete p.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",function(a){},"@VERSION@",{use:["event-base","event-delegate","event-synthetic","event-mousewheel","event-mouseenter","event-key","event-focus","event-resize"]});