event-custom-complex.js revision e0a3334414dd1b202d0a0e57b003a6b84c28d9d8
/**
* Adds event facades, preventable default behavior, and bubbling.
* events.
* @module event-custom
* @submodule event-custom-complex
*/
(function() {
/**
* Wraps and protects a custom event for use when emitFacade is set to true.
* Requires the event-custom-complex module
* @class EventFacade
* @param e {Event} the custom event
* @param currentTarget {HTMLElement} the element the listener was attached to
*/
Y.EventFacade = function(e, currentTarget) {
e = e || {};
/**
* The arguments passed to fire
* @property details
* @type Array
*/
/**
* The event type
* @property type
* @type string
*/
//////////////////////////////////////////////////////
/**
* Node reference for the targeted eventtarget
* @propery target
* @type Node
*/
/**
* Node reference for the element that the listener was attached to.
* @propery currentTarget
* @type Node
*/
this.currentTarget = currentTarget;
/**
* Node reference to the relatedTarget
* @propery relatedTarget
* @type Node
*/
this.relatedTarget = e.relatedTarget;
/**
* Stops the propagation to the next bubble target
* @method stopPropagation
*/
this.stopPropagation = function() {
e.stopPropagation();
};
/**
* Stops the propagation to the next bubble target and
* prevents any additional listeners from being exectued
* on the current target.
* @method stopImmediatePropagation
*/
this.stopImmediatePropagation = function() {
};
/**
* Prevents the event's default behavior
* @method preventDefault
*/
this.preventDefault = function() {
e.preventDefault();
};
/**
* Stops the event propagation and prevents the default
* event behavior.
* @method halt
* @param immediate {boolean} if true additional listeners
* on the current target will not be executed
*/
};
};
if (es) {
// queue this event if the current item in the queue bubbles
return true;
}
} else {
Y.Env._eventstack = {
// id of the first event in the stack
next: this,
stopped: 0,
prevented: 0,
queue: []
};
}
this.stopped = 0;
this.prevented = 0;
events = new Y.EventTarget({
fireOnce: true,
});
if (this.preventedFn) {
}
if (this.stoppedFn) {
}
// this.log("Firing " + this + ", " + "args: " + args);
this._facade = null; // kill facade to eliminate stale properties
} else {
}
if (this.hasSubscribers) {
}
// bubble if this is hosted in an event target and propagation has not been stopped
}
// execute the default behavior if not prevented
}
// broadcast listeners are fired as discreet events on the
// YUI instance and potentially the YUI global.
this._broadcast(args);
// process after listeners. If the default behavior was
// prevented, the after events don't fire.
}
ce = q[0];
// set up stack to allow the next item to be processed
}
Y.Env._eventstack = null;
}
return this.stopped ? false : true;
};
CEProto._getFacade = function() {
if (!ef) {
}
// if the first argument is an object literal, apply the
// properties to the event facade
o2 = {};
// protect the event facade properties
// mix the data
// restore ef
}
// update the details field with the arguments
// ef.type = this.type;
return this._facade;
};
/**
* Stop propagation to bubble targets
* @for CustomEvent
* @method stopPropagation
*/
CEProto.stopPropagation = function() {
this.stopped = 1;
};
/**
* Stops propagation to bubble targets, and prevents any remaining
* subscribers on the current target from executing.
* @method stopImmediatePropagation
*/
CEProto.stopImmediatePropagation = function() {
this.stopped = 2;
};
/**
* Prevents the execution of this event's defaultFn
* @method preventDefault
*/
CEProto.preventDefault = function() {
if (this.preventable) {
this.prevented = 1;
}
};
/**
* Stops the event propagation and prevents the default
* event behavior.
* @method halt
* @param immediate {boolean} if true additional listeners
* on the current target will not be executed
*/
if (immediate) {
this.stopImmediatePropagation();
} else {
this.stopPropagation();
}
this.preventDefault();
};
/**
* Propagate an event. Requires the event-custom-complex module.
* @method bubble
* @param evt {Event.Custom} the custom event to propagate
* @return {boolean} the aggregated return value from Event.Custom.fire
* @for EventTarget
*/
for (i in targs) {
if (targs.hasOwnProperty(i)) {
t = targs[i];
// if this event was not published on the bubble target,
// publish it with sensible default properties
if (!ce) {
if (t._yuievt.hasTargets) {
}
} else {
ce.currentTarget = t;
// stopPropagation() was called
break;
}
}
}
}
}
return ret;
};
FACADE = new Y.EventFacade();
})();