event-custom-debug.js revision e69255aa5a65f8406ba2fabaf69fe4e1d05daf69
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove(function() {
8a485a720d4a37f68766d1022297dca2bd4549b7Allen Rabinovich * Allows for the insertion of methods that are executed before or after
8a485a720d4a37f68766d1022297dca2bd4549b7Allen Rabinovich * a specified method
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * Cache of objects touched by the utility
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @property objs
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * Execute the supplied method before the specified function
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @method before
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param fn {Function} the function to execute
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param obj the object hosting the method to displace
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param sFn {string} the name of the method to displace
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param c The execution context for fn
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @return {string} handle for the subscription
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // Y.log('Do before: ' + sFn, 'info', 'event');
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove var f = fn, a;
e0047f099a90bbd6805761981cd17c03e354e237Allen Rabinovich a = [fn, c].concat(Y.Array(arguments, 4, true));
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * Execute the supplied method after the specified function
0a90ef96933fdee0702794b1276c18fc95609b85Allen Rabinovich * @method after
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param fn {Function} the function to execute
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param obj the object hosting the method to displace
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param sFn {string} the name of the method to displace
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param c The execution context for fn
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @return {string} handle for the subscription
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * Execute the supplied method after the specified function
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @method _inject
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param when {string} before or after
8a485a720d4a37f68766d1022297dca2bd4549b7Allen Rabinovich * @param fn {Function} the function to execute
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param obj the object hosting the method to displace
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param sFn {string} the name of the method to displace
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param c The execution context for fn
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @return {string} handle for the subscription
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // object id
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // create a map entry for the obj if it doesn't exist
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // create a map entry for the method if it doesn't exist
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // re-route the method to our wrapper
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove function() {
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // subscriber id
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // register the callback
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * Detach a before or after subscription
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @method detach
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param handle {string} the subscription handle
8a485a720d4a37f68766d1022297dca2bd4549b7Allen Rabinovich//////////////////////////////////////////////////////////////////////////
0a90ef96933fdee0702794b1276c18fc95609b85Allen Rabinovich * Wrapper for a displaced method with aop enabled
8a485a720d4a37f68766d1022297dca2bd4549b7Allen Rabinovich * @class Do.Method
8a485a720d4a37f68766d1022297dca2bd4549b7Allen Rabinovich * @constructor
8a485a720d4a37f68766d1022297dca2bd4549b7Allen Rabinovich * @param obj The object to operate on
8a485a720d4a37f68766d1022297dca2bd4549b7Allen Rabinovich * @param sFn The name of the method to displace
8a485a720d4a37f68766d1022297dca2bd4549b7Allen Rabinovich // this.before = [];
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // this.after = [];
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * Register a aop subscriber
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @method register
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param sid {string} the subscriber id
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param fn {Function} the function to execute
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove * @param when {string} when to execute the function
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan GroveY.Do.Method.prototype.register = function (sid, fn, when) {
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // this.after.push(fn);
fa9bf5a0f37d4bea5588392a65e67c1197cc89e0Ryan Grove // this.before.push(fn);
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich * Unregister a aop subscriber
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich * @method delete
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich * @param sid {string} the subscriber id
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich * @param fn {Function} the function to execute
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich * @param when {string} when to execute the function
71bbbe94567d63ab107a7eab263595bcc6e47833Allen RabinovichY.Do.Method.prototype._delete = function (sid) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich // Y.log('Y.Do._delete: ' + sid, 'info', 'Event');
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich * Execute the wrapped method
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich * @method exec
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich // execute before
prevented = true;
if (!prevented) {
for (i in af) {
return ret;
this.stopPropagation = function() {
e.stopPropagation();
this.stopImmediatePropagation = function() {
this.preventDefault = function() {
e.preventDefault();
CONFIGS = [
detach: function() {
if (this.evt) {
this.context = Y;
this.subscribers = {};
// this.configured = true;
this.afters = {};
this.preventable = true;
this.bubbles = true;
this.applyConfig(o, true);
_YUI_EVENT: true,
if (!fn) {
this.hasAfters = true;
this.hasSubscribers = true;
return new Y.EventHandle(this, s);
if (!fn) {
return this.unsubscribeAll();
for (i in subs) {
s = subs[i];
this._delete(s);
found = true;
return found;
unsubscribe: function() {
_getFacade: function() {
if (!ef) {
o2 = {};
return this._facade;
var ret;
if (this.emitFacade) {
if (!ef) {
if (!this.silent) {
fire: function() {
if (es) {
next: this,
queue: []
fireOnce: true,
if (this.preventedFn) {
if (this.stoppedFn) {
this.fired = true;
hasSub = false;
ef = null;
if (this.emitFacade) {
this._facade = null;
if (this.hasSubscribers) {
for (i in subs) {
if (!hasSub) {
hasSub = true;
s = subs[i];
if (s && s.fn) {
if (false === ret) {
if (this.host !== Y) {
for (i in subs) {
if (!hasSub) {
hasSub = true;
s = subs[i];
if (s && s.fn) {
if (false === ret) {
return this.stopped ? false : true;
unsubscribeAll: function() {
detachAll: function() {
for (i in subs) {
this.subscribers={};
_delete: function(s) {
delete s.fn;
delete s.context;
toString: function() {
return this.type;
stopPropagation: function() {
stopImmediatePropagation: function() {
preventDefault: function() {
if (this.preventable) {
if (immediate) {
this.stopImmediatePropagation();
this.stopPropagation();
this.preventDefault();
this.events = null;
if (a || args) {
return ret;
var c = this.context,
ret = true;
return ret;
if (context) {
toString: function() {
var L = Y.Lang,
return type;
if (!L.isString(t)) {
after = true;
this._yuievt = {
events: {},
targets: {},
config: o,
defaults: {
host: this,
f = fn;
c = context;
ret = {};
c = v.context || c;
if (this instanceof YUI) {
if (Node) {
if (n instanceof Y.NodeList) {
} else if (n instanceof Node) {
if (adapt) {
if (!handle) {
handle = ce._on(fn, context, (arguments.length > 3) ? Y.Array(arguments, 3, true) : null, (after) ? 'after' : true);
if (detachcategory) {
subscribe: function() {
if (handles) {
if (detachcategory) {
if (cat) {
if (type) {
for (i in cat) {
} else if (Y.Node && (this instanceof Y.Node) && ((!shorttype) || (shorttype in Y.Node.DOM_EVENTS))) {
if (this instanceof YUI) {
if (type) {
if (ce) {
for (i in evts) {
return ret;
unsubscribe: function() {
unsubscribeAll: function() {
* 'broadcast': whether or not the YUI instance and YUI global are notified when the event is fired (false)
* 'defaultFn': the default function to execute when this event fires if preventDefault was not called
// this._yuievt.config.prefix
ret = {};
return ret;
//if (ce && !ce.configured) {
if (ce) {
if (opts) {
addTarget: function(o) {
removeTarget: function(o) {
if (!ce) {
return this.bubble(null, a, this);
ret = true;
for (i in targs) {
t = targs[i];
if (!ce) {
return ret;
before: function() {
bubbles: false