The triggering mechanism used by SyntheticEvents.
Implementers should not instantiate these directly. Use the Notifier * provided to the event's implemented on(node, sub, notifier) or * delegate(node, sub, notifier, filter) methods.
on(node, sub, notifier)
delegate(node, sub, notifier, filter)
Executes the subscription callback, passing the firing arguments as the * first parameters to that callback. For events that are configured with * emitFacade=true, it is common practice to pass the triggering DOMEventFacade * as the first parameter. Barring a proper DOMEventFacade or EventFacade * (from a CustomEvent), a new EventFacade will be generated. In that case, if * fire() is called with a simple object, it will be mixed into the facade. * Otherwise, the facade will be prepended to the callback parameters.
For notifiers provided to delegate logic, the first argument should be an * object with a "currentTarget" property to identify what object to * default as 'this' in the callback. Typically this is gleaned from the * DOMEventFacade or EventFacade, but if configured with emitFacade=false, an * object must be provided. In that case, the object will be removed from the * callback parameters.
Additional arguments passed during event subscription will be * automatically added after those passed to fire().
Wrapper class for the integration of new events into the YUI event * infrastructure. Don't instantiate this object directly, use * Y.Event.define(type, config). See that method for details.
Y.Event.define(type, config)
Properties that MAY or SHOULD be specified in the configuration are noted * below and in the description of Y.Event.define.
Y.Event.define
_delete()
Implementers MAY provide this method definition.
Implement this function if the event supports a different * subscription signature. This function is used by both * on() and delegate(). The second parameter * indicates that the event is being subscribed via * delegate().
on()
delegate()
Implementations must remove extra arguments from the args list * before returning. The required args for on() * subscriptions are
[type, callback, target, context, argN...]
The required args for delegate() * subscriptions are
[type, callback, target, filter, context, argN...]
The return value from this function will be stored on the * subscription in the '_extra' property for reference elsewhere.
Implementers MAY override this property.
Whether to prevent multiple subscriptions to this event that are * classified as being the same. By default, this means the subscribed * callback is the same function. See the subMatch * method. Setting this to true will impact performance for high volume * events.
subMatch
Implementers SHOULD provide this method definition.
node.on(type, * fn)
Y.on(type, fn, target)
detach
sub
notifier.fire(e)
Implementation logic for detaching subscriptions done via * node.on(type, fn). This function should clean up any * subscriptions made in the on() phase.
node.on(type, fn)
Implementation logic for subscriptions done via * node.delegate(type, fn, filter) or * Y.delegate(type, fn, container, filter). Like with * on() above, this function should monitor the environment * for the event being fired, and trigger subscription execution by * calling notifier.fire(e).
node.delegate(type, fn, filter)
Y.delegate(type, fn, container, filter)
This function receives a fourth argument, which is the filter * used to identify which Node's are of interest to the subscription. * The filter will be either a boolean function that accepts a target * Node for each hierarchy level as the event bubbles, or a selector * string. To translate selector strings into filter functions, use * Y.delegate.compileFilter(filter).
Y.delegate.compileFilter(filter)
Implementation logic for detaching subscriptions done via * node.delegate(type, fn, filter) or * Y.delegate(type, fn, container, filter). This function * should clean up any subscriptions made in the * delegate() phase.
Y.on(...)
Y.delegate(...)
on(...)
delegate(...)
processArgs(args)
Implement this function if you want extra data extracted during * processArgs to be propagated to subscriptions on a per-node basis. * That is to say, if you call Y.on('xyz', fn, xtra, 'div') * the data returned from processArgs will be shared * across the subscription objects for all the divs. If you want each * subscription to receive unique information, do that processing * here.
Y.on('xyz', fn, xtra, 'div')
The default implementation adds the data extracted by processArgs * to the subscription object as sub._extra.
sub._extra
SyntheticEvent._deleteSub
node.detach(...)
processArgs
Implementers MAY override this to define what constitutes a * "same" subscription. Override implementations should * consider the lack of a comparator as a match, so calling * getSubs() with no arguments will return all subs.
getSubs()
Compares a set of subscription arguments against a Subscription * object to determine if they match. The default implementation * compares the callback function against the second argument passed to * Y.on(...) or node.detach(...) etc.
Defines a new event in the DOM event system. Implementers are * responsible for monitoring for a scenario whereby the event is fired. A * notifier object is provided to the functions identified below. When the * criteria defining the event are met, call notifier.fire( [args] ); to * execute event subscribers.
The first parameter is the name of the event. The second parameter is a * configuration object which define the behavior of the event system when the * new event is subscribed to or detached from. The methods that should be * defined in this configuration object are on, * detach, delegate, and detachDelegate. * You are free to define any other methods or properties needed to define your * event. Be aware, however, that since the object is used to subclass * SyntheticEvent, you should avoid method names used by SyntheticEvent unless * your intention is to override the default behavior.
on
delegate
detachDelegate
This is a list of properties and methods that you can or should specify * in the configuration object:
function (node, subscription, notifier)
subscription
fire()
function (node, subscription, notifier, filter)
Y.delegate
node.delegate
Y.delegate.compileFilter(selectorString)
publishConfig
fire
function (argArray, fromDelegate) Optional method * to extract any additional arguments from the subscription * signature. Using this allows on or * delegate signatures like * node.on("hover", overCallback, * outCallback).
function (argArray, fromDelegate)
node.on("hover", overCallback, * outCallback)
When processing an atypical argument signature, make sure the * args array is returned to the normal signature before returning * from the function. For example, in the "hover" example * above, the outCallback needs to be spliced * out of the array. The expected signature of the args array for * on() subscriptions is:
outCallback
splice
* [type, callback, target, contextOverride, argN...] *
[type, callback, target, contextOverride, argN...]
And for delegate():
* [type, callback, target, filter, contextOverride, argN...] *
[type, callback, target, filter, contextOverride, argN...]
where target is the node the event is being * subscribed for. You can see these signatures documented for * Y.on() and Y.delegate() respectively.
target
Y.on()
Y.delegate()
Whatever gets returned from the function will be stored on the * subscription object under * subscription._extra.
subscription._extra
function (sub, args) Compares a set of * subscription arguments against a Subscription object to determine * if they match. The default implementation compares the callback * function against the second argument passed to * Y.on(...) or node.detach(...) etc.
function (sub, args)