event-delegate-min.js revision 0bc189b2acbd7c4b5af63eded0c4289e224676b7
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"]});