event-dom.js.html revision eb9b6f817df5c660be9f00fc5d27fe33479fdc98
> event-dom.js (source view)
<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>
<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">"event-dom"</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="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="k">var</span> <span class="nx">loadComplete</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</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="k">var</span> <span class="nx">_avail</span> <span class="o">=</span> <span class="o">[];</span>
<span class="k">var</span> <span class="nx">_wrappers</span> <span class="o">=</span> <span class="o">{};</span>
<span class="k">var</span> <span class="nx">_el_events</span> <span class="o">=</span> <span class="o">{};</span>
<span class="nx">POLL_RETRYS</span><span class="o">:</span> <span class="m">2000</span><span class="o">,</span>
<span class="nx">POLL_INTERVAL</span><span class="o">:</span> <span class="m">20</span><span class="o">,</span>
<span class="nx">lastError</span><span class="o">:</span> <span class="kc">null</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="nx">_dri</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
<span class="nx">DOMReady</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</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="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"></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"><</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="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="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="c"> * <p>type &lt;string&gt;, args &lt;array&gt;, customobject &lt;object&gt;</p></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"></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">'event:ready'</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="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('addListener: ' + Y.Lang.dump(Y.Array(arguments, 0, true), 1));</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 + " addListener call failed, callback undefined");</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">" addListener call failed, invalid callback"</span><span class="o">,</span> <span class="s2">"error"</span><span class="o">,</span> <span class="s2">"Event"</span><span class="o">);</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"></span> <span class="c">// Y.log('collection: ' + el.item(0) + ', ' + el.item(1));</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="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="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="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"></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="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">></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="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="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"></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="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"></span> <span class="k">return</span> <span class="kc">false</span><span class="o">;</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">'event:'</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"></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"></span> <span class="nx">bubbles</span><span class="o">:</span> <span class="kc">false</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="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"></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="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="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="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"></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="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">&&</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="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"></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">"string"</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"></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"><</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">&&</span> <span class="nx">ok</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"></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="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="s1">'event:'</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="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">&&</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="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="c">// Y.log('wrapper for facade: ' + 'event:' + Y.stamp(boundEl) + e.type);</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">'event:'</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="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="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">return</span> <span class="o">(</span> <span class="nx">o</span> <span class="o">&&</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">"string"</span> <span class="o">&&</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">&&</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">&&</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">&&</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">"undefined"</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">"collection check failure"</span><span class="o">,</span> <span class="s2">"warn"</span><span class="o">);</span>
<span class="c"></span> <span class="c">// DOMReadyEvent: Y.publish("event:ready", this, {</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"></span> <span class="nx">Y</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">fire</span><span class="o">(</span><span class="s1">'event:ready'</span><span class="o">);</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="nx">E</span><span class="o">.</span><span class="nx">_tryPreloadAttach</span><span class="o">();</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">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"></span> <span class="c">// readyState to protect against the IE operation aborted</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">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"></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="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">></span> <span class="m">0</span><span class="o">);</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="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="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="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"></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"><</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">&&</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="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="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"><</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">&&</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"></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="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="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"></span> <span class="k">this</span><span class="o">.</span><span class="nx">startInterval</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="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="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"><</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="k">if</span> <span class="o">(</span><span class="nx">recurse</span> <span class="o">&&</span> <span class="nx">oEl</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="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"><</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="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">'event:'</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="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="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="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="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">"unload"</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">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">"on"</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">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">"on"</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="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"></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">&&</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s1">'event:ready'</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="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="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="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="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">"load"</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">"unload"</span><span class="o">,</span> <span class="nx">E</span><span class="o">.</span><span class="nx">_unload</span><span class="o">);</span>