3
Copyright 2012 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
var GLOBAL_ENV = YUI.Env;
10
if (!GLOBAL_ENV._ready) {
11
GLOBAL_ENV._ready = function() {
12
GLOBAL_ENV.DOMReady = true;
13
GLOBAL_ENV.remove(YUI.config.doc, 'DOMContentLoaded', GLOBAL_ENV._ready);
16
GLOBAL_ENV.add(YUI.config.doc, 'DOMContentLoaded', GLOBAL_ENV._ready);
19
YUI.add('event-base', function(Y) {
22
* DOM event listener abstraction layer
24
* @submodule event-base
28
* The domready event fires at the moment the browser's DOM is
29
* usable. In most cases, this is before images are fully
30
* downloaded, allowing you to provide a more responsive user
33
* In YUI 3, domready subscribers will be notified immediately if
34
* that moment has already passed when the subscription is created.
36
* One exception is if the yui.js file is dynamically injected into
37
* the page. If this is done, you must tell the YUI instance that
38
* you did this in order for DOMReady (and window load events) to
39
* fire normally. That configuration option is 'injected' -- set
40
* it to true if the yui.js script is not included inline.
42
* This method is part of the 'event-ready' module, which is a
43
* submodule of 'event'.
48
Y.publish('domready', {
53
if (YUI.Env.DOMReady) {
56
Y.Do.before(function() { Y.fire('domready'); }, YUI.Env, '_ready');
60
* Custom event engine, DOM event listener abstraction layer, synthetic DOM
63
* @submodule event-base
67
* Wraps a DOM event, properties requiring browser abstraction are
68
* fixed here. Provids a security layer when required.
69
* @class DOMEventFacade
70
* @param ev {Event} the DOM event
71
* @param currentTarget {HTMLElement} the element the listener was attached to
72
* @param wrapper {Event.Custom} the custom event wrapper for this DOM event
80
* webkit key remapping required for Safari < 3.1
81
* @property webkitKeymap
90
63277: 34, // page down
91
25: 9, // SHIFT-TAB (Safari provides a different key code in
92
// this case, even though the shiftKey modifier is set)
99
* Returns a wrapped node. Intended to be used on event targets,
100
* so it will return the node's parent if the target is a text
103
* If accessing a property of the node throws an error, this is
104
* probably the anonymous div wrapper Gecko adds inside text
105
* nodes. This likely will only occur when attempting to access
106
* the relatedTarget. In this case, we now return null because
107
* the anonymous div is completely useless and we do not know
108
* what the related target was because we can't even get to
109
* the element's parent node.
114
resolve = function(n) {
119
if (n && 3 == n.nodeType) {
129
DOMEventFacade = function(ev, currentTarget, wrapper) {
131
this._currentTarget = currentTarget;
132
this._wrapper = wrapper || EMPTY;
138
Y.extend(DOMEventFacade, Object, {
143
overrides = this._wrapper.overrides,
147
currentTarget = this._currentTarget;
149
this.altKey = e.altKey;
150
this.ctrlKey = e.ctrlKey;
151
this.metaKey = e.metaKey;
152
this.shiftKey = e.shiftKey;
153
this.type = (overrides && overrides.type) || e.type;
154
this.clientX = e.clientX;
155
this.clientY = e.clientY;
160
// charCode is unknown in keyup, keydown. keyCode is unknown in keypress.
161
// FF 3.6 - 8+? pass 0 for keyCode in keypress events.
162
// Webkit, FF 3.6-8+?, and IE9+? pass 0 for charCode in keydown, keyup.
163
// Webkit and IE9+? duplicate charCode in keyCode.
164
// Opera never sets charCode, always keyCode (though with the charCode).
165
// IE6-8 don't set charCode or which.
166
// All browsers other than IE6-8 set which=keyCode in keydown, keyup, and
167
// which=charCode in keypress.
169
// Moral of the story: (e.which || e.keyCode) will always return the
170
// known code for that key event phase. e.keyCode is often different in
171
// keypress from keydown and keyup.
172
c = e.keyCode || e.charCode;
174
if (ua.webkit && (c in webkitKeymap)) {
180
// Fill in e.which for IE - implementers should always use this over
181
// e.keyCode or e.charCode.
182
this.which = e.which || e.charCode || c;
183
// this.button = e.button;
184
this.button = this.which;
186
this.target = resolve(e.target);
187
this.currentTarget = resolve(currentTarget);
188
this.relatedTarget = resolve(e.relatedTarget);
190
if (e.type == "mousewheel" || e.type == "DOMMouseScroll") {
191
this.wheelDelta = (e.detail) ? (e.detail * -1) : Math.round(e.wheelDelta / 80) || ((e.wheelDelta < 0) ? -1 : 1);
195
this._touch(e, currentTarget, this._wrapper);
199
stopPropagation: function() {
200
this._event.stopPropagation();
201
this._wrapper.stopped = 1;
205
stopImmediatePropagation: function() {
207
if (e.stopImmediatePropagation) {
208
e.stopImmediatePropagation();
210
this.stopPropagation();
212
this._wrapper.stopped = 2;
216
preventDefault: function(returnValue) {
219
e.returnValue = returnValue || false;
220
this._wrapper.prevented = 1;
224
halt: function(immediate) {
226
this.stopImmediatePropagation();
228
this.stopPropagation();
231
this.preventDefault();
236
DOMEventFacade.resolve = resolve;
237
Y.DOM2EventFacade = DOMEventFacade;
238
Y.DOMEventFacade = DOMEventFacade;
243
* @type {Native DOM Event}
248
The name of the event (e.g. "click")
255
`true` if the "alt" or "option" key is pressed.
262
`true` if the shift key is pressed.
269
`true` if the "Windows" key on a Windows keyboard, "command" key on an
270
Apple keyboard, or "meta" key on other keyboards is pressed.
277
`true` if the "Ctrl" or "control" key is pressed.
284
* The X location of the event on the page (including scroll)
290
* The Y location of the event on the page (including scroll)
296
* The X location of the event in the viewport
302
* The Y location of the event in the viewport
308
* The keyCode for key events. Uses charCode if keyCode is not available
314
* The charCode for key events. Same as keyCode
320
* The button that was pushed. 1 for left click, 2 for middle click, 3 for
321
* right click. This is only reliably populated on `mouseup` events.
327
* The button that was pushed. Same as button.
333
* Node reference for the targeted element
339
* Node reference for the element that the listener was attached to.
340
* @property currentTarget
345
* Node reference to the relatedTarget
346
* @property relatedTarget
351
* Number representing the direction and velocity of the movement of the mousewheel.
352
* Negative is down, the higher the number, the faster. Applies to the mousewheel event.
353
* @property wheelDelta
358
* Stops the propagation to the next bubble target
359
* @method stopPropagation
363
* Stops the propagation to the next bubble target and
364
* prevents any additional listeners from being exectued
365
* on the current target.
366
* @method stopImmediatePropagation
370
* Prevents the event's default behavior
371
* @method preventDefault
372
* @param returnValue {string} sets the returnValue of the event to this value
373
* (rather than the default false value). This can be used to add a customized
374
* confirmation query to the beforeunload event).
378
* Stops the event propagation and prevents the default
381
* @param immediate {boolean} if true additional listeners
382
* on the current target will not be executed
386
* The event utility provides functions to add and remove event listeners,
387
* event cleansing. It also tries to automatically remove listeners it
388
* registers during the unload event.
391
* @submodule event-base
395
* The event utility provides functions to add and remove event listeners,
396
* event cleansing. It also tries to automatically remove listeners it
397
* registers during the unload event.
403
Y.Env.evt.dom_wrappers = {};
404
Y.Env.evt.dom_map = {};
406
var _eventenv = Y.Env.evt,
410
remove = YUI.Env.remove,
412
onLoad = function() {
413
YUI.Env.windowLoaded = true;
415
remove(win, "load", onLoad);
418
onUnload = function() {
422
EVENT_READY = 'domready',
424
COMPAT_ARG = '~yui|2|compat~',
426
shouldIterate = function(o) {
428
return (o && typeof o !== "string" && Y.Lang.isNumber(o.length) &&
429
!o.tagName && !o.alert);
436
// aliases to support DOM event subscription clean up when the last
437
// subscriber is detached. deleteAndClean overrides the DOM event's wrapper
438
// CustomEvent _delete method.
439
_ceProtoDelete = Y.CustomEvent.prototype._delete,
440
_deleteAndClean = function(s) {
441
var ret = _ceProtoDelete.apply(this, arguments);
443
if (!this.subCount && !this.afterCount) {
444
Y.Event._clean(this);
453
* True after the onload event has fired
454
* @property _loadComplete
459
var _loadComplete = false,
462
* The number of times to poll after window.onload. This number is
463
* increased if additional late-bound handlers are requested after
465
* @property _retryCount
472
* onAvailable listeners
480
* Custom event wrappers for DOM events. Key is
481
* 'event:' + Element uid stamp + event type
482
* @property _wrappers
483
* @type Y.Event.Custom
487
_wrappers = _eventenv.dom_wrappers,
489
_windowLoadKey = null,
492
* Custom event wrapper map DOM events. Key is
493
* Element uid stamp. Each item is a hash of custom event
494
* wrappers as provided in the _wrappers collection. This
495
* provides the infrastructure for getListeners.
496
* @property _el_events
500
_el_events = _eventenv.dom_map;
505
* The number of times we should look for elements that are not
506
* in the DOM at the time the event is requested after the document
507
* has been loaded. The default is 1000@amp;40 ms, so it will poll
508
* for 40 seconds or until all outstanding handlers are bound
509
* (whichever comes first).
510
* @property POLL_RETRYS
518
* The poll interval in milliseconds
519
* @property POLL_INTERVAL
527
* addListener/removeListener can throw errors in unexpected scenarios.
528
* These errors are suppressed, the method returns false, and this property
530
* @property lastError
539
* @property _interval
546
* document readystate poll handle
554
* True when the document is initially usable
562
* @method startInterval
566
startInterval: function() {
567
if (!Event._interval) {
568
Event._interval = setInterval(Event._poll, Event.POLL_INTERVAL);
573
* Executes the supplied callback when the item with the supplied
574
* id is found. This is meant to be used to execute behavior as
575
* soon as possible as the page loads. If you use this after the
576
* initial page load it will poll for a fixed time for the element.
577
* The number of times it will poll and the frequency are
578
* configurable. By default it will poll for 10 seconds.
580
* <p>The callback is executed with a single parameter:
581
* the custom object parameter, if provided.</p>
583
* @method onAvailable
585
* @param {string||string[]} id the id of the element, or an array
586
* of ids to look for.
587
* @param {function} fn what to execute when the element is found.
588
* @param {object} p_obj an optional object to be passed back as
590
* @param {boolean|object} p_override If set to true, fn will execute
591
* in the context of p_obj, if set to an object it
592
* will execute in the context of that object
593
* @param checkContent {boolean} check child node readiness (onContentReady)
595
* @deprecated Use Y.on("available")
597
// @TODO fix arguments
598
onAvailable: function(id, fn, p_obj, p_override, checkContent, compat) {
600
var a = Y.Array(id), i, availHandle;
603
for (i=0; i<a.length; i=i+1) {
608
override: p_override,
609
checkReady: checkContent,
613
_retryCount = this.POLL_RETRYS;
615
// We want the first test to be immediate, but async
616
setTimeout(Event._poll, 0);
618
availHandle = new Y.EventHandle({
620
_delete: function() {
621
// set by the event system for lazy DOM listeners
622
if (availHandle.handle) {
623
availHandle.handle.detach();
629
// otherwise try to remove the onAvailable listener(s)
630
for (i = 0; i < a.length; i++) {
631
for (j = 0; j < _avail.length; j++) {
632
if (a[i] === _avail[j].id) {
645
* Works the same way as onAvailable, but additionally checks the
646
* state of sibling elements to determine if the content of the
647
* available element is safe to modify.
649
* <p>The callback is executed with a single parameter:
650
* the custom object parameter, if provided.</p>
652
* @method onContentReady
654
* @param {string} id the id of the element to look for.
655
* @param {function} fn what to execute when the element is ready.
656
* @param {object} obj an optional object to be passed back as
658
* @param {boolean|object} override If set to true, fn will execute
659
* in the context of p_obj. If an object, fn will
660
* exectute in the context of that object
663
* @deprecated Use Y.on("contentready")
665
// @TODO fix arguments
666
onContentReady: function(id, fn, obj, override, compat) {
667
return Event.onAvailable(id, fn, obj, override, true, compat);
671
* Adds an event listener
675
* @param {String} type The type of event to append
676
* @param {Function} fn The method the event invokes
677
* @param {String|HTMLElement|Array|NodeList} el An id, an element
678
* reference, or a collection of ids and/or elements to assign the
680
* @param {Object} context optional context object
681
* @param {Boolean|object} args 0..n arguments to pass to the callback
682
* @return {EventHandle} an object to that can be used to detach the listener
687
attach: function(type, fn, el, context) {
688
return Event._attach(Y.Array(arguments, 0, true));
691
_createWrapper: function (el, type, capture, compat, facade) {
695
key = 'event:' + ek + type;
697
if (false === facade) {
705
cewrapper = _wrappers[key];
710
cewrapper = Y.publish(key, {
713
contextFn: function() {
717
cewrapper.nodeRef = cewrapper.nodeRef || Y.one(cewrapper.el);
718
return cewrapper.nodeRef;
723
cewrapper.overrides = {};
725
// for later removeListener calls
728
cewrapper.domkey = ek;
729
cewrapper.type = type;
730
cewrapper.fn = function(e) {
731
cewrapper.fire(Event.getEvent(e, el, (compat || (false === facade))));
733
cewrapper.capture = capture;
735
if (el == win && type == "load") {
736
// window load happens once
737
cewrapper.fireOnce = true;
738
_windowLoadKey = key;
740
cewrapper._delete = _deleteAndClean;
742
_wrappers[key] = cewrapper;
743
_el_events[ek] = _el_events[ek] || {};
744
_el_events[ek][key] = cewrapper;
746
add(el, type, cewrapper.fn, capture);
753
_attach: function(args, conf) {
756
handles, oEl, cewrapper, context,
757
fireNow = false, ret,
761
facade = conf && conf.facade,
762
capture = conf && conf.capture,
763
overrides = conf && conf.overrides;
765
if (args[args.length-1] === COMPAT_ARG) {
769
if (!fn || !fn.call) {
770
// throw new TypeError(type + " attach call failed, callback undefined");
774
// The el argument can be an array of elements or element ids.
775
if (shouldIterate(el)) {
779
Y.each(el, function(v, k) {
781
handles.push(Event._attach(args.slice(), conf));
784
// return (handles.length === 1) ? handles[0] : handles;
785
return new Y.EventHandle(handles);
787
// If the el argument is a string, we assume it is
788
// actually the id of the element. If the page is loaded
789
// we convert el to the actual element, otherwise we
790
// defer attaching the event until the element is
792
} else if (Y.Lang.isString(el)) {
794
// oEl = (compat) ? Y.DOM.byId(el) : Y.Selector.query(el);
797
oEl = Y.DOM.byId(el);
800
oEl = Y.Selector.query(el);
802
switch (oEl.length) {
811
return Event._attach(args, conf);
819
// Not found = defer adding the event until the element is available
822
ret = Event.onAvailable(el, function() {
824
ret.handle = Event._attach(args, conf);
826
}, Event, true, false, compat);
833
// Element should be an html element or node
838
if (Y.Node && Y.instanceOf(el, Y.Node)) {
839
el = Y.Node.getDOMNode(el);
842
cewrapper = Event._createWrapper(el, type, capture, compat, facade);
844
Y.mix(cewrapper.overrides, overrides);
847
if (el == win && type == "load") {
849
// if the load is complete, fire immediately.
850
// all subscribers, including the current one
852
if (YUI.Env.windowLoaded) {
863
// set context to the Node if not specified
864
// ret = cewrapper.on.apply(cewrapper, trimmedArgs);
865
ret = cewrapper._on(fn, context, (args.length > 4) ? args.slice(4) : null);
876
* Removes an event listener. Supports the signature the event was bound
877
* with, but the preferred way to remove listeners is using the handle
878
* that is returned when using Y.on
882
* @param {String} type the type of event to remove.
883
* @param {Function} fn the method the event invokes. If fn is
884
* undefined, then all event handlers for the type of event are
886
* @param {String|HTMLElement|Array|NodeList|EventHandle} el An
887
* event handle, an id, an element reference, or a collection
888
* of ids and/or elements to remove the listener from.
889
* @return {boolean} true if the unbind was successful, false otherwise.
892
detach: function(type, fn, el, obj) {
894
var args=Y.Array(arguments, 0, true), compat, l, ok, i,
897
if (args[args.length-1] === COMPAT_ARG) {
902
if (type && type.detach) {
903
return type.detach();
906
// The el argument can be a string
907
if (typeof el == "string") {
909
// el = (compat) ? Y.DOM.byId(el) : Y.all(el);
913
el = Y.Selector.query(el);
921
// return Event.detach.apply(Event, args);
930
return el.detach.apply(el, args);
931
// The el argument can be an array of elements or element ids.
932
} else if (shouldIterate(el)) {
934
for (i=0, l=el.length; i<l; ++i) {
936
ok = ( Y.Event.detach.apply(Y.Event, args) && ok );
942
if (!type || !fn || !fn.call) {
943
return Event.purgeElement(el, false, type);
946
id = 'event:' + Y.stamp(el) + type;
950
return ce.detach(fn);
958
* Finds the event in the window object, the caller's arguments, or
959
* in the arguments of another method in the callstack. This is
960
* executed automatically for events registered through the event
961
* manager, so the implementer should not normally need to execute
962
* this function at all.
964
* @param {Event} e the event parameter from the handler
965
* @param {HTMLElement} el the element the listener was attached to
966
* @return {Event} the event
969
getEvent: function(e, el, noFacade) {
970
var ev = e || win.event;
972
return (noFacade) ? ev :
973
new Y.DOMEventFacade(ev, el, _wrappers['event:' + Y.stamp(el) + e.type]);
977
* Generates an unique ID for the element if it does not already
980
* @param el the element to create the id for
981
* @return {string} the resulting id of the element
984
generateId: function(el) {
985
return Y.DOM.generateID(el);
989
* We want to be able to use getElementsByTagName as a collection
990
* to attach a group of events to. Unfortunately, different
991
* browsers return different types of collections. This function
992
* tests to determine if the object is array-like. It will also
993
* fail if the object is an array, but is empty.
994
* @method _isValidCollection
995
* @param o the object to test
996
* @return {boolean} true if the object is array-like and populated
997
* @deprecated was not meant to be used directly
1001
_isValidCollection: shouldIterate,
1004
* hook up any deferred listeners
1009
_load: function(e) {
1010
if (!_loadComplete) {
1011
_loadComplete = true;
1013
// Just in case DOMReady did not go off for some reason
1016
Y.fire(EVENT_READY);
1019
// Available elements may not have been detected before the
1020
// window load event fires. Try to find them now so that the
1021
// the user is more likely to get the onAvailable notifications
1022
// before the window load notification
1028
* Polling function that runs before the onload event fires,
1029
* attempting to attach to DOM Nodes as soon as they are
1040
if (Y.UA.ie && !YUI.Env.DOMReady) {
1041
// Hold off if DOMReady has not fired and check current
1042
// readyState to protect against the IE operation aborted
1044
Event.startInterval();
1048
Event.locked = true;
1050
// keep trying until after the page is loaded. We need to
1051
// check the page load state prior to trying to bind the
1052
// elements so that we can be certain all elements have been
1053
// tested appropriately
1054
var i, len, item, el, notAvail, executeItem,
1055
tryAgain = !_loadComplete;
1058
tryAgain = (_retryCount > 0);
1064
executeItem = function (el, item) {
1065
var context, ov = item.override;
1068
if (item.override) {
1077
item.fn.call(context, item.obj);
1079
context = item.obj || Y.one(el);
1080
item.fn.apply(context, (Y.Lang.isArray(ov)) ? ov : []);
1087
for (i=0,len=_avail.length; i<len; ++i) {
1089
if (item && !item.checkReady) {
1091
// el = (item.compat) ? Y.DOM.byId(item.id) : Y.one(item.id);
1092
el = (item.compat) ? Y.DOM.byId(item.id) : Y.Selector.query(item.id, null, true);
1095
executeItem(el, item);
1098
notAvail.push(item);
1104
for (i=0,len=_avail.length; i<len; ++i) {
1106
if (item && item.checkReady) {
1108
// el = (item.compat) ? Y.DOM.byId(item.id) : Y.one(item.id);
1109
el = (item.compat) ? Y.DOM.byId(item.id) : Y.Selector.query(item.id, null, true);
1112
// The element is available, but not necessarily ready
1113
// @todo should we test parentNode.nextSibling?
1114
if (_loadComplete || (el.get && el.get('nextSibling')) || el.nextSibling) {
1115
executeItem(el, item);
1119
notAvail.push(item);
1124
_retryCount = (notAvail.length === 0) ? 0 : _retryCount - 1;
1127
// we may need to strip the nulled out items here
1128
Event.startInterval();
1130
clearInterval(Event._interval);
1131
Event._interval = null;
1134
Event.locked = false;
1141
* Removes all listeners attached to the given element via addListener.
1142
* Optionally, the node's children can also be purged.
1143
* Optionally, you can specify a specific type of event to remove.
1144
* @method purgeElement
1145
* @param {HTMLElement} el the element to purge
1146
* @param {boolean} recurse recursively purge this element's children
1147
* as well. Use with caution.
1148
* @param {string} type optional type of listener to purge. If
1149
* left out, all listeners will be removed
1152
purgeElement: function(el, recurse, type) {
1153
// var oEl = (Y.Lang.isString(el)) ? Y.one(el) : el,
1154
var oEl = (Y.Lang.isString(el)) ? Y.Selector.query(el, null, true) : el,
1155
lis = Event.getListeners(oEl, type), i, len, children, child;
1157
if (recurse && oEl) {
1159
children = Y.Selector.query('*', oEl);
1161
len = children.length;
1162
for (; i < len; ++i) {
1163
child = Event.getListeners(children[i], type);
1165
lis = lis.concat(child);
1171
for (i = 0, len = lis.length; i < len; ++i) {
1179
* Removes all object references and the DOM proxy subscription for
1180
* a given event for a DOM node.
1183
* @param wrapper {CustomEvent} Custom event proxy for the DOM
1189
_clean: function (wrapper) {
1190
var key = wrapper.key,
1191
domkey = wrapper.domkey;
1193
remove(wrapper.el, wrapper.type, wrapper.fn, wrapper.capture);
1194
delete _wrappers[key];
1195
delete Y._yuievt.events[key];
1196
if (_el_events[domkey]) {
1197
delete _el_events[domkey][key];
1198
if (!Y.Object.size(_el_events[domkey])) {
1199
delete _el_events[domkey];
1205
* Returns all listeners attached to the given element via addListener.
1206
* Optionally, you can specify a specific type of event to return.
1207
* @method getListeners
1208
* @param el {HTMLElement|string} the element or element id to inspect
1209
* @param type {string} optional type of listener to return. If
1210
* left out, all listeners will be returned
1211
* @return {CustomEvent} the custom event wrapper for the DOM event(s)
1214
getListeners: function(el, type) {
1215
var ek = Y.stamp(el, true), evts = _el_events[ek],
1216
results=[] , key = (type) ? 'event:' + ek + type : null,
1217
adapters = _eventenv.plugins;
1224
// look for synthetic events
1225
if (adapters[type] && adapters[type].eventDef) {
1230
results.push(evts[key]);
1233
// get native events as well
1236
results.push(evts[key]);
1240
Y.each(evts, function(v, k) {
1245
return (results.length) ? results : null;
1249
* Removes all listeners registered by pe.event. Called
1250
* automatically during the unload event.
1255
_unload: function(e) {
1256
Y.each(_wrappers, function(v, k) {
1257
if (v.type == 'unload') {
1262
remove(win, "unload", onUnload);
1266
* Adds a DOM event directly without the caching, cleanup, context adj, etc
1269
* @param {HTMLElement} el the element to bind the handler to
1270
* @param {string} type the type of event handler
1271
* @param {function} fn the callback to invoke
1272
* @param {boolen} capture capture or bubble phase
1279
* Basic remove listener
1281
* @method nativeRemove
1282
* @param {HTMLElement} el the element to bind the handler to
1283
* @param {string} type the type of event handler
1284
* @param {function} fn the callback to invoke
1285
* @param {boolen} capture capture or bubble phase
1289
nativeRemove: remove
1296
if (config.injected || YUI.Env.windowLoaded) {
1299
add(win, "load", onLoad);
1302
// Process onAvailable/onContentReady items when when the DOM is ready in IE
1304
Y.on(EVENT_READY, Event._poll);
1307
add(win, "unload", onUnload);
1309
Event.Custom = Y.CustomEvent;
1310
Event.Subscriber = Y.Subscriber;
1311
Event.Target = Y.EventTarget;
1312
Event.Handle = Y.EventHandle;
1313
Event.Facade = Y.EventFacade;
1320
* DOM event listener abstraction layer
1322
* @submodule event-base
1326
* Executes the callback as soon as the specified element
1327
* is detected in the DOM. This function expects a selector
1328
* string for the element(s) to detect. If you already have
1329
* an element reference, you don't need this event.
1331
* @param type {string} 'available'
1332
* @param fn {function} the callback function to execute.
1333
* @param el {string} an selector for the element(s) to attach
1334
* @param context optional argument that specifies what 'this' refers to.
1335
* @param args* 0..n additional arguments to pass on to the callback function.
1336
* These arguments will be added after the event object.
1337
* @return {EventHandle} the detach handle
1340
Y.Env.evt.plugins.available = {
1341
on: function(type, fn, id, o) {
1342
var a = arguments.length > 4 ? Y.Array(arguments, 4, true) : null;
1343
return Y.Event.onAvailable.call(Y.Event, id, fn, o, a);
1348
* Executes the callback as soon as the specified element
1349
* is detected in the DOM with a nextSibling property
1350
* (indicating that the element's children are available).
1351
* This function expects a selector
1352
* string for the element(s) to detect. If you already have
1353
* an element reference, you don't need this event.
1354
* @event contentready
1355
* @param type {string} 'contentready'
1356
* @param fn {function} the callback function to execute.
1357
* @param el {string} an selector for the element(s) to attach.
1358
* @param context optional argument that specifies what 'this' refers to.
1359
* @param args* 0..n additional arguments to pass on to the callback function.
1360
* These arguments will be added after the event object.
1361
* @return {EventHandle} the detach handle
1364
Y.Env.evt.plugins.contentready = {
1365
on: function(type, fn, id, o) {
1366
var a = arguments.length > 4 ? Y.Array(arguments, 4, true) : null;
1367
return Y.Event.onContentReady.call(Y.Event, id, fn, o, a);
1372
}, '3.5.1' ,{requires:['event-custom-base']});