YUI.add("event-custom-base",function(Y){
Y.Env.evt={handles:{},plugins:{}};
(function(){
var _1=0,_2=1;
Y.Do={objs:{},before:function(fn,_3,_4,c){
var f=fn,a;
if(c){
a=[fn,c].concat(Y.Array(arguments,4,true));
f=Y.rbind.apply(Y,a);
}
return this._inject(_1,f,_3,_4);
},after:function(fn,_5,_6,c){
var f=fn,a;
if(c){
a=[fn,c].concat(Y.Array(arguments,4,true));
f=Y.rbind.apply(Y,a);
}
return this._inject(_2,f,_5,_6);
},_inject:function(_7,fn,_8,_9){
var id=Y.stamp(_8),o,_a;
if(!this.objs[id]){
this.objs[id]={};
}
o=this.objs[id];
if(!o[_9]){
o[_9]=new Y.Do.Method(_8,_9);
_8[_9]=function(){
return o[_9].exec.apply(o[_9],arguments);
};
}
_a=id+Y.stamp(fn)+_9;
o[_9].register(_a,fn,_7);
return new Y.EventHandle(o[_9],_a);
},detach:function(_b){
if(_b.detach){
_b.detach();
}
},_unload:function(e,me){
}};
Y.Do.Method=function(_c,_d){
this.obj=_c;
this.methodName=_d;
this.method=_c[_d];
this.before={};
this.after={};
};
Y.Do.Method.prototype.register=function(_e,fn,_f){
if(_f){
this.after[_e]=fn;
}else{
this.before[_e]=fn;
}
};
Y.Do.Method.prototype._delete=function(sid){
delete this.before[sid];
delete this.after[sid];
};
Y.Do.Method.prototype.exec=function(){
var _10=Y.Array(arguments,0,true),i,ret,_11,bf=this.before,af=this.after,_12=false;
for(i in bf){
if(bf.hasOwnProperty(i)){
ret=bf[i].apply(this.obj,_10);
if(ret){
switch(ret.constructor){
case Y.Do.Halt:
return ret.retVal;
case Y.Do.AlterArgs:
_10=ret.newArgs;
break;
case Y.Do.Prevent:
_12=true;
break;
default:
}
}
}
}
if(!_12){
ret=this.method.apply(this.obj,_10);
}
for(i in af){
if(af.hasOwnProperty(i)){
_11=af[i].apply(this.obj,_10);
if(_11&&_11.constructor==Y.Do.Halt){
return _11.retVal;
}else{
if(_11&&_11.constructor==Y.Do.AlterReturn){
ret=_11.newRetVal;
}
}
}
}
return ret;
};
Y.Do.AlterArgs=function(msg,_13){
this.msg=msg;
this.newArgs=_13;
};
Y.Do.AlterReturn=function(msg,_14){
this.msg=msg;
this.newRetVal=_14;
};
Y.Do.Halt=function(msg,_15){
this.msg=msg;
this.retVal=_15;
};
Y.Do.Prevent=function(msg){
this.msg=msg;
};
Y.Do.Error=Y.Do.Halt;
})();
var _16="after",_17=["broadcast","bubbles","context","contextFn","currentTarget","defaultFn","details","emitFacade","fireOnce","host","preventable","preventedFn","queuable","silent","stoppedFn","target","type"],_18=9,_19="yui:log";
Y.EventHandle=function(evt,sub){
this.evt=evt;
this.sub=sub;
};
Y.EventHandle.prototype={detach:function(){
var evt=this.evt,i;
if(evt){
if(Y.Lang.isArray(evt)){
for(i=0;i<evt.length;i++){
evt[i].detach();
}
}else{
evt._delete(this.sub);
}
}
}};
Y.CustomEvent=function(_1a,o){
o=o||{};
this.id=Y.stamp(this);
this.type=_1a;
this.context=Y;
this.logSystem=(_1a==_19);
this.silent=this.logSystem;
this.subscribers={};
this.afters={};
this.preventable=true;
this.bubbles=true;
this.signature=_18;
this.applyConfig(o,true);
};
Y.CustomEvent.prototype={applyConfig:function(o,_1b){
if(o){
Y.mix(this,o,_1b,_17);
}
},_on:function(fn,_1c,_1d,_1e){
if(!fn){
this.log("Invalid callback for CE: "+this.type);
}
var s=new Y.Subscriber(fn,_1c,_1d,_1e);
if(this.fireOnce&&this.fired){
Y.later(0,this,Y.bind(this._notify,this,s,this.firedWith));
}
if(_1e==_16){
this.afters[s.id]=s;
this.hasAfters=true;
}else{
this.subscribers[s.id]=s;
this.hasSubscribers=true;
}
return new Y.EventHandle(this,s);
},subscribe:function(fn,_1f){
var a=(arguments.length>2)?Y.Array(arguments,2,true):null;
return this._on(fn,_1f,a,true);
},on:function(fn,_20){
var a=(arguments.length>2)?Y.Array(arguments,2,true):null;
return this._on(fn,_20,a,true);
},after:function(fn,_21){
var a=(arguments.length>2)?Y.Array(arguments,2,true):null;
return this._on(fn,_21,a,_16);
},detach:function(fn,_22){
if(fn&&fn.detach){
return fn.detach();
}
var _23=0,_24=this.subscribers,i,s;
for(i in _24){
if(_24.hasOwnProperty(i)){
s=_24[i];
if(s&&(!fn||fn===s.fn)){
this._delete(s);
_23++;
}
}
}
return _23;
},unsubscribe:function(){
return this.detach.apply(this,arguments);
},_notify:function(s,_25,ef){
this.log(this.type+"->"+"sub: "+s.id);
var ret;
ret=s.notify(_25,this);
if(false===ret||this.stopped>1){
this.log(this.type+" cancelled by subscriber");
return false;
}
return true;
},log:function(msg,cat){
if(!this.silent){
}
},fire:function(){
if(this.fireOnce&&this.fired){
this.log("fireOnce event: "+this.type+" already fired");
return true;
}else{
var _26=Y.Array(arguments,0,true);
this.fired=true;
this.firedWith=_26;
if(this.emitFacade){
return this.fireComplex(_26);
}else{
return this.fireSimple(_26);
}
}
},fireSimple:function(_27){
if(this.hasSubscribers||this.hasAfters){
this._procSubs(Y.merge(this.subscribers,this.afters),_27);
}
this._broadcast(_27);
return this.stopped?false:true;
},fireComplex:function(_28){
_28[0]=_28[0]||{};
return this.fireSimple(_28);
},_procSubs:function(_29,_2a,ef){
var s,i;
for(i in _29){
if(_29.hasOwnProperty(i)){
s=_29[i];
if(s&&s.fn){
if(false===this._notify(s,_2a,ef)){
this.stopped=2;
}
if(this.stopped==2){
return false;
}
}
}
}
return true;
},_broadcast:function(_2b){
if(!this.stopped&&this.broadcast){
var a=Y.Array(_2b);
a.unshift(this.type);
if(this.host!==Y){
Y.fire.apply(Y,a);
}
if(this.broadcast==2){
Y.Global.fire.apply(Y.Global,a);
}
}
},unsubscribeAll:function(){
return this.detachAll.apply(this,arguments);
},detachAll:function(){
return this.detach();
},_delete:function(s){
if(s){
delete s.fn;
delete s.context;
delete this.subscribers[s.id];
delete this.afters[s.id];
}
}};
Y.Subscriber=function(fn,_2c,_2d){
this.fn=fn;
this.context=_2c;
this.id=Y.stamp(this);
this.args=_2d;
this.events=null;
};
Y.Subscriber.prototype={_notify:function(c,_2e,ce){
var a=this.args,ret;
switch(ce.signature){
case 0:
ret=this.fn.call(c,ce.type,_2e,c);
break;
case 1:
ret=this.fn.call(c,_2e[0]||null,c);
break;
default:
if(a||_2e){
_2e=_2e||[];
a=(a)?_2e.concat(a):_2e;
ret=this.fn.apply(c,a);
}else{
ret=this.fn.call(c);
}
}
return ret;
},notify:function(_2f,ce){
var c=this.context,ret=true;
if(!c){
c=(ce.contextFn)?ce.contextFn():ce.context;
}
if(Y.config.throwFail){
ret=this._notify(c,_2f,ce);
}else{
try{
ret=this._notify(c,_2f,ce);
}
catch(e ){
Y.error(this+" failed: "+e.message,e);
}
}
return ret;
},contains:function(fn,_30){
if(_30){
return ((this.fn==fn)&&this.context==_30);
}else{
return (this.fn==fn);
}
}};
(function(){
var L=Y.Lang,_31=":",_32="|",_33="~AFTER~",_34=Y.cached(function(_35,pre){
if(!pre||!L.isString(_35)||_35.indexOf(_31)>-1){
return _35;
}
return pre+_31+_35;
}),_36=Y.cached(function(_37,pre){
var t=_37,_38,_39,i;
if(!L.isString(t)){
return t;
}
i=t.indexOf(_33);
if(i>-1){
_39=true;
t=t.substr(_33.length);
}
i=t.indexOf(_32);
if(i>-1){
_38=t.substr(0,(i));
t=t.substr(i+1);
if(t=="*"){
t=null;
}
}
return [_38,(pre)?_34(t,pre):t,_39,t];
}),ET=function(_3a){
var o=(L.isObject(_3a))?_3a:{};
this._yuievt=this._yuievt||{id:Y.guid(),events:{},targets:{},config:o,chain:("chain" in o)?o.chain:Y.config.chain,defaults:{context:o.context||this,host:this,emitFacade:o.emitFacade,fireOnce:o.fireOnce,queuable:o.queuable,broadcast:o.broadcast,bubbles:("bubbles" in o)?o.bubbles:true}};
};
ET.prototype={on:function(_3b,fn,_3c,x){
var _3d=_36(_3b,this._yuievt.config.prefix),f,c,_3e,ret,ce,_3f,_40,_41=Y.Env.evt.handles,_42,_43,_44,_45=Y.Node,n,_46;
if(L.isObject(_3b)){
if(L.isFunction(_3b)){
return Y.Do.before.apply(Y.Do,arguments);
}
f=fn;
c=_3c;
_3e=Y.Array(arguments,0,true);
ret={};
_42=_3b._after;
delete _3b._after;
Y.each(_3b,function(v,k){
if(v){
f=v.fn||((Y.Lang.isFunction(v))?v:f);
c=v.context||c;
}
_3e[0]=(_42)?_33+k:k;
_3e[1]=f;
_3e[2]=c;
ret[k]=this.on.apply(this,_3e);
},this);
return (this._yuievt.chain)?this:new Y.EventHandle(ret);
}
_3f=_3d[0];
_42=_3d[2];
_44=_3d[3];
if(_45&&(this instanceof _45)&&(_44 in _45.DOM_EVENTS)){
_3e=Y.Array(arguments,0,true);
_3e.splice(2,0,_45.getDOMNode(this));
return Y.on.apply(Y,_3e);
}
_3b=_3d[1];
if(this instanceof YUI){
_43=Y.Env.evt.plugins[_3b];
_3e=Y.Array(arguments,0,true);
_3e[0]=_44;
if(_45){
n=_3e[2];
if(n instanceof Y.NodeList){
n=Y.NodeList.getDOMNodes(n);
}else{
if(n instanceof _45){
n=_45.getDOMNode(n);
}
}
_46=(_44 in _45.DOM_EVENTS);
if(_46){
_3e[2]=n;
}
}
if(_43){
_40=_43.on.apply(Y,_3e);
}else{
if((!_3b)||_46){
_40=Y.Event._attach(_3e);
}
}
}
if(!_40){
ce=this._yuievt.events[_3b]||this.publish(_3b);
_40=ce._on(fn,_3c,(arguments.length>3)?Y.Array(arguments,3,true):null,(_42)?"after":true);
}
if(_3f){
_41[_3f]=_41[_3f]||{};
_41[_3f][_3b]=_41[_3f][_3b]||[];
_41[_3f][_3b].push(_40);
}
return (this._yuievt.chain)?this:_40;
},subscribe:function(){
return this.on.apply(this,arguments);
},detach:function(_47,fn,_48){
var _49=this._yuievt.events,i,ret,_4a=Y.Node,_4b=(this instanceof _4a);
if(!_47&&(this!==Y)){
for(i in _49){
if(_49.hasOwnProperty(i)){
ret=_49[i].detach(fn,_48);
}
}
if(_4b){
Y.Event.purgeElement(_4a.getDOMNode(this));
}
return ret;
}
var _4c=_36(_47,this._yuievt.config.prefix),_4d=L.isArray(_4c)?_4c[0]:null,_4e=(_4c)?_4c[3]:null,_4f,_50,_51=Y.Env.evt.handles,cat,_52,ce,_53=function(_54,_55){
var _56=_54[_55];
if(_56){
while(_56.length){
_4f=_56.pop();
_4f.detach();
}
}
};
if(_4d){
cat=_51[_4d];
_47=_4c[1];
if(cat){
if(_47){
_53(cat,_47);
}else{
for(i in cat){
if(cat.hasOwnProperty(i)){
_53(cat,i);
}
}
}
return (this._yuievt.chain)?this:true;
}
}else{
if(L.isObject(_47)&&_47.detach){
ret=_47.detach();
return (this._yuievt.chain)?this:ret;
}else{
if(_4b&&((!_4e)||(_4e in _4a.DOM_EVENTS))){
_52=Y.Array(arguments,0,true);
_52[2]=_4a.getDOMNode(this);
return Y.detach.apply(Y,_52);
}
}
}
_50=Y.Env.evt.plugins[_4e];
if(this instanceof YUI){
_52=Y.Array(arguments,0,true);
if(_50&&_50.detach){
return _50.detach.apply(Y,_52);
}else{
if(!_47||(!_50&&_4a&&(_47 in _4a.DOM_EVENTS))){
_52[0]=_47;
return Y.Event.detach.apply(Y.Event,_52);
}
}
}
ce=_49[_47];
if(ce){
ret=ce.detach(fn,_48);
}
return (this._yuievt.chain)?this:ret;
},unsubscribe:function(){
return this.detach.apply(this,arguments);
},detachAll:function(_57){
return this.detach(_57);
},unsubscribeAll:function(){
return this.detachAll.apply(this,arguments);
},publish:function(_58,_59){
var _5a,ce,ret,pre=this._yuievt.config.prefix;
_58=(pre)?_34(_58,pre):_58;
if(L.isObject(_58)){
ret={};
Y.each(_58,function(v,k){
ret[k]=this.publish(k,v||_59);
},this);
return ret;
}
_5a=this._yuievt.events;
ce=_5a[_58];
if(ce){
if(_59){
ce.applyConfig(_59,true);
}
}else{
ce=new Y.CustomEvent(_58,(_59)?Y.mix(_59,this._yuievt.defaults):this._yuievt.defaults);
_5a[_58]=ce;
}
return _5a[_58];
},addTarget:function(o){
this._yuievt.targets[Y.stamp(o)]=o;
this._yuievt.hasTargets=true;
},removeTarget:function(o){
delete this._yuievt.targets[Y.stamp(o)];
},fire:function(_5b){
var _5c=L.isString(_5b),t=(_5c)?_5b:(_5b&&_5b.type),ce,a,ret,pre=this._yuievt.config.prefix;
t=(pre)?_34(t,pre):t;
ce=this.getEvent(t,true);
if(!ce){
if(this._yuievt.hasTargets){
a=(_5c)?arguments:Y.Array(arguments,0,true).unshift(t);
return this.bubble(null,a,this);
}
ret=true;
}else{
a=Y.Array(arguments,(_5c)?1:0,true);
ret=ce.fire.apply(ce,a);
ce.target=null;
}
return (this._yuievt.chain)?this:ret;
},getEvent:function(_5d,_5e){
var pre,e;
if(!_5e){
pre=this._yuievt.config.prefix;
_5d=(pre)?_34(_5d,pre):_5d;
}
e=this._yuievt.events;
return (e&&_5d in e)?e[_5d]:null;
},after:function(_5f,fn){
var a=Y.Array(arguments,0,true);
switch(L.type(_5f)){
case "function":
return Y.Do.after.apply(Y.Do,arguments);
case "object":
a[0]._after=true;
break;
default:
a[0]=_33+_5f;
}
return this.on.apply(this,a);
},before:function(){
return this.on.apply(this,arguments);
}};
Y.EventTarget=ET;
Y.mix(Y,ET.prototype,false,false,{bubbles:false});
ET.call(Y);
YUI.Env.globalEvents=YUI.Env.globalEvents||new ET();
Y.Global=YUI.Env.globalEvents;
})();
},"3.0.0",{requires:["oop"]});

