event-min.js revision 0bc189b2acbd7c4b5af63eded0c4289e224676b7
(function(){var d,b=YUI.Env,c=YUI.config,h=c.doc,e=h&&h.documentElement,i=e&&e.doScroll,k=YUI.Env.add,f=YUI.Env.remove,g=(i)?"onreadystatechange":"DOMContentLoaded",a=c.pollInterval||40,j=function(l){b._ready();};if(!b._ready){b._ready=function(){if(!b.DOMReady){b.DOMReady=true;f(h,g,j);}};
/*! DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */
if(i){if(self!==self.top){d=function(){if(h.readyState=="complete"){f(h,g,d);j();}};k(h,g,d);}else{b._dri=setInterval(function(){try{e.doScroll("left");clearInterval(b._dri);b._dri=null;j();}catch(l){}},a);}}else{k(h,g,j);}}})();YUI.add("event-base",function(a){(function(){var c=YUI.Env,b=function(){a.fire("domready");};a.publish("domready",{fireOnce:true,async:true});if(c.DOMReady){b();}else{a.before(b,c,"_ready");}})();(function(){var c=a.UA,b={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9,63272:46,63273:36,63275:35},d=function(g){try{if(g&&3==g.nodeType){g=g.parentNode;}}catch(f){return null;}return a.one(g);};a.DOMEventFacade=function(m,g,f){f=f||{};var i=m,h=g,j=a.config.doc,n=j.body,o=i.pageX,l=i.pageY,k,r,p=j.documentElement,q=f.overrides||{};this.altKey=i.altKey;this.ctrlKey=i.ctrlKey;this.metaKey=i.metaKey;this.shiftKey=i.shiftKey;this.type=q.type||i.type;this.clientX=i.clientX;this.clientY=i.clientY;if(("clientX" in i)&&(!o)&&(0!==o)){o=i.clientX;l=i.clientY;if(c.ie){o+=(p.scrollLeft||(n&&n.scrollLeft)||0);l+=(p.scrollTop||(n&&n.scrollTop)||0);}}this._yuifacade=true;this._event=i;this.pageX=o;this.pageY=l;k=i.keyCode||i.charCode||0;if(c.webkit&&(k in b)){k=b[k];}this.keyCode=k;this.charCode=k;this.button=i.which||i.button;this.which=this.button;this.target=d(i.target||i.srcElement);this.currentTarget=d(h);r=i.relatedTarget;if(!r){if(i.type=="mouseout"){r=i.toElement;}else{if(i.type=="mouseover"){r=i.fromElement;}}}this.relatedTarget=d(r);if(i.type=="mousewheel"||i.type=="DOMMouseScroll"){this.wheelDelta=(i.detail)?(i.detail*-1):Math.round(i.wheelDelta/80)||((i.wheelDelta<0)?-1:1);}this.stopPropagation=function(){if(i.stopPropagation){i.stopPropagation();}else{i.cancelBubble=true;}f.stopped=1;this.stopped=1;};this.stopImmediatePropagation=function(){if(i.stopImmediatePropagation){i.stopImmediatePropagation();}else{this.stopPropagation();}f.stopped=2;this.stopped=2;};this.preventDefault=function(e){if(i.preventDefault){i.preventDefault();}i.returnValue=e||false;f.prevented=1;this.prevented=1;};this.halt=function(e){if(e){this.stopImmediatePropagation();}else{this.stopPropagation();}this.preventDefault();};if(this._touch){this._touch(i,g,f);}};})();(function(){a.Env.evt.dom_wrappers={};a.Env.evt.dom_map={};var j=a.Env.evt,c=a.config,g=c.win,l=YUI.Env.add,e=YUI.Env.remove,i=function(){YUI.Env.windowLoaded=true;a.Event._load();e(g,"load",i);},b=function(){a.Event._unload();},d="domready",f="~yui|2|compat~",h=function(n){try{return(n&&typeof n!=="string"&&a.Lang.isNumber(n.length)&&!n.tagName&&!n.alert);}catch(m){return false;}},k=function(){var o=false,p=0,n=[],q=j.dom_wrappers,m=null,r=j.dom_map;return{POLL_RETRYS:1000,POLL_INTERVAL:40,lastError:null,_interval:null,_dri:null,DOMReady:false,startInterval:function(){if(!k._interval){k._interval=setInterval(a.bind(k._poll,k),k.POLL_INTERVAL);}},onAvailable:function(s,w,A,t,x,z){var y=a.Array(s),u,v;for(u=0;u<y.length;u=u+1){n.push({id:y[u],fn:w,obj:A,override:t,checkReady:x,compat:z});}p=this.POLL_RETRYS;setTimeout(a.bind(k._poll,k),0);v=new a.EventHandle({_delete:function(){if(v.handle){v.handle.detach();return;}var C,B;for(C=0;C<y.length;C++){for(B=0;B<n.length;B++){if(y[C]===n[B].id){n.splice(B,1);}}}}});return v;},onContentReady:function(w,t,v,u,s){return this.onAvailable(w,t,v,u,true,s);},attach:function(v,u,t,s){return k._attach(a.Array(arguments,0,true));},_createWrapper:function(y,x,s,t,w){var v,z=a.stamp(y),u="event:"+z+x;if(false===w){u+="native";}if(s){u+="capture";}v=q[u];if(!v){v=a.publish(u,{silent:true,bubbles:false,contextFn:function(){if(t){return v.el;}else{v.nodeRef=v.nodeRef||a.one(v.el);return v.nodeRef;}}});v.overrides={};v.el=y;v.key=u;v.domkey=z;v.type=x;v.fn=function(A){v.fire(k.getEvent(A,y,(t||(false===w))));};v.capture=s;if(y==g&&x=="load"){v.fireOnce=true;m=u;}q[u]=v;r[z]=r[z]||{};r[z][u]=v;l(y,x,v.fn,s);}return v;},_attach:function(y,x){var D,F,v,C,s,u=false,w,z=y[0],A=y[1],t=y[2]||g,G=x&&x.facade,E=x&&x.capture,B=x&&x.overrides;if(y[y.length-1]===f){D=true;}if(!A||!A.call){return false;}if(h(t)){F=[];a.each(t,function(I,H){y[2]=I;F.push(k._attach(y,x));});return new a.EventHandle(F);}else{if(a.Lang.isString(t)){if(D){v=a.DOM.byId(t);}else{v=a.Selector.query(t);switch(v.length){case 0:v=null;break;case 1:v=v[0];break;default:y[2]=v;return k._attach(y,x);}}if(v){t=v;}else{w=this.onAvailable(t,function(){w.handle=k._attach(y,x);},k,true,false,D);return w;}}}if(!t){return false;}if(a.Node&&t instanceof a.Node){t=a.Node.getDOMNode(t);}C=this._createWrapper(t,z,E,D,G);if(B){a.mix(C.overrides,B);}if(t==g&&z=="load"){if(YUI.Env.windowLoaded){u=true;}}if(D){y.pop();}s=y[3];w=C._on(A,s,(y.length>4)?y.slice(4):null);if(u){C.fire();}return w;},detach:function(z,A,u,x){var y=a.Array(arguments,0,true),C,v,B,w,s,t;if(y[y.length-1]===f){C=true;}if(z&&z.detach){return z.detach();}if(typeof u=="string"){if(C){u=a.DOM.byId(u);}else{u=a.Selector.query(u);v=u.length;if(v<1){u=null;}else{if(v==1){u=u[0];}}}}if(!u){return false;}if(u.detach){y.splice(2,1);return u.detach.apply(u,y);}else{if(h(u)){B=true;for(w=0,v=u.length;w<v;++w){y[2]=u[w];B=(a.Event.detach.apply(a.Event,y)&&B);}return B;}}if(!z||!A||!A.call){return this.purgeElement(u,false,z);}s="event:"+a.stamp(u)+z;t=q[s];if(t){return t.detach(A);}else{return false;}},getEvent:function(v,t,s){var u=v||g.event;return(s)?u:new a.DOMEventFacade(u,t,q["event:"+a.stamp(t)+v.type]);},generateId:function(s){var t=s.id;if(!t){t=a.stamp(s);s.id=t;}return t;},_isValidCollection:h,_load:function(s){if(!o){o=true;if(a.fire){a.fire(d);}k._poll();}},_poll:function(){if(this.locked){return;}if(a.UA.ie&&!YUI.Env.DOMReady){this.startInterval();
return;}this.locked=true;var t,s,x,u,w,y,v=!o;if(!v){v=(p>0);}w=[];y=function(B,C){var A,z=C.override;if(C.compat){if(C.override){if(z===true){A=C.obj;}else{A=z;}}else{A=B;}C.fn.call(A,C.obj);}else{A=C.obj||a.one(B);C.fn.apply(A,(a.Lang.isArray(z))?z:[]);}};for(t=0,s=n.length;t<s;++t){x=n[t];if(x&&!x.checkReady){u=(x.compat)?a.DOM.byId(x.id):a.Selector.query(x.id,null,true);if(u){y(u,x);n[t]=null;}else{w.push(x);}}}for(t=0,s=n.length;t<s;++t){x=n[t];if(x&&x.checkReady){u=(x.compat)?a.DOM.byId(x.id):a.Selector.query(x.id,null,true);if(u){if(o||(u.get&&u.get("nextSibling"))||u.nextSibling){y(u,x);n[t]=null;}}else{w.push(x);}}}p=(w.length===0)?0:p-1;if(v){this.startInterval();}else{clearInterval(this._interval);this._interval=null;}this.locked=false;return;},purgeElement:function(v,s,z){var x=(a.Lang.isString(v))?a.Selector.query(v,null,true):v,B=this.getListeners(x,z),w,y,A,u,t;if(s&&x){B=B||[];u=a.Selector.query("*",x);w=0;y=u.length;for(;w<y;++w){t=this.getListeners(u[w],z);if(t){B=B.concat(t);}}}if(B){w=0;y=B.length;for(;w<y;++w){A=B[w];A.detachAll();e(A.el,A.type,A.fn,A.capture);delete q[A.key];delete r[A.domkey][A.key];}}},getListeners:function(w,v){var x=a.stamp(w,true),s=r[x],u=[],t=(v)?"event:"+x+v:null,y=j.plugins;if(!s){return null;}if(t){if(y[v]&&y[v].eventDef){t+="_synth";}if(s[t]){u.push(s[t]);}t+="native";if(s[t]){u.push(s[t]);}}else{a.each(s,function(A,z){u.push(A);});}return(u.length)?u:null;},_unload:function(s){a.each(q,function(u,t){u.detachAll();e(u.el,u.type,u.fn,u.capture);delete q[t];delete r[u.domkey][t];});e(g,"unload",b);},nativeAdd:l,nativeRemove:e};}();a.Event=k;if(c.injected||YUI.Env.windowLoaded){i();}else{l(g,"load",i);}if(a.UA.ie){a.on(d,k._poll,k,true);}a.on("unload",b);k.Custom=a.CustomEvent;k.Subscriber=a.Subscriber;k.Target=a.EventTarget;k.Handle=a.EventHandle;k.Facade=a.EventFacade;k._poll();})();a.Env.evt.plugins.available={on:function(d,c,f,e){var b=arguments.length>4?a.Array(arguments,4,true):[];return a.Event.onAvailable.call(a.Event,f,c,e,b);}};a.Env.evt.plugins.contentready={on:function(d,c,f,e){var b=arguments.length>4?a.Array(arguments,4,true):[];return a.Event.onContentReady.call(a.Event,f,c,e,b);}};},"@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(o,j,n){j=j.slice();if(this.args){j.push.apply(j,this.args);}var m=e._applyFilter(this.filter,j,n),l,k,h;if(m){m=d(m);l=j[0]=new g.DOMEventFacade(j[0],n.el,n);l.container=g.one(n.el);for(k=m.length-1;k>=0;--k){l.currentTarget=g.one(m[k]);h=this.fn.apply(this.context||l.currentTarget,j);if(h===false){break;}}return h;}};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"]});