event-custom-complex.js revision 78d3c37c02e77731a25f370f9fac264ef51f01a9
/**
* Adds event facades, preventable default behavior, and bubbling.
* events.
* @module event-custom
* @submodule event-custom-complex
*/
var FACADE,
EMPTY = {},
/**
* 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 || EMPTY;
this._event = e;
/**
* The arguments passed to fire
* @property details
* @type Array
*/
/**
* The event type, this can be overridden by the fire() payload
* @property type
* @type string
*/
/**
* The real event type
* @property type
* @type string
*/
//////////////////////////////////////////////////////
/**
* Node reference for the targeted eventtarget
* @property target
* @type Node
*/
/**
* Node reference for the element that the listener was attached to.
* @property currentTarget
* @type Node
*/
this.currentTarget = currentTarget;
/**
* Node reference to the relatedTarget
* @property relatedTarget
* @type Node
*/
this.relatedTarget = e.relatedTarget;
};
Y.extend(Y.EventFacade, Object, {
/**
* Stops the propagation to the next bubble target
* @method stopPropagation
*/
stopPropagation: function() {
this._event.stopPropagation();
this.stopped = 1;
},
/**
* Stops the propagation to the next bubble target and
* prevents any additional listeners from being exectued
* on the current target.
* @method stopImmediatePropagation
*/
stopImmediatePropagation: function() {
this._event.stopImmediatePropagation();
this.stopped = 2;
},
/**
* Prevents the event's default behavior
* @method preventDefault
*/
preventDefault: function() {
this._event.preventDefault();
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
*/
this.prevented = 1;
}
});
// queue this event if the current item in the queue bubbles
return true;
}
}
// id of the first event in the stack
stopped: 0,
prevented: 0,
bubbling: null,
// defaultFnQueue: new Y.Queue(),
afterQueue: new Y.Queue(),
queue: []
};
events = new Y.EventTarget({
fireOnce: true,
});
}
// self.log("Firing " + self + ", " + "args: " + args);
} else {
}
// if (subCount) {
if (subs[0]) {
// self._procSubs(Y.merge(self.subscribers), args, ef);
}
// bubble if this is hosted in an event target and propagation has not been stopped
// self.bubbling = true;
// if (host !== ef.target || es.type != self.type) {
}
// self.bubbling = false;
}
if (self.preventedFn) {
}
}
// broadcast listeners are fired as discreet events on the
// YUI instance and potentially the YUI global.
// Queue the after
next();
}
} else {
if (es.execDefaultCnt) {
s.postponed = true;
});
}
});
}
}
ce = q[0];
// set up stack to allow the next item to be processed
}
}
}
return ret;
};
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
// Allow the event type to be faked
}
// update the details field with the arguments
// ef.type = this.type;
// use the original target when the event bubbled to this target
return this._facade;
};
/**
* Stop propagation to bubble targets
* @for CustomEvent
* @method stopPropagation
*/
CEProto.stopPropagation = function() {
this.stopped = 1;
if (this.stack) {
}
};
/**
* Stops propagation to bubble targets, and prevents any remaining
* subscribers on the current target from executing.
* @method stopImmediatePropagation
*/
CEProto.stopImmediatePropagation = function() {
this.stopped = 2;
if (this.stack) {
}
};
/**
* Prevents the execution of this event's defaultFn
* @method preventDefault
*/
CEProto.preventDefault = function() {
if (this.preventable) {
this.prevented = 1;
if (this.stack) {
}
}
};
/**
* 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();
};
/**
* Registers another EventTarget as a bubble target. Bubble order
* is determined by the order registered. Multiple targets can
* be specified.
*
* Events can only bubble if emitFacade is true.
*
* Included in the event-custom-complex submodule.
*
* @method addTarget
* @param o {EventTarget} the target to add
* @for EventTarget
*/
this._yuievt.hasTargets = true;
};
/**
* Returns an array of bubble targets for this object.
* @method getTargets
* @return EventTarget[]
*/
ETProto.getTargets = function() {
};
/**
* Removes a bubble target
* @method removeTarget
* @param o {EventTarget} the target to remove
* @for EventTarget
*/
ETProto.removeTarget = function(o) {
};
/**
* Propagate an event. Requires the event-custom-complex module.
* @method bubble
* @param evt {CustomEvent} 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,
// continue propagating the event.
if (!ce) {
if (t._yuievt.hasTargets) {
}
} else {
// set the original target to that the target payload on the
// facade is correct.
ce.currentTarget = t;
// default publish may not have emitFacade true -- that
// shouldn't be what the implementer meant to do
ce.emitFacade = true;
ce.originalTarget = null;
// stopPropagation() was called
break;
}
}
}
}
}
return ret;
};
FACADE = new Y.EventFacade();