YUI.add("aui-event-delegate-submit",function(e,t){function h(e){var t=this,r=n.some(e,function(t,n){if(t.args&&t.args[0]===f){var r=e.splice(e.length-1,1)[0];return e.splice(n,0,r),!0}})}function p(e,t){var n=t,i={},s=t[e.sub.id],o=!1;return r.each(t,function(e,t){!o&&e.args&&e.args[0]===f&&(i[s.id]=s,o=!0),e!==s&&(i[e.id]=e)}),o&&(n=i),n}function d(e,t,n,r,i){var s=this;r&&r[0]===l&&(i===a&&s._afters.length?h.call(s,s._afters):s._subscribers.length&&h.call(s,s._subscribers))}function v(e,t,n,i,s){var o=this;i&&i[0]===l&&(s===a&&!r.isEmpty(o.afters)?o.afters=p.call(o,e,o.afters):r.isEmpty(o.subscribers)||(o.subscribers=p.call(o,o.subscribers)))}var n=e.Array,r=e.Object,i=e.Node,s=e.Selector,o="click",u="submit",a="after",f="submit_delegate",l="submit_on";e.Event.define(u,{delegate:function(e,t,n,i){var s=this,u=s._prepareHandles(t,e);r.owns(u,o)||(u[o]=e.delegate(o,function(r){var o=r.target;if(s._getNodeName(o,"input")||s._getNodeName(o,"button")){var u=o.get("form");u&&s._attachEvent(u,e,t,n,i)}},i))},detach:function(e,t,n){var r=this;r._detachEvents(e,t,n)},detachDelegate:function(e,t,n){var r=this;r._detachEvents(e,t,n)},on:function(e,t,n){var r=this;r._attachEvent(e,e,t,n)},_attachEvent:function(t,n,i,o,a){var c=this,h=function(r){var i=!0;if(a){if(!r.stopped||!c._hasParent(r._stoppedOnNode,n)){var u=n.getDOM(),f=t.getDOM();do f&&s.test(f,a)&&(r.currentTarget=e.one(f),r.container=n,i=o.fire(r),r.stopped&&!r._stoppedOnNode&&(r._stoppedOnNode=n)),f=f.parentNode;while(i!==!1&&!r.stopped&&f&&f!==u);i=i!==!1&&r.stopped!==2}}else i=o.fire(r),r.stopped&&!r._stoppedOnNode&&(r._stoppedOnNode=n);return i},p=c._prepareHandles(i,t);r.owns(p,u)||(p[u]=e.Event._attach([u,h,t,o,a?f:l]))},_detachEvents:function(t,n,r){e.each(n._handles,function(t,n,r){e.each(t,function(e,t,n){e.detach()})}),delete n._handles},_getNodeName:function(e,t){var n=e.get("nodeName");return n&&n.toLowerCase()===t.toLowerCase()},_hasParent:function(e,t){return e.ancestor(function(e){return e===t},!1)},_prepareHandles:function(e,t){r.owns(e,"_handles")||(e._handles={});var n=e._handles;return r.owns(n,t)||(n[t]={}),n[t]}},!0);var c=e.CustomEvent.prototype._on;e.CustomEvent.prototype._on=function(e,t,n,r){var i=this,s=c.apply(i,arguments);return i._kds?v.call(i,s,e,t,n,r):d.call(i,s,e,t,n,r),s}},"2.0.0",{requires:["aui-event-base","event-delegate","event-synthetic"]});
