event-dom.js.html revision 62e7a7d39cc0c6d25fec20964c26bc35b9fa116a
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>API: event event-dom.js (YUI Library)</title>
<link rel="stylesheet" type="text/css" href="assets/api.css">
<script type="text/javascript" src="assets/api-js"></script>
<script type="text/javascript" src="assets/ac-js"></script>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
<h3>event&nbsp; <span class="subtitle">3.00PR1</span></h3>
<p>
<a href="/index.html">Yahoo! UI Library</a>
&gt; <a href="/module_event.html">event</a>
&gt; event-dom.js (source view)
</p>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="yui-classopts-form">
<span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> Show Private</span>
<span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
<span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> Show Deprecated</span>
</form>
<div id="srcout">
<style>
#doc3 #classopts { display:none; }
</style>
<div class="highlight" ><pre><span class="nx">YUI</span><span class="o">.</span><span class="nx">add</span><span class="o">(</span><span class="s2">&quot;event-dom&quot;</span><span class="o">,</span> <span class="k">function</span><span class="o">(</span><span class="nx">Y</span><span class="o">)</span> <span class="o">{</span>
<span class="c">/*</span>
<span class="c"> * The Event Utility provides utilities for managing DOM Events and tools</span>
<span class="c"> * for building event systems</span>
<span class="c"> *</span>
<span class="c"> * @module event</span>
<span class="c"> * @title Event Utility</span>
<span class="c"> */</span>
<span class="c">/**</span>
<span class="c"> * The event utility provides functions to add and remove event listeners,</span>
<span class="c"> * event cleansing. It also tries to automatically remove listeners it</span>
<span class="c"> * registers during the unload event.</span>
<span class="c"> *</span>
<span class="c"> * @class Event</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="c">/**</span>
<span class="c"> * True after the onload event has fired</span>
<span class="c"> * @property loadComplete</span>
<span class="c"> * @type boolean</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">loadComplete</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * The number of times to poll after window.onload. This number is</span>
<span class="c"> * increased if additional late-bound handlers are requested after</span>
<span class="c"> * the page load.</span>
<span class="c"> * @property _retryCount</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_retryCount</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * onAvailable listeners</span>
<span class="c"> * @property _avail</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_avail</span> <span class="o">=</span> <span class="o">[];</span>
<span class="c">/**</span>
<span class="c"> * Custom event wrappers for DOM events. Key is </span>
<span class="c"> * &#39;event:&#39; + Element uid stamp + event type</span>
<span class="c"> * @property _wrappers</span>
<span class="c"> * @type Y.Event.Custom</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_wrappers</span> <span class="o">=</span> <span class="o">{};</span>
<span class="c">/**</span>
<span class="c"> * Custom event wrapper map DOM events. Key is </span>
<span class="c"> * Element uid stamp. Each item is a hash of custom event</span>
<span class="c"> * wrappers as provided in the _wrappers collection. This</span>
<span class="c"> * provides the infrastructure for getListeners.</span>
<span class="c"> * @property _el_events</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_el_events</span> <span class="o">=</span> <span class="o">{};</span>
<span class="k">return</span> <span class="o">{</span>
<span class="c">/**</span>
<span class="c"> * The number of times we should look for elements that are not</span>
<span class="c"> * in the DOM at the time the event is requested after the document</span>
<span class="c"> * has been loaded. The default is 2000@amp;20 ms, so it will poll</span>
<span class="c"> * for 40 seconds or until all outstanding handlers are bound</span>
<span class="c"> * (whichever comes first).</span>
<span class="c"> * @property POLL_RETRYS</span>
<span class="c"> * @type int</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> */</span>
<span class="nx">POLL_RETRYS</span><span class="o">:</span> <span class="m">2000</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * The poll interval in milliseconds</span>
<span class="c"> * @property POLL_INTERVAL</span>
<span class="c"> * @type int</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> */</span>
<span class="nx">POLL_INTERVAL</span><span class="o">:</span> <span class="m">20</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * addListener/removeListener can throw errors in unexpected scenarios.</span>
<span class="c"> * These errors are suppressed, the method returns false, and this property</span>
<span class="c"> * is set</span>
<span class="c"> * @property lastError</span>
<span class="c"> * @static</span>
<span class="c"> * @type Error</span>
<span class="c"> */</span>
<span class="nx">lastError</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * poll handle</span>
<span class="c"> * @property _interval</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_interval</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * document readystate poll handle</span>
<span class="c"> * @property _dri</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_dri</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * True when the document is initially usable</span>
<span class="c"> * @property DOMReady</span>
<span class="c"> * @type boolean</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">DOMReady</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * @method startInterval</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">startInterval</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_interval</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">callback</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span> <span class="nx">self</span><span class="o">.</span><span class="nx">_tryPreloadAttach</span><span class="o">();</span> <span class="o">};</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_interval</span> <span class="o">=</span> <span class="nx">setInterval</span><span class="o">(</span><span class="nx">callback</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">POLL_INTERVAL</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Executes the supplied callback when the item with the supplied</span>
<span class="c"> * id is found. This is meant to be used to execute behavior as</span>
<span class="c"> * soon as possible as the page loads. If you use this after the</span>
<span class="c"> * initial page load it will poll for a fixed time for the element.</span>
<span class="c"> * The number of times it will poll and the frequency are</span>
<span class="c"> * configurable. By default it will poll for 10 seconds.</span>
<span class="c"> *</span>
<span class="c"> * &lt;p&gt;The callback is executed with a single parameter:</span>
<span class="c"> * the custom object parameter, if provided.&lt;/p&gt;</span>
<span class="c"> *</span>
<span class="c"> * @method onAvailable</span>
<span class="c"> *</span>
<span class="c"> * @param {string||string[]} id the id of the element, or an array</span>
<span class="c"> * of ids to look for.</span>
<span class="c"> * @param {function} fn what to execute when the element is found.</span>
<span class="c"> * @param {object} p_obj an optional object to be passed back as</span>
<span class="c"> * a parameter to fn.</span>
<span class="c"> * @param {boolean|object} p_override If set to true, fn will execute</span>
<span class="c"> * in the context of p_obj, if set to an object it</span>
<span class="c"> * will execute in the context of that object</span>
<span class="c"> * @param checkContent {boolean} check child node readiness (onContentReady)</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="c">// @TODO fix arguments</span>
<span class="c"></span> <span class="nx">onAvailable</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">p_obj</span><span class="o">,</span> <span class="nx">p_override</span><span class="o">,</span> <span class="nx">checkContent</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// var a = (Y.Lang.isString(id)) ? [id] : id;</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">(</span><span class="nx">id</span><span class="o">);</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">a</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">=</span><span class="nx">i</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_avail</span><span class="o">.</span><span class="nx">push</span><span class="o">({</span> <span class="nx">id</span><span class="o">:</span> <span class="nx">a</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span>
<span class="nx">fn</span><span class="o">:</span> <span class="nx">fn</span><span class="o">,</span>
<span class="nx">obj</span><span class="o">:</span> <span class="nx">p_obj</span><span class="o">,</span>
<span class="nx">override</span><span class="o">:</span> <span class="nx">p_override</span><span class="o">,</span>
<span class="nx">checkReady</span><span class="o">:</span> <span class="nx">checkContent</span> <span class="o">});</span>
<span class="o">}</span>
<span class="nx">_retryCount</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">POLL_RETRYS</span><span class="o">;</span>
<span class="k">this</span><span class="o">.</span><span class="nx">startInterval</span><span class="o">();</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Works the same way as onAvailable, but additionally checks the</span>
<span class="c"> * state of sibling elements to determine if the content of the</span>
<span class="c"> * available element is safe to modify.</span>
<span class="c"> *</span>
<span class="c"> * &lt;p&gt;The callback is executed with a single parameter:</span>
<span class="c"> * the custom object parameter, if provided.&lt;/p&gt;</span>
<span class="c"> *</span>
<span class="c"> * @method onContentReady</span>
<span class="c"> *</span>
<span class="c"> * @param {string} id the id of the element to look for.</span>
<span class="c"> * @param {function} fn what to execute when the element is ready.</span>
<span class="c"> * @param {object} p_obj an optional object to be passed back as</span>
<span class="c"> * a parameter to fn.</span>
<span class="c"> * @param {boolean|object} p_override If set to true, fn will execute</span>
<span class="c"> * in the context of p_obj. If an object, fn will</span>
<span class="c"> * exectute in the context of that object</span>
<span class="c"> *</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="c">// @TODO fix arguments</span>
<span class="c"></span> <span class="nx">onContentReady</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">p_obj</span><span class="o">,</span> <span class="nx">p_override</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">onAvailable</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">p_obj</span><span class="o">,</span> <span class="nx">p_override</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Executes the supplied callback when the DOM is first usable. This</span>
<span class="c"> * will execute immediately if called after the DOMReady event has</span>
<span class="c"> * fired. @todo the DOMContentReady event does not fire when the</span>
<span class="c"> * script is dynamically injected into the page. This means the</span>
<span class="c"> * DOMReady custom event will never fire in FireFox or Opera when the</span>
<span class="c"> * library is injected. It _will_ fire in Safari, and the IE </span>
<span class="c"> * implementation would allow for us to fire it if the defered script</span>
<span class="c"> * is not available. We want this to behave the same in all browsers.</span>
<span class="c"> * Is there a way to identify when the script has been injected </span>
<span class="c"> * instead of included inline? Is there a way to know whether the </span>
<span class="c"> * window onload event has fired without having had a listener attached </span>
<span class="c"> * to it when it did so?</span>
<span class="c"> *</span>
<span class="c"> * &lt;p&gt;The callback is a Event.Custom, so the signature is:&lt;/p&gt;</span>
<span class="c"> * &lt;p&gt;type &amp;lt;string&amp;gt;, args &amp;lt;array&amp;gt;, customobject &amp;lt;object&amp;gt;&lt;/p&gt;</span>
<span class="c"> * &lt;p&gt;For DOMReady events, there are no fire argments, so the</span>
<span class="c"> * signature is:&lt;/p&gt;</span>
<span class="c"> * &lt;p&gt;&quot;DOMReady&quot;, [], obj&lt;/p&gt;</span>
<span class="c"> *</span>
<span class="c"> *</span>
<span class="c"> * @method onDOMReady</span>
<span class="c"> *</span>
<span class="c"> * @param {function} fn what to execute when the element is found.</span>
<span class="c"> * @optional context execution context</span>
<span class="c"> * @optional args 1..n arguments to send to the listener</span>
<span class="c"> *</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">onDOMReady</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// var ev = Y.Event.DOMReadyEvent;</span>
<span class="c"></span> <span class="c">// ev.subscribe.apply(ev, arguments);</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">(</span><span class="nx">arguments</span><span class="o">,</span> <span class="m">0</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="nx">a</span><span class="o">.</span><span class="nx">unshift</span><span class="o">(</span><span class="s1">&#39;event:ready&#39;</span><span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">Y</span><span class="o">,</span> <span class="nx">a</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Appends an event handler</span>
<span class="c"> *</span>
<span class="c"> * @method addListener</span>
<span class="c"> *</span>
<span class="c"> * @param {String|HTMLElement|Array|NodeList} el An id, an element </span>
<span class="c"> * reference, or a collection of ids and/or elements to assign the </span>
<span class="c"> * listener to.</span>
<span class="c"> * @param {String} type The type of event to append</span>
<span class="c"> * @param {Function} fn The method the event invokes</span>
<span class="c"> * @param {Object} obj An arbitrary object that will be </span>
<span class="c"> * passed as a parameter to the handler</span>
<span class="c"> * @param {Boolean|object} args 1..n ar</span>
<span class="c"> * @return {Boolean} True if the action was successful or defered,</span>
<span class="c"> * false if one or more of the elements </span>
<span class="c"> * could not have the listener attached,</span>
<span class="c"> * or if the operation throws an exception.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">addListener</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;addListener: &#39; + Y.Lang.dump(Y.Array(arguments, 0, true), 1));</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">a</span><span class="o">=</span><span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">(</span><span class="nx">arguments</span><span class="o">,</span> <span class="m">1</span><span class="o">,</span> <span class="kc">true</span><span class="o">),</span> <span class="nx">override</span> <span class="o">=</span> <span class="nx">a</span><span class="o">[</span><span class="m">3</span><span class="o">],</span> <span class="nx">E</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">,</span>
<span class="nx">aa</span><span class="o">=</span><span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">(</span><span class="nx">arguments</span><span class="o">,</span> <span class="m">0</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">fn</span> <span class="o">||</span> <span class="o">!</span><span class="nx">fn</span><span class="o">.</span><span class="nx">call</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// throw new TypeError(type + &quot; addListener call failed, callback undefined&quot;);</span>
<span class="c"></span> <span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="nx">type</span> <span class="o">+</span> <span class="s2">&quot; addListener call failed, invalid callback&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="s2">&quot;Event&quot;</span><span class="o">);</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// The el argument can be an array of elements or element ids.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isValidCollection</span><span class="o">(</span><span class="nx">el</span><span class="o">))</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;collection: &#39; + el);</span>
<span class="c"></span> <span class="c">// Y.log(&#39;collection: &#39; + el.item(0) + &#39;, &#39; + el.item(1));</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">handles</span><span class="o">=[],</span> <span class="nx">h</span><span class="o">,</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">l</span><span class="o">,</span> <span class="nx">proc</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">v</span><span class="o">,</span> <span class="nx">k</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// handles.push(this.addListener(el[i], type, fn, obj, override));</span>
<span class="c"></span> <span class="c">// var node = el.item(k);</span>
<span class="c"></span> <span class="c">// Y.log(&#39;collection stuff: &#39; + node);</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">b</span> <span class="o">=</span> <span class="nx">a</span><span class="o">.</span><span class="nx">slice</span><span class="o">();</span>
<span class="nx">b</span><span class="o">.</span><span class="nx">unshift</span><span class="o">(</span><span class="nx">v</span><span class="o">);</span>
<span class="nx">h</span> <span class="o">=</span> <span class="nx">E</span><span class="o">.</span><span class="nx">addListener</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">E</span><span class="o">,</span> <span class="nx">b</span><span class="o">);</span>
<span class="nx">handles</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">h</span><span class="o">);</span>
<span class="o">};</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">each</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">proc</span><span class="o">,</span> <span class="nx">E</span><span class="o">);</span>
<span class="k">return</span> <span class="nx">handles</span><span class="o">;</span>
<span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">el</span><span class="o">))</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">oEl</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">all</span><span class="o">(</span><span class="nx">el</span><span class="o">);</span>
<span class="c">// If the el argument is a string, we assume it is </span>
<span class="c"></span> <span class="c">// actually the id of the element. If the page is loaded</span>
<span class="c"></span> <span class="c">// we convert el to the actual element, otherwise we </span>
<span class="c"></span> <span class="c">// defer attaching the event until onload event fires</span>
<span class="c"></span>
<span class="c">// check to see if we need to delay hooking up the event </span>
<span class="c"></span> <span class="c">// until after the page loads.</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">size</span> <span class="o">=</span> <span class="nx">oEl</span><span class="o">.</span><span class="nx">size</span><span class="o">();</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">size</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">size</span> <span class="o">&gt;</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">aa</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oEl</span><span class="o">;</span>
<span class="k">return</span> <span class="nx">E</span><span class="o">.</span><span class="nx">addListener</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">E</span><span class="o">,</span> <span class="nx">aa</span><span class="o">);</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="nx">el</span> <span class="o">=</span> <span class="nx">oEl</span><span class="o">.</span><span class="nx">item</span><span class="o">(</span><span class="m">0</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="c">//</span>
<span class="c"></span> <span class="c">// defer adding the event until the element is available</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">onAvailable</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="c">// Y.Event.addListener(el, type, fn, obj, override);</span>
<span class="c"></span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">,</span> <span class="nx">aa</span><span class="o">);</span>
<span class="o">});</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// Element should be an html element or an array if we get </span>
<span class="c"></span> <span class="c">// here.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&quot;unable to attach event &quot; + type);</span>
<span class="c"></span> <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// the custom event key is the uid for the element + type</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">ek</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="nx">el</span><span class="o">),</span> <span class="nx">key</span> <span class="o">=</span> <span class="s1">&#39;event:&#39;</span> <span class="o">+</span> <span class="nx">ek</span> <span class="o">+</span> <span class="nx">type</span><span class="o">,</span>
<span class="nx">cewrapper</span> <span class="o">=</span> <span class="nx">_wrappers</span><span class="o">[</span><span class="nx">key</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">cewrapper</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// create CE wrapper</span>
<span class="c"></span> <span class="nx">cewrapper</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">publish</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">silent</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span>
<span class="c">// host: this,</span>
<span class="c"></span> <span class="nx">bubbles</span><span class="o">:</span> <span class="kc">false</span>
<span class="o">});</span>
<span class="c">// cache the dom event details in the custom event</span>
<span class="c"></span> <span class="c">// for later removeListener calls</span>
<span class="c"></span> <span class="nx">cewrapper</span><span class="o">.</span><span class="nx">el</span> <span class="o">=</span> <span class="nx">el</span><span class="o">;</span>
<span class="nx">cewrapper</span><span class="o">.</span><span class="nx">type</span> <span class="o">=</span> <span class="nx">type</span><span class="o">;</span>
<span class="nx">cewrapper</span><span class="o">.</span><span class="nx">fn</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">cewrapper</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">el</span><span class="o">));</span>
<span class="o">};</span>
<span class="nx">_wrappers</span><span class="o">[</span><span class="nx">key</span><span class="o">]</span> <span class="o">=</span> <span class="nx">cewrapper</span><span class="o">;</span>
<span class="nx">_el_events</span><span class="o">[</span><span class="nx">ek</span><span class="o">]</span> <span class="o">=</span> <span class="nx">_el_events</span><span class="o">[</span><span class="nx">ek</span><span class="o">]</span> <span class="o">||</span> <span class="o">{};</span>
<span class="nx">_el_events</span><span class="o">[</span><span class="nx">ek</span><span class="o">][</span><span class="nx">key</span><span class="o">]</span> <span class="o">=</span> <span class="nx">cewrapper</span><span class="o">;</span>
<span class="c">// var capture = (Y.lang.isObject(obj) &amp;&amp; obj.capture);</span>
<span class="c"></span> <span class="c">// attach a listener that fires the custom event</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">nativeAdd</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">type</span><span class="o">,</span> <span class="nx">cewrapper</span><span class="o">.</span><span class="nx">fn</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">// from type, fn, etc to fn, obj, override</span>
<span class="c"></span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">(</span><span class="nx">arguments</span><span class="o">,</span> <span class="m">2</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="c">// a = a.shift();</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">context</span> <span class="o">=</span> <span class="nx">obj</span> <span class="o">||</span> <span class="nx">el</span><span class="o">;</span>
<span class="c">// if (override) {</span>
<span class="c"></span> <span class="c">// if (override === true) {</span>
<span class="c"></span> <span class="c">// context = obj;</span>
<span class="c"></span> <span class="c">// } else {</span>
<span class="c"></span> <span class="c">// context = override;</span>
<span class="c"></span> <span class="c">// }</span>
<span class="c"></span> <span class="c">// }</span>
<span class="c"></span>
<span class="nx">a</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">=</span> <span class="nx">context</span><span class="o">;</span>
<span class="c">// set context to element if not specified</span>
<span class="c"></span> <span class="k">return</span> <span class="nx">cewrapper</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">cewrapper</span><span class="o">,</span> <span class="nx">a</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Removes an event listener</span>
<span class="c"> *</span>
<span class="c"> * @method removeListener</span>
<span class="c"> *</span>
<span class="c"> * @param {String|HTMLElement|Array|NodeList} el An id, an element </span>
<span class="c"> * reference, or a collection of ids and/or elements to remove</span>
<span class="c"> * the listener from.</span>
<span class="c"> * @param {String} type the type of event to remove.</span>
<span class="c"> * @param {Function} fn the method the event invokes. If fn is</span>
<span class="c"> * undefined, then all event handlers for the type of event are * removed.</span>
<span class="c"> * @return {boolean} true if the unbind was successful, false * otherwise.</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">removeListener</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">el</span> <span class="o">&amp;&amp;</span> <span class="nx">el</span><span class="o">.</span><span class="nx">detach</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="nx">el</span><span class="o">.</span><span class="nx">detach</span><span class="o">();</span>
<span class="o">}</span>
<span class="k">var</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">len</span><span class="o">,</span> <span class="nx">li</span><span class="o">;</span>
<span class="c">// The el argument can be a string</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">el</span> <span class="o">==</span> <span class="s2">&quot;string&quot;</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">el</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">el</span><span class="o">);</span>
<span class="c">// The el argument can be an array of elements or element ids.</span>
<span class="c"></span> <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span> <span class="k">this</span><span class="o">.</span><span class="nx">_isValidCollection</span><span class="o">(</span><span class="nx">el</span><span class="o">))</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">,</span><span class="nx">len</span><span class="o">=</span><span class="nx">el</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">ok</span> <span class="o">=</span> <span class="o">(</span> <span class="k">this</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">el</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">ok</span> <span class="o">);</span>
<span class="o">}</span>
<span class="k">return</span> <span class="nx">ok</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">fn</span> <span class="o">||</span> <span class="o">!</span><span class="nx">fn</span><span class="o">.</span><span class="nx">call</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&quot;Error, function is not valid &quot; + fn);</span>
<span class="c"></span> <span class="c">//return false;</span>
<span class="c"></span> <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="kc">false</span><span class="o">,</span> <span class="nx">type</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="s1">&#39;event:&#39;</span> <span class="o">+</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">+</span> <span class="nx">type</span><span class="o">,</span>
<span class="nx">ce</span> <span class="o">=</span> <span class="nx">_wrappers</span><span class="o">[</span><span class="nx">id</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">ce</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="nx">ce</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="nx">fn</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Finds the event in the window object, the caller&#39;s arguments, or</span>
<span class="c"> * in the arguments of another method in the callstack. This is</span>
<span class="c"> * executed automatically for events registered through the event</span>
<span class="c"> * manager, so the implementer should not normally need to execute</span>
<span class="c"> * this function at all.</span>
<span class="c"> * @method getEvent</span>
<span class="c"> * @param {Event} e the event parameter from the handler</span>
<span class="c"> * @param {HTMLElement} boundEl the element the listener is attached to</span>
<span class="c"> * @return {Event} the event </span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">getEvent</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">boundEl</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">ev</span> <span class="o">=</span> <span class="nx">e</span> <span class="o">||</span> <span class="nb">window</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">ev</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getEvent</span><span class="o">.</span><span class="nx">caller</span><span class="o">;</span>
<span class="k">while</span> <span class="o">(</span><span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">ev</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">arguments</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">ev</span> <span class="o">&amp;&amp;</span> <span class="nx">Event</span> <span class="o">==</span> <span class="nx">ev</span><span class="o">.</span><span class="nx">constructor</span><span class="o">)</span> <span class="o">{</span>
<span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="nx">c</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">caller</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// Y.log(&#39;wrapper for facade: &#39; + &#39;event:&#39; + Y.stamp(boundEl) + e.type);</span>
<span class="c"></span>
<span class="k">return</span> <span class="k">new</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">Facade</span><span class="o">(</span><span class="nx">ev</span><span class="o">,</span> <span class="nx">boundEl</span><span class="o">,</span> <span class="nx">_wrappers</span><span class="o">[</span><span class="s1">&#39;event:&#39;</span> <span class="o">+</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="nx">boundEl</span><span class="o">)</span> <span class="o">+</span> <span class="nx">e</span><span class="o">.</span><span class="nx">type</span><span class="o">]);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Generates an unique ID for the element if it does not already </span>
<span class="c"> * have one.</span>
<span class="c"> * @method generateId</span>
<span class="c"> * @param el the element to create the id for</span>
<span class="c"> * @return {string} the resulting id of the element</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">generateId</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">id</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="nx">el</span><span class="o">);</span>
<span class="nx">el</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">id</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">return</span> <span class="nx">id</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * We want to be able to use getElementsByTagName as a collection</span>
<span class="c"> * to attach a group of events to. Unfortunately, different </span>
<span class="c"> * browsers return different types of collections. This function</span>
<span class="c"> * tests to determine if the object is array-like. It will also </span>
<span class="c"> * fail if the object is an array, but is empty.</span>
<span class="c"> * @method _isValidCollection</span>
<span class="c"> * @param o the object to test</span>
<span class="c"> * @return {boolean} true if the object is array-like and populated</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_isValidCollection</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">o</span><span class="o">)</span> <span class="o">{</span>
<span class="k">try</span> <span class="o">{</span>
<span class="k">return</span> <span class="o">(</span> <span class="nx">o</span> <span class="o">&amp;&amp;</span> <span class="c">// o is something</span>
<span class="c"></span> <span class="k">typeof</span> <span class="nx">o</span> <span class="o">!==</span> <span class="s2">&quot;string&quot;</span> <span class="o">&amp;&amp;</span> <span class="c">// o is not a string</span>
<span class="c"></span> <span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">each</span> <span class="o">||</span> <span class="nx">o</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="c">// o is indexed</span>
<span class="c"></span> <span class="o">!</span><span class="nx">o</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">&amp;&amp;</span> <span class="c">// o is not an HTML element</span>
<span class="c"></span> <span class="o">!</span><span class="nx">o</span><span class="o">.</span><span class="nx">alert</span> <span class="o">&amp;&amp;</span> <span class="c">// o is not a window</span>
<span class="c"></span> <span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">item</span> <span class="o">||</span> <span class="k">typeof</span> <span class="nx">o</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">!==</span> <span class="s2">&quot;undefined&quot;</span><span class="o">)</span> <span class="o">);</span>
<span class="o">}</span> <span class="k">catch</span><span class="o">(</span><span class="nx">ex</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;collection check failure&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">);</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/*</span>
<span class="c"> * Custom event the fires when the dom is initially usable</span>
<span class="c"> * @event DOMReadyEvent</span>
<span class="c"> */</span>
<span class="c">// DOMReadyEvent: new Y.CustomEvent(&quot;event:ready&quot;, this),</span>
<span class="c"></span> <span class="c">// DOMReadyEvent: Y.publish(&quot;event:ready&quot;, this, {</span>
<span class="c"></span> <span class="c">// fireOnce: true</span>
<span class="c"></span> <span class="c">// }),</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * hook up any deferred listeners</span>
<span class="c"> * @method _load</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_load</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">loadComplete</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">loadComplete</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">E</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">;</span>
<span class="c">// Just in case DOMReady did not go off for some reason</span>
<span class="c"></span> <span class="c">// E._ready();</span>
<span class="c"></span> <span class="nx">Y</span><span class="o">.</span><span class="nx">fire</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="s1">&#39;event:ready&#39;</span><span class="o">);</span>
<span class="c">// Available elements may not have been detected before the</span>
<span class="c"></span> <span class="c">// window load event fires. Try to find them now so that the</span>
<span class="c"></span> <span class="c">// the user is more likely to get the onAvailable notifications</span>
<span class="c"></span> <span class="c">// before the window load notification</span>
<span class="c"></span> <span class="nx">E</span><span class="o">.</span><span class="nx">_tryPreloadAttach</span><span class="o">();</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Polling function that runs before the onload event fires, </span>
<span class="c"> * attempting to attach to DOM Nodes as soon as they are </span>
<span class="c"> * available</span>
<span class="c"> * @method _tryPreloadAttach</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_tryPreloadAttach</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">locked</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">ie</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Hold off if DOMReady has not fired and check current</span>
<span class="c"></span> <span class="c">// readyState to protect against the IE operation aborted</span>
<span class="c"></span> <span class="c">// issue.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">DOMReady</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">startInterval</span><span class="o">();</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">locked</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="c">// Y.log.debug(&quot;tryPreloadAttach&quot;);</span>
<span class="c"></span>
<span class="c">// keep trying until after the page is loaded. We need to </span>
<span class="c"></span> <span class="c">// check the page load state prior to trying to bind the </span>
<span class="c"></span> <span class="c">// elements so that we can be certain all elements have been </span>
<span class="c"></span> <span class="c">// tested appropriately</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">tryAgain</span> <span class="o">=</span> <span class="o">!</span><span class="nx">loadComplete</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">tryAgain</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">tryAgain</span> <span class="o">=</span> <span class="o">(</span><span class="nx">_retryCount</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">// onAvailable</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">notAvail</span> <span class="o">=</span> <span class="o">[];</span>
<span class="k">var</span> <span class="nx">executeItem</span> <span class="o">=</span> <span class="k">function</span> <span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">item</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">context</span> <span class="o">=</span> <span class="nx">el</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">item</span><span class="o">.</span><span class="nx">override</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">item</span><span class="o">.</span><span class="nx">override</span> <span class="o">===</span> <span class="kc">true</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">context</span> <span class="o">=</span> <span class="nx">item</span><span class="o">.</span><span class="nx">obj</span><span class="o">;</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="nx">context</span> <span class="o">=</span> <span class="nx">item</span><span class="o">.</span><span class="nx">override</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="nx">item</span><span class="o">.</span><span class="nx">fn</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">context</span><span class="o">,</span> <span class="nx">item</span><span class="o">.</span><span class="nx">obj</span><span class="o">);</span>
<span class="o">};</span>
<span class="k">var</span> <span class="nx">i</span><span class="o">,</span><span class="nx">len</span><span class="o">,</span><span class="nx">item</span><span class="o">,</span><span class="nx">el</span><span class="o">;</span>
<span class="c">// onAvailable</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">,</span><span class="nx">len</span><span class="o">=</span><span class="nx">_avail</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">item</span> <span class="o">=</span> <span class="nx">_avail</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">item</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">item</span><span class="o">.</span><span class="nx">checkReady</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">el</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">item</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">executeItem</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">item</span><span class="o">);</span>
<span class="nx">_avail</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="nx">notAvail</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">item</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// onContentReady</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">,</span><span class="nx">len</span><span class="o">=</span><span class="nx">_avail</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">item</span> <span class="o">=</span> <span class="nx">_avail</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">item</span> <span class="o">&amp;&amp;</span> <span class="nx">item</span><span class="o">.</span><span class="nx">checkReady</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">el</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">item</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// The element is available, but not necessarily ready</span>
<span class="c"></span> <span class="c">// @todo should we test parentNode.nextSibling?</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">loadComplete</span> <span class="o">||</span> <span class="nx">el</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">executeItem</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">item</span><span class="o">);</span>
<span class="nx">_avail</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="nx">notAvail</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">item</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="nx">_retryCount</span> <span class="o">=</span> <span class="o">(</span><span class="nx">notAvail</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">?</span> <span class="m">0</span> <span class="o">:</span> <span class="nx">_retryCount</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">tryAgain</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// we may need to strip the nulled out items here</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">startInterval</span><span class="o">();</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="nx">clearInterval</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_interval</span><span class="o">);</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_interval</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">locked</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Removes all listeners attached to the given element via addListener.</span>
<span class="c"> * Optionally, the node&#39;s children can also be purged.</span>
<span class="c"> * Optionally, you can specify a specific type of event to remove.</span>
<span class="c"> * @method purgeElement</span>
<span class="c"> * @param {HTMLElement} el the element to purge</span>
<span class="c"> * @param {boolean} recurse recursively purge this element&#39;s children</span>
<span class="c"> * as well. Use with caution.</span>
<span class="c"> * @param {string} type optional type of listener to purge. If</span>
<span class="c"> * left out, all listeners will be removed</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">purgeElement</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">recurse</span><span class="o">,</span> <span class="nx">type</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">oEl</span> <span class="o">=</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">el</span><span class="o">))</span> <span class="o">?</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">:</span> <span class="nx">el</span><span class="o">,</span>
<span class="nx">id</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="nx">oEl</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">lis</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getListeners</span><span class="o">(</span><span class="nx">oEl</span><span class="o">,</span> <span class="nx">type</span><span class="o">),</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">len</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">lis</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">,</span><span class="nx">len</span><span class="o">=</span><span class="nx">lis</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</span> <span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">lis</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">recurse</span> <span class="o">&amp;&amp;</span> <span class="nx">oEl</span> <span class="o">&amp;&amp;</span> <span class="nx">oEl</span><span class="o">.</span><span class="nx">childNodes</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">,</span><span class="nx">len</span><span class="o">=</span><span class="nx">oEl</span><span class="o">.</span><span class="nx">childNodes</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</span> <span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">oEl</span><span class="o">.</span><span class="nx">childNodes</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">recurse</span><span class="o">,</span> <span class="nx">type</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Returns all listeners attached to the given element via addListener.</span>
<span class="c"> * Optionally, you can specify a specific type of event to return.</span>
<span class="c"> * @method getListeners</span>
<span class="c"> * @param el {HTMLElement|string} the element or element id to inspect </span>
<span class="c"> * @param type {string} optional type of listener to return. If</span>
<span class="c"> * left out, all listeners will be returned</span>
<span class="c"> * @return {Y.Custom.Event} the custom event wrapper for the DOM event(s)</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">getListeners</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">type</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">results</span><span class="o">=[],</span> <span class="nx">ek</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="nx">el</span><span class="o">),</span> <span class="nx">key</span> <span class="o">=</span> <span class="o">(</span><span class="nx">type</span><span class="o">)</span> <span class="o">?</span> <span class="s1">&#39;event:&#39;</span> <span class="o">+</span> <span class="nx">type</span> <span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
<span class="nx">evts</span> <span class="o">=</span> <span class="nx">_el_events</span><span class="o">[</span><span class="nx">ek</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">evts</span><span class="o">[</span><span class="nx">key</span><span class="o">])</span> <span class="o">{</span>
<span class="nx">results</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">evts</span><span class="o">[</span><span class="nx">key</span><span class="o">]);</span>
<span class="o">}</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">evts</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">results</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">evts</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">return</span> <span class="o">(</span><span class="nx">results</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">?</span> <span class="nx">results</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Removes all listeners registered by pe.event. Called </span>
<span class="c"> * automatically during the unload event.</span>
<span class="c"> * @method _unload</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_unload</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">E</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">,</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">w</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">_wrappers</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">w</span> <span class="o">=</span> <span class="nx">_wrappers</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="nx">w</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
<span class="nx">E</span><span class="o">.</span><span class="nx">nativeRemove</span><span class="o">(</span><span class="nx">w</span><span class="o">.</span><span class="nx">el</span><span class="o">,</span> <span class="nx">w</span><span class="o">.</span><span class="nx">type</span><span class="o">,</span> <span class="nx">w</span><span class="o">.</span><span class="nx">fn</span><span class="o">);</span>
<span class="nx">delete</span> <span class="nx">_wrappers</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="o">}</span>
<span class="nx">E</span><span class="o">.</span><span class="nx">nativeRemove</span><span class="o">(</span><span class="nb">window</span><span class="o">,</span> <span class="s2">&quot;unload&quot;</span><span class="o">,</span> <span class="nx">E</span><span class="o">.</span><span class="nx">_unload</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Adds a DOM event directly without the caching, cleanup, context adj, etc</span>
<span class="c"> *</span>
<span class="c"> * @method nativeAdd</span>
<span class="c"> * @param {HTMLElement} el the element to bind the handler to</span>
<span class="c"> * @param {string} type the type of event handler</span>
<span class="c"> * @param {function} fn the callback to invoke</span>
<span class="c"> * @param {boolen} capture capture or bubble phase</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">nativeAdd</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">capture</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">addEventListener</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">el</span><span class="o">.</span><span class="nx">addEventListener</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="o">!!</span><span class="nx">capture</span><span class="o">);</span>
<span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">attachEvent</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">el</span><span class="o">.</span><span class="nx">attachEvent</span><span class="o">(</span><span class="s2">&quot;on&quot;</span> <span class="o">+</span> <span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">// else {</span>
<span class="c"></span> <span class="c">// Y.log(&#39;DOM evt error&#39;);</span>
<span class="c"></span> <span class="c">// }</span>
<span class="c"></span> <span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Basic remove listener</span>
<span class="c"> *</span>
<span class="c"> * @method nativeRemove</span>
<span class="c"> * @param {HTMLElement} el the element to bind the handler to</span>
<span class="c"> * @param {string} type the type of event handler</span>
<span class="c"> * @param {function} fn the callback to invoke</span>
<span class="c"> * @param {boolen} capture capture or bubble phase</span>
<span class="c"> * @static</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">nativeRemove</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">capture</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">removeEventListener</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">el</span><span class="o">.</span><span class="nx">removeEventListener</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="o">!!</span><span class="nx">capture</span><span class="o">);</span>
<span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">detachEvent</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">el</span><span class="o">.</span><span class="nx">detachEvent</span><span class="o">(</span><span class="s2">&quot;on&quot;</span> <span class="o">+</span> <span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="o">}();</span>
<span class="k">var</span> <span class="nx">E</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">;</span>
<span class="c">// Process onAvailable/onContentReady items when when the DOM is ready in IE</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">ie</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">subscribe</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s1">&#39;event:ready&#39;</span><span class="o">,</span> <span class="nx">E</span><span class="o">.</span><span class="nx">_tryPreloadAttach</span><span class="o">,</span> <span class="nx">E</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">E</span><span class="o">.</span><span class="nx">Custom</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">CustomEvent</span><span class="o">;</span>
<span class="nx">E</span><span class="o">.</span><span class="nx">Subscriber</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Subscriber</span><span class="o">;</span>
<span class="nx">E</span><span class="o">.</span><span class="nx">Target</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">EventTarget</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Y.Event.on is an alias for addListener</span>
<span class="c"> * @method on</span>
<span class="c"> * @see addListener</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">E</span><span class="o">.</span><span class="nx">attach</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">el</span><span class="o">,</span> <span class="nx">data</span><span class="o">,</span> <span class="nx">context</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">(</span><span class="nx">arguments</span><span class="o">,</span> <span class="m">0</span><span class="o">,</span> <span class="kc">true</span><span class="o">),</span>
<span class="nx">oEl</span> <span class="o">=</span> <span class="nx">a</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="m">2</span><span class="o">,</span> <span class="m">1</span><span class="o">);</span>
<span class="nx">a</span><span class="o">.</span><span class="nx">unshift</span><span class="o">(</span><span class="nx">oEl</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
<span class="k">return</span> <span class="nx">E</span><span class="o">.</span><span class="nx">addListener</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">E</span><span class="o">,</span> <span class="nx">a</span><span class="o">);</span>
<span class="o">};</span>
<span class="nx">E</span><span class="o">.</span><span class="nx">detach</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">el</span><span class="o">,</span> <span class="nx">data</span><span class="o">,</span> <span class="nx">context</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="nx">E</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">data</span><span class="o">,</span> <span class="nx">context</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">// for the moment each instance will get its own load/unload listeners</span>
<span class="c"></span> <span class="nx">E</span><span class="o">.</span><span class="nx">nativeAdd</span><span class="o">(</span><span class="nb">window</span><span class="o">,</span> <span class="s2">&quot;load&quot;</span><span class="o">,</span> <span class="nx">E</span><span class="o">.</span><span class="nx">_load</span><span class="o">);</span>
<span class="nx">E</span><span class="o">.</span><span class="nx">nativeAdd</span><span class="o">(</span><span class="nb">window</span><span class="o">,</span> <span class="s2">&quot;unload&quot;</span><span class="o">,</span> <span class="nx">E</span><span class="o">.</span><span class="nx">_unload</span><span class="o">);</span>
<span class="nx">E</span><span class="o">.</span><span class="nx">_tryPreloadAttach</span><span class="o">();</span>
<span class="o">},</span> <span class="s2">&quot;3.0.0&quot;</span><span class="o">);</span>
</pre></div>
</div>
</div>
</div>
<div class="yui-b">
<div class="nav">
<div class="module">
<h4>Modules</h4>
<ul class="content">
<li class=""><a href="module_anim.html">anim</a></li>
<li class=""><a href="module_anim-color.html">anim-color</a></li>
<li class=""><a href="module_anim-curve.html">anim-curve</a></li>
<li class=""><a href="module_anim-easing.html">anim-easing</a></li>
<li class=""><a href="module_anim-scroll.html">anim-scroll</a></li>
<li class=""><a href="module_anim-xy.html">anim-xy</a></li>
<li class=""><a href="module_attribute.html">attribute</a></li>
<li class=""><a href="module_base.html">base</a></li>
<li class=""><a href="module_dd-plugin.html">dd-plugin</a></li>
<li class="selected"><a href="module_event.html">event</a></li>
<li class=""><a href="module_io.html">io</a></li>
<li class=""><a href="module_json.html">json</a></li>
<li class=""><a href="module_loader.html">loader</a></li>
<li class=""><a href="module_node.html">node</a></li>
<li class=""><a href="module_node-class.html">node-class</a></li>
<li class=""><a href="module_node-region.html">node-region</a></li>
<li class=""><a href="module_node-screen.html">node-screen</a></li>
<li class=""><a href="module_queue.html">queue</a></li>
<li class=""><a href="module_yui.html">yui</a></li>
</ul>
</div>
<div class="module">
<h4>Classes</h4>
<ul class="content">
<li class=""><a href="Do.html">Do</a></li>
<li class=""><a href="Do.AlterArgs.html">Do.AlterArgs</a></li>
<li class=""><a href="Do.AlterReturn.html">Do.AlterReturn</a></li>
<li class=""><a href="Do.Error.html">Do.Error</a></li>
<li class=""><a href="Do.Method.html">Do.Method</a></li>
<li class=""><a href="Event.html">Event</a></li>
<li class=""><a href="Event.Custom.html">Event.Custom</a></li>
<li class=""><a href="Event.Facade.html">Event.Facade</a></li>
<li class=""><a href="Event.Handle.html">Event.Handle</a></li>
<li class=""><a href="Event.Subscriber.html">Event.Subscriber</a></li>
<li class=""><a href="Event.Target.html">Event.Target</a></li>
</ul>
</div>
<div class="module">
<h4>Files</h4>
<ul class="content">
<li class=""><a href="event-custom.js.html">event-custom.js</a></li>
<li class=""><a href="event-do.js.html">event-do.js</a></li>
<li class="selected"><a href="event-dom.js.html">event-dom.js</a></li>
<li class=""><a href="event-facade.js.html">event-facade.js</a></li>
<li class=""><a href="event-ready.js.html">event-ready.js</a></li>
<li class=""><a href="event-target.js.html">event-target.js</a></li>
<li class=""><a href="event.js.html">event.js</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright &copy; 2008 Yahoo! Inc. All rights reserved.
</div>
</div>
</body>
</html>