event-base-debug.js revision c8b2e9f045b5805162fe7488edfd8de133a341ba
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * DOM event listener abstraction layer
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * @module event
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * @submodule event-base
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp(function() {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp// Unlike most of the library, this code has to be executed as soon as it is
4ef2f7e4cb7c7d255be077c47d542199f7bf8607Tripp// introduced into the page -- and it should only be executed one time
a89ad754cce3cfc8aee71760e10217b54020360dTripp// regardless of the number of instances that use it.
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp _ready = function(e) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // Remove the DOMContentLoaded (FF/Opera/Safari)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp D.removeEventListener("DOMContentLoaded", _ready, false);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // create custom event
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp/*! DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // Internet Explorer: use the readyState of a defered script.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // This isolates what appears to be a safe moment to manipulate
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // the DOM prior to when the document's readyState suggests
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // it is safe to do so.
a89ad754cce3cfc8aee71760e10217b54020360dTripp // throws an error if doc is not ready
a89ad754cce3cfc8aee71760e10217b54020360dTripp } catch (ex) {
a89ad754cce3cfc8aee71760e10217b54020360dTripp // FireFox, Opera, Safari 3+: These browsers provide a event for this
a89ad754cce3cfc8aee71760e10217b54020360dTripp D.addEventListener("DOMContentLoaded", _ready, false);
a89ad754cce3cfc8aee71760e10217b54020360dTripp /////////////////////////////////////////////////////////////
a89ad754cce3cfc8aee71760e10217b54020360dTripp(function() {
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * DOM event listener abstraction layer
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @module event
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @submodule event-base
a89ad754cce3cfc8aee71760e10217b54020360dTripp yready = function() {
c093c1aed867e18aa4778708592e1ceb45d18cffTripp // console.log('DOMReady already fired', 'info', 'event');
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp // console.log('setting up before listener', 'info', 'event');
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp // console.log('env: ' + YUI.Env.windowLoaded, 'info', 'event');
527cf651dc5df871799abd06cf589bca3f3a665fTripp(function() {
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * Custom event engine, DOM event listener abstraction layer, synthetic DOM
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @module event
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @submodule event-base
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * Wraps a DOM event, properties requiring browser abstraction are
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * fixed here. Provids a security layer when required.
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * @class DOMEventFacade
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * @param ev {Event} the DOM event
527cf651dc5df871799abd06cf589bca3f3a665fTripp * @param currentTarget {HTMLElement} the element the listener was attached to
527cf651dc5df871799abd06cf589bca3f3a665fTripp * @param wrapper {Event.Custom} the custom event wrapper for this DOM event
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @TODO constants? LEFTBUTTON, MIDDLEBUTTON, RIGHTBUTTON, keys
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTrippvar whitelist = {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp altKey : 1,
c093c1aed867e18aa4778708592e1ceb45d18cffTripp // "button" : 1, // we supply
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "bubbles" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "cancelable" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "charCode" : 1, // we supply
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp cancelBubble : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "currentTarget" : 1, // we supply
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp ctrlKey : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp clientX : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp clientY : 1, // needed?
bf801d6851ecf7ed14742ef3639a077daecb5cf8Tripp detail : 1, // not fully implemented
a4d2446149b07f9e5c32947091dcbcf4d2eee765Tripp // "fromElement" : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp keyCode : 1,
c093c1aed867e18aa4778708592e1ceb45d18cffTripp // "height" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "initEvent" : 1, // need the init events?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "initMouseEvent" : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "initUIEvent" : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "layerX" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "layerY" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp metaKey : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "modifiers" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "offsetX" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "offsetY" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "preventDefault" : 1, // we supply
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "reason" : 1, // IE proprietary
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "relatedTarget" : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "returnValue" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp shiftKey : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "srcUrn" : 1, // IE proprietary
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "srcElement" : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "srcFilter" : 1, IE proprietary
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "stopPropagation" : 1, // we supply
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "target" : 1,
c093c1aed867e18aa4778708592e1ceb45d18cffTripp // "timeStamp" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "toElement" : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "view" : 1,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "which" : 1, // we supply
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // "width" : 1, // needed?
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * webkit key remapping required for Safari < 3.1
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property webkitKeymap
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp 25: 9, // SHIFT-TAB (Safari provides a different key code in
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // this case, even though the shiftKey modifier is set)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Returns a wrapped node. Intended to be used on event targets,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * so it will return the node's parent if the target is a text
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * If accessing a property of the node throws an error, this is
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * probably the anonymous div wrapper Gecko adds inside text
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * nodes. This likely will only occur when attempting to access
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * the relatedTarget. In this case, we now return null because
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * the anonymous div is completely useless and we do not know
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * what the related target was because we can't even get to
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * the element's parent node.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method resolve
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp resolve = function(n) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp } catch(e) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return null;
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp return Y.one(n);
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp// provide a single event with browser abstractions resolved
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp// include all properties for both browers?
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp// include only DOM2 spec properties?
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp// provide browser-specific facade?
a75ebc38c1de401b679953a9b87bd323f0f48d02TrippY.DOMEventFacade = function(ev, currentTarget, wrapper) {
a89ad754cce3cfc8aee71760e10217b54020360dTripp var e = ev, ot = currentTarget, d = Y.config.doc, b = d.body,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp //////////////////////////////////////////////////////
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if (!x && 0 !== x) {
cec703a844d9691646231634fe709f4ea41d278aTripp x += Math.max(d.documentElement.scrollLeft, b.scrollLeft);
cec703a844d9691646231634fe709f4ea41d278aTripp y += Math.max(d.documentElement.scrollTop, b.scrollTop);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._yuifacade = true;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * The native event
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @property _event
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * The X location of the event on the page (including scroll)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property pageX
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type int
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * The Y location of the event on the page (including scroll)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @property pageY
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type int
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp //////////////////////////////////////////////////////
a89ad754cce3cfc8aee71760e10217b54020360dTripp * The keyCode for key events. Uses charCode if keyCode is not available
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @property keyCode
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type int
a89ad754cce3cfc8aee71760e10217b54020360dTripp * The charCode for key events. Same as keyCode
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @property charCode
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type int
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp //////////////////////////////////////////////////////
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * The button that was pushed.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @property button
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type int
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * The button that was pushed. Same as button.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @property which
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type int
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp //////////////////////////////////////////////////////
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Node reference for the targeted element
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @propery target
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Node
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Node reference for the element that the listener was attached to.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @propery currentTarget
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Node
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Node reference to the relatedTarget
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @propery relatedTarget
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type Node
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Number representing the direction and velocity of the movement of the mousewheel.
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * Negative is down, the higher the number, the faster. Applies to the mousewheel event.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @property wheelDelta
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type int
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp if (e.type == "mousewheel" || e.type == "DOMMouseScroll") {
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp this.wheelDelta = (e.detail) ? (e.detail * -1) : Math.round(e.wheelDelta / 80) || ((e.wheelDelta < 0) ? -1 : 1);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp //////////////////////////////////////////////////////
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * Stops the propagation to the next bubble target
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method stopPropagation
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp this.stopPropagation = function() {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Stops the propagation to the next bubble target and
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * prevents any additional listeners from being exectued
a89ad754cce3cfc8aee71760e10217b54020360dTripp * on the current target.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @method stopImmediatePropagation
a89ad754cce3cfc8aee71760e10217b54020360dTripp this.stopImmediatePropagation = function() {
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Prevents the event's default behavior
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @method preventDefault
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @param returnValue {string} sets the returnValue of the event to this value
a89ad754cce3cfc8aee71760e10217b54020360dTripp * (rather than the default false value). This can be used to add a customized
a89ad754cce3cfc8aee71760e10217b54020360dTripp * confirmation query to the beforeunload event).
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Stops the event propagation and prevents the default
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * event behavior.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @method halt
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param immediate {boolean} if true additional listeners
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * on the current target will not be executed
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp(function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * DOM event listener abstraction layer
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @module event
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @submodule event-base
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * The event utility provides functions to add and remove event listeners,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * event cleansing. It also tries to automatically remove listeners it
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * registers during the unload event.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @class Event
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripponLoad = function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripponUnload = function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTrippshouldIterate = function(o) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return (o && typeof o !== "string" && Y.Lang.isNumber(o.length) && !o.tagName && !o.alert);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp } catch(ex) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return false;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTrippEvent = function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * True after the onload event has fired
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property _loadComplete
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type boolean
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * The number of times to poll after window.onload. This number is
cec703a844d9691646231634fe709f4ea41d278aTripp * increased if additional late-bound handlers are requested after
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * the page load.
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @property _retryCount
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * onAvailable listeners
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * @property _avail
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * Custom event wrappers for DOM events. Key is
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * 'event:' + Element uid stamp + event type
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @property _wrappers
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @type Y.Event.Custom
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Custom event wrapper map DOM events. Key is
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Element uid stamp. Each item is a hash of custom event
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * wrappers as provided in the _wrappers collection. This
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * provides the infrastructure for getListeners.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @property _el_events
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * The number of times we should look for elements that are not
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * in the DOM at the time the event is requested after the document
9eaaa502227248d304ac9170902697d02158c1d9Tripp * has been loaded. The default is 1000@amp;40 ms, so it will poll
9eaaa502227248d304ac9170902697d02158c1d9Tripp * for 40 seconds or until all outstanding handlers are bound
9eaaa502227248d304ac9170902697d02158c1d9Tripp * (whichever comes first).
9eaaa502227248d304ac9170902697d02158c1d9Tripp * @property POLL_RETRYS
9eaaa502227248d304ac9170902697d02158c1d9Tripp * @type int
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * The poll interval in milliseconds
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property POLL_INTERVAL
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type int
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * addListener/removeListener can throw errors in unexpected scenarios.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * These errors are suppressed, the method returns false, and this property
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property lastError
b79c07ef87dd1a48a03fc33a91c37d04f3addae2Tripp * @type Error
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * poll handle
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @property _interval
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * document readystate poll handle
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property _dri
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * True when the document is initially usable
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @property DOMReady
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @type boolean
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method startInterval
0fdefaa9ca017edfb76b736c825b34186f33045aTripp startInterval: function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTrippE._interval = setInterval(Y.bind(E._poll, E), E.POLL_INTERVAL);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Executes the supplied callback when the item with the supplied
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * id is found. This is meant to be used to execute behavior as
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * soon as possible as the page loads. If you use this after the
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * initial page load it will poll for a fixed time for the element.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * The number of times it will poll and the frequency are
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * configurable. By default it will poll for 10 seconds.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <p>The callback is executed with a single parameter:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * the custom object parameter, if provided.</p>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method onAvailable
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {string||string[]} id the id of the element, or an array
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * of ids to look for.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {function} fn what to execute when the element is found.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {object} p_obj an optional object to be passed back as
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * a parameter to fn.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {boolean|object} p_override If set to true, fn will execute
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * in the context of p_obj, if set to an object it
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * will execute in the context of that object
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param checkContent {boolean} check child node readiness (onContentReady)
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @deprecated Use Y.on("available")
e0caea9528bfbb244d27129aa9dea5aebc07fc18Tripp // @TODO fix arguments
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp onAvailable: function(id, fn, p_obj, p_override, checkContent, compat) {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // Y.log('onAvailable registered for: ' + id);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // We want the first test to be immediate, but async
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp _delete: function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // set by the event system for lazy DOM listeners
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // otherwise try to remove the onAvailable listener(s)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Works the same way as onAvailable, but additionally checks the
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * state of sibling elements to determine if the content of the
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * available element is safe to modify.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <p>The callback is executed with a single parameter:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * the custom object parameter, if provided.</p>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method onContentReady
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {string} id the id of the element to look for.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {function} fn what to execute when the element is ready.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {object} p_obj an optional object to be passed back as
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * a parameter to fn.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {boolean|object} p_override If set to true, fn will execute
b79c07ef87dd1a48a03fc33a91c37d04f3addae2Tripp * in the context of p_obj. If an object, fn will
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * exectute in the context of that object
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @deprecated Use Y.on("contentready")
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // @TODO fix arguments
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp onContentReady: function(id, fn, p_obj, p_override, compat) {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return this.onAvailable(id, fn, p_obj, p_override, true, compat);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Adds an event listener
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp * @method attach
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * @param {String} type The type of event to append
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Function} fn The method the event invokes
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {String|HTMLElement|Array|NodeList} el An id, an element
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * reference, or a collection of ids and/or elements to assign the
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * listener to.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Object} context optional context object
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {Boolean|object} args 0..n arguments to pass to the callback
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return {EventHandle} an object to that can be used to detach the listener
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _createWrapper: function (el, type, capture, compat, facade) {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp if (false === facade) {
silent: true,
bubbles: false,
contextFn: function() {
if (compat) {
return cewrapper;
compat = true;
handles=[];
if (compat) {
oEl = null;
if (oEl) {
}, E, true, false, compat);
return ret;
if (!el) {
fireNow = true;
if (compat) {
if (fireNow) {
return ret;
compat = true;
if (compat) {
el = null;
if (!el) {
ok = true;
return ok;
if (ce) {
if (!id) {
return id;
_load: function(e) {
if (!_loadComplete) {
_loadComplete = true;
if (Y.fire) {
_poll: function() {
if (this.locked) {
this.startInterval();
this.locked = true;
if (!tryAgain) {
notAvail = [];
if (ov === true) {
if (el) {
_avail[i] = null;
if (el) {
_avail[i] = null;
if (tryAgain) {
this.startInterval();
this._interval = null;
this.locked = false;
if (lis) {
if (!evts) {
if (key) {
_unload: function(e) {
v.detachAll();
delete _wrappers[k];
onLoad();
// Process onAvailable/onContentReady items when when the DOM is ready in IE