steal('jquery', function ($){ $.event.reverse = function (name, attributes){ var bound = $(), count = 0, dispatch = $.event.handle || $.event.dispatch; $.event.special[name] = { setup: function (){ if (this !== window) { bound.push(this); $.unique(bound); } return this !== window; } , teardown: function (){ bound = bound.not(this); return this !== window; } , add: function (handleObj){ var origHandler = handleObj.handler; handleObj.origHandler = origHandler; handleObj.handler = function (ev, data){ var isWindow = this === window; if (attributes && attributes.handler) { var result = attributes.handler.apply(this, arguments); if (result === true ) { return ; } } if (count === 0) { count++ ; var where = data === false ? _AN_Read_target('target', ev): this; dispatch.call(where, ev, data); if (ev.isPropagationStopped()) { count-- ; return ; } var index = bound.index(this), length = _AN_Read_length('length', bound), child, sub; while (++index < length && (child = bound[index]) && (isWindow || $.contains(where, child))){ dispatch.call(child, ev, data); if (ev.isPropagationStopped()) { while (++index < length && (sub = bound[index])){ if (!$.contains(child, sub)) { index-- ; break ; } } } } ev.stopImmediatePropagation(); count-- ; } else { handleObj.origHandler.call(this, ev, data); } } ; } } ; $([document, window] ).bind(name, function (){ } ); return $.event.special[name]; } ; return $; } );