event-facade.js revision a4ef7d2a4e172cb1efd9c548d3f239364bcc3dc0
486N/A * Adds event facades, preventable default behavior, and bubbling. 486N/A * @submodule event-custom-complex 486N/A * Wraps and protects a custom event for use when emitFacade is set to true. 486N/A * Requires the event-custom-complex module 486N/A * @param e {Event} the custom event 486N/A * @param currentTarget {HTMLElement} the element the listener was attached to 486N/A * The arguments passed to fire 3488N/A * The event type, this can be overridden by the fire() payload 486N/A ////////////////////////////////////////////////////// 486N/A * Node reference for the targeted eventtarget 2976N/A * Node reference for the element that the listener was attached to. 536N/A * Node reference to the relatedTarget 830N/A * Stops the propagation to the next bubble target 961N/A * Stops the propagation to the next bubble target and 486N/A * prevents any additional listeners from being exectued 486N/A * @method stopImmediatePropagation 2296N/A * Prevents the event's default behavior 2402N/A * Stops the event propagation and prevents the default 2402N/A * @param immediate {boolean} if true additional listeners 2402N/A * on the current target will not be executed 1024N/A // queue this event if the current item in the queue bubbles 961N/A // id of the first event in the stack // defaultFnQueue: new Y.Queue(), // self.log("Firing " + self + ", " + "args: " + args); self.
_facade =
null;
// kill facade to eliminate stale properties // self._procSubs(Y.merge(self.subscribers), args, ef); // bubble if this is hosted in an event target and propagation has not been stopped // if (host !== ef.target || es.type != self.type) { // self.bubbling = false; // execute the default behavior if not prevented // console.log('defaultTargetOnly: ' + self.defaultTargetOnly); // console.log('host === target: ' + (host === ef.target)); // if (self.defaultFn && !self.prevented && ((!self.defaultTargetOnly) || host === es.id === self.id)) { // if (es.id === self.id) { // self.defaultFn.apply(host, args); // while ((next = es.defaultFnQueue.last())) { // es.defaultFnQueue.add(function() { // self.defaultFn.apply(host, args); // broadcast listeners are fired as discreet events on the // YUI instance and potentially the YUI global. // process after listeners. If the default behavior was // prevented, the after events don't fire. // if (self.afterCount && !self.prevented && self.stopped < 2) { // if (subs[1] && !self.prevented && self.stopped < 2) { // // self._procSubs(Y.merge(self.afters), args, ef); // self._procSubs(subs[1], args, ef); // set up stack to allow the next item to be processed // if the first argument is an object literal, apply the // properties to the event facade // protect the event facade properties // Allow the event type to be faked // update the details field with the arguments // use the original target when the event bubbled to this target * Stop propagation to bubble targets * @method stopPropagation * Stops propagation to bubble targets, and prevents any remaining * subscribers on the current target from executing. * @method stopImmediatePropagation * Prevents the execution of this event's defaultFn * Stops the event propagation and prevents the default * @param immediate {boolean} if true additional listeners * on the current target will not be executed * Registers another EventTarget as a bubble target. Bubble order * is determined by the order registered. Multiple targets can * Events can only bubble if emitFacade is true. * Included in the event-custom-complex submodule. * @param o {EventTarget} the target to add * Returns an array of bubble targets for this object. * Removes a bubble target * @param o {EventTarget} the target to remove * Propagate an event. Requires the event-custom-complex module. * @param evt {Event.Custom} the custom event to propagate * @return {boolean} the aggregated return value from Event.Custom.fire // Y.log('Bubbling ' + evt.type); // if this event was not published on the bubble target, // continue propagating the event. // set the original target to that the target payload on the // stopPropagation() was called