yui-get.js.html revision ace5e2555c33a0ceddef42649f6f38fa006707cc
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
b1c39f37bdd5f51ec6a90991eb0c586867a02da5Matt Sweeney<html>
b1c39f37bdd5f51ec6a90991eb0c586867a02da5Matt Sweeney<head>
b1c39f37bdd5f51ec6a90991eb0c586867a02da5Matt Sweeney <title>API: yui yui-get.js (YUI Library)</title>
b1c39f37bdd5f51ec6a90991eb0c586867a02da5Matt Sweeney <link rel="stylesheet" type="text/css" href="assets/api.css">
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <script type="text/javascript" src="assets/api-js"></script>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <script type="text/javascript" src="assets/ac-js"></script>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney</head>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney<body id="yahoo-com">
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney<div id="doc3" class="yui-t2">
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <div id="hd">
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <h3>yui&nbsp; <span class="subtitle">3.00PR1</span></h3>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <p>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <a href="/index.html">Yahoo! UI Library</a>
cb742409a5b74a0dcae38d50f3565e9bbadb93b8Matt Sweeney &gt; <a href="/module_yui.html">yui</a>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney &gt; yui-get.js (source view)
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney </p>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney </div>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <div id="bd">
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <div id="yui-main">
0b5b717e67174f60b93146fe0f74b1ebe6f0ca7cMatt Sweeney <div class="yui-b">
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <form name="yui-classopts-form">
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> Show Private</span>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> Show Deprecated</span>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney </form>
308519cb5905de3c04732c5f356c17b43c004039Matt Sweeney
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <div id="srcout">
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <style>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney #doc3 #classopts { display:none; }
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney </style>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney<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;get&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>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <span class="k">var</span> <span class="nx">ua</span><span class="o">=</span><span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">,</span>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney <span class="nx">L</span><span class="o">=</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Lang</span><span class="o">;</span>
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney
53c29b5c2e45418277bf03d6fc5dd81882abcff8Matt Sweeney<span class="c">/*</span>
<span class="c"> * Provides a mechanism to fetch remote resources and</span>
<span class="c"> * insert them into a document</span>
<span class="c"> * @module get</span>
<span class="c"> */</span>
<span class="c">/**</span>
<span class="c"> * Fetches and inserts one or more script or link nodes into the document </span>
<span class="c"> * @class Get</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">Get</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"> * hash of queues to manage multiple requests</span>
<span class="c"> * @property queues</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">queues</span><span class="o">={},</span>
<span class="c">/**</span>
<span class="c"> * queue index used to generate transaction ids</span>
<span class="c"> * @property qidx</span>
<span class="c"> * @type int</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">qidx</span><span class="o">=</span><span class="m">0</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * node index used to generate unique node ids</span>
<span class="c"> * @property nidx</span>
<span class="c"> * @type int</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">nidx</span><span class="o">=</span><span class="m">0</span><span class="o">,</span>
<span class="c">// ridx=0,</span>
<span class="c"></span>
<span class="c">// sandboxFrame=null,</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * interal property used to prevent multiple simultaneous purge </span>
<span class="c"> * processes</span>
<span class="c"> * @property purging</span>
<span class="c"> * @type boolean</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">purging</span><span class="o">=</span><span class="kc">false</span><span class="o">;</span>
<span class="c">/** </span>
<span class="c"> * Generates an HTML element, this is not appended to a document</span>
<span class="c"> * @method _node</span>
<span class="c"> * @param type {string} the type of element</span>
<span class="c"> * @param attr {string} the attributes</span>
<span class="c"> * @param win {Window} optional window to create the element in</span>
<span class="c"> * @return {HTMLElement} the generated node</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_node</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">attr</span><span class="o">,</span> <span class="nx">win</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nx">win</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">win</span><span class="o">,</span> <span class="nx">d</span><span class="o">=</span><span class="nx">w</span><span class="o">.</span><span class="nb">document</span><span class="o">,</span> <span class="nx">n</span><span class="o">=</span><span class="nx">d</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="nx">type</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">attr</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">attr</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Object</span><span class="o">.</span><span class="nx">owns</span><span class="o">(</span><span class="nx">attr</span><span class="o">,</span> <span class="nx">i</span><span class="o">))</span> <span class="o">{</span>
<span class="nx">n</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="nx">i</span><span class="o">,</span> <span class="nx">attr</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="nx">n</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Generates a link node</span>
<span class="c"> * @method _linkNode</span>
<span class="c"> * @param url {string} the url for the css file</span>
<span class="c"> * @param win {Window} optional window to create the node in</span>
<span class="c"> * @return {HTMLElement} the generated node</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_linkNode</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">url</span><span class="o">,</span> <span class="nx">win</span><span class="o">,</span> <span class="nx">charset</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="nx">charset</span> <span class="o">||</span> <span class="s2">&quot;utf-8&quot;</span><span class="o">;</span>
<span class="k">return</span> <span class="nx">_node</span><span class="o">(</span><span class="s2">&quot;link&quot;</span><span class="o">,</span> <span class="o">{</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;yui__dyn_&quot;</span> <span class="o">+</span> <span class="o">(</span><span class="nx">nidx</span><span class="o">++),</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;text/css&quot;</span><span class="o">,</span>
<span class="s2">&quot;charset&quot;</span><span class="o">:</span> <span class="nx">c</span><span class="o">,</span>
<span class="s2">&quot;rel&quot;</span><span class="o">:</span> <span class="s2">&quot;stylesheet&quot;</span><span class="o">,</span>
<span class="s2">&quot;href&quot;</span><span class="o">:</span> <span class="nx">url</span>
<span class="o">},</span> <span class="nx">win</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Generates a script node</span>
<span class="c"> * @method _scriptNode</span>
<span class="c"> * @param url {string} the url for the script file</span>
<span class="c"> * @param win {Window} optional window to create the node in</span>
<span class="c"> * @return {HTMLElement} the generated node</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_scriptNode</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">url</span><span class="o">,</span> <span class="nx">win</span><span class="o">,</span> <span class="nx">charset</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="nx">charset</span> <span class="o">||</span> <span class="s2">&quot;utf-8&quot;</span><span class="o">;</span>
<span class="k">return</span> <span class="nx">_node</span><span class="o">(</span><span class="s2">&quot;script&quot;</span><span class="o">,</span> <span class="o">{</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;yui__dyn_&quot;</span> <span class="o">+</span> <span class="o">(</span><span class="nx">nidx</span><span class="o">++),</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;text/javascript&quot;</span><span class="o">,</span>
<span class="s2">&quot;charset&quot;</span><span class="o">:</span> <span class="nx">c</span><span class="o">,</span>
<span class="s2">&quot;src&quot;</span><span class="o">:</span> <span class="nx">url</span>
<span class="o">},</span> <span class="nx">win</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Returns the data payload for callback functions</span>
<span class="c"> * @method _returnData</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_returnData</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">q</span><span class="o">,</span> <span class="nx">msg</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="o">{</span>
<span class="nx">tId</span><span class="o">:</span> <span class="nx">q</span><span class="o">.</span><span class="nx">tId</span><span class="o">,</span>
<span class="nx">win</span><span class="o">:</span> <span class="nx">q</span><span class="o">.</span><span class="nx">win</span><span class="o">,</span>
<span class="nx">data</span><span class="o">:</span> <span class="nx">q</span><span class="o">.</span><span class="nx">data</span><span class="o">,</span>
<span class="nx">nodes</span><span class="o">:</span> <span class="nx">q</span><span class="o">.</span><span class="nx">nodes</span><span class="o">,</span>
<span class="nx">msg</span><span class="o">:</span> <span class="nx">msg</span><span class="o">,</span>
<span class="nx">purge</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="nx">_purge</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">tId</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">_get</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">nId</span><span class="o">,</span> <span class="nx">tId</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">q</span> <span class="o">=</span> <span class="nx">queues</span><span class="o">[</span><span class="nx">tId</span><span class="o">],</span>
<span class="nx">n</span> <span class="o">=</span> <span class="o">(</span><span class="nx">L</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">nId</span><span class="o">))</span> <span class="o">?</span> <span class="nx">q</span><span class="o">.</span><span class="nx">win</span><span class="o">.</span><span class="nb">document</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">nId</span><span class="o">)</span> <span class="o">:</span> <span class="nx">nId</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">n</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_fail</span><span class="o">(</span><span class="nx">tId</span><span class="o">,</span> <span class="s2">&quot;target node not found: &quot;</span> <span class="o">+</span> <span class="nx">nId</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">return</span> <span class="nx">n</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">/*</span>
<span class="c"> * The request failed, execute fail handler with whatever</span>
<span class="c"> * was accomplished. There isn&#39;t a failure case at the</span>
<span class="c"> * moment unless you count aborted transactions</span>
<span class="c"> * @method _fail</span>
<span class="c"> * @param id {string} the id of the request</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_fail</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">msg</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;get failure: &quot;</span> <span class="o">+</span> <span class="nx">msg</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="s2">&quot;Get&quot;</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">q</span> <span class="o">=</span> <span class="nx">queues</span><span class="o">[</span><span class="nx">id</span><span class="o">];</span>
<span class="c">// execute failure callback</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">onFailure</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">sc</span><span class="o">=</span><span class="nx">q</span><span class="o">.</span><span class="nx">scope</span> <span class="o">||</span> <span class="nx">q</span><span class="o">;</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">onFailure</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">sc</span><span class="o">,</span> <span class="nx">_returnData</span><span class="o">(</span><span class="nx">q</span><span class="o">,</span> <span class="nx">msg</span><span class="o">));</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * The request is complete, so executing the requester&#39;s callback</span>
<span class="c"> * @method _finish</span>
<span class="c"> * @param id {string} the id of the request</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_finish</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="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Finishing transaction &quot;</span> <span class="o">+</span> <span class="nx">id</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">q</span> <span class="o">=</span> <span class="nx">queues</span><span class="o">[</span><span class="nx">id</span><span class="o">];</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">finished</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">q</span><span class="o">.</span><span class="nx">aborted</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">msg</span> <span class="o">=</span> <span class="s2">&quot;transaction &quot;</span> <span class="o">+</span> <span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot; was aborted&quot;</span><span class="o">;</span>
<span class="nx">_fail</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">msg</span><span class="o">);</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// execute success callback</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">onSuccess</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">sc</span><span class="o">=</span><span class="nx">q</span><span class="o">.</span><span class="nx">scope</span> <span class="o">||</span> <span class="nx">q</span><span class="o">;</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">onSuccess</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">sc</span><span class="o">,</span> <span class="nx">_returnData</span><span class="o">(</span><span class="nx">q</span><span class="o">));</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Timeout detected</span>
<span class="c"> * @method _timeout</span>
<span class="c"> * @param id {string} the id of the request</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_timeout</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="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Get utility timeout &quot;</span> <span class="o">+</span> <span class="nx">id</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">q</span> <span class="o">=</span> <span class="nx">queues</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">q</span><span class="o">.</span><span class="nx">onTimeout</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">sc</span><span class="o">=</span><span class="nx">q</span><span class="o">.</span><span class="nx">scope</span> <span class="o">||</span> <span class="nx">q</span><span class="o">;</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">onTimeout</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">sc</span><span class="o">,</span> <span class="nx">_returnData</span><span class="o">(</span><span class="nx">q</span><span class="o">));</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Loads the next item for a given request</span>
<span class="c"> * @method _next</span>
<span class="c"> * @param id {string} the id of the request</span>
<span class="c"> * @param loaded {string} the url that was just loaded, if any</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_next</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">loaded</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;_next: &quot;</span> <span class="o">+</span> <span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;, loaded: &quot;</span> <span class="o">+</span> <span class="nx">loaded</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Get&quot;</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">q</span> <span class="o">=</span> <span class="nx">queues</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">q</span><span class="o">.</span><span class="nx">timer</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;cancel timer&#39;);</span>
<span class="c"></span> <span class="nx">q</span><span class="o">.</span><span class="nx">timer</span><span class="o">.</span><span class="nx">cancel</span><span class="o">();</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">aborted</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">msg</span> <span class="o">=</span> <span class="s2">&quot;transaction &quot;</span> <span class="o">+</span> <span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot; was aborted&quot;</span><span class="o">;</span>
<span class="nx">_fail</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">msg</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">loaded</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">url</span><span class="o">.</span><span class="nx">shift</span><span class="o">();</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">varName</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">varName</span><span class="o">.</span><span class="nx">shift</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">// This is the first pass: make sure the url is an array</span>
<span class="c"></span> <span class="nx">q</span><span class="o">.</span><span class="nx">url</span> <span class="o">=</span> <span class="o">(</span><span class="nx">L</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">url</span><span class="o">))</span> <span class="o">?</span> <span class="o">[</span><span class="nx">q</span><span class="o">.</span><span class="nx">url</span><span class="o">]</span> <span class="o">:</span> <span class="nx">q</span><span class="o">.</span><span class="nx">url</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">varName</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">varName</span> <span class="o">=</span> <span class="o">(</span><span class="nx">L</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">varName</span><span class="o">))</span> <span class="o">?</span> <span class="o">[</span><span class="nx">q</span><span class="o">.</span><span class="nx">varName</span><span class="o">]</span> <span class="o">:</span> <span class="nx">q</span><span class="o">.</span><span class="nx">varName</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">var</span> <span class="nx">w</span><span class="o">=</span><span class="nx">q</span><span class="o">.</span><span class="nx">win</span><span class="o">,</span> <span class="nx">d</span><span class="o">=</span><span class="nx">w</span><span class="o">.</span><span class="nb">document</span><span class="o">,</span> <span class="nx">h</span><span class="o">=</span><span class="nx">d</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="s2">&quot;head&quot;</span><span class="o">)[</span><span class="m">0</span><span class="o">],</span> <span class="nx">n</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">url</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="nx">_finish</span><span class="o">(</span><span class="nx">id</span><span class="o">);</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">var</span> <span class="nx">url</span> <span class="o">=</span> <span class="nx">q</span><span class="o">.</span><span class="nx">url</span><span class="o">[</span><span class="m">0</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;attempting to load &quot;</span> <span class="o">+</span> <span class="nx">url</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Get&quot;</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">timeout</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;create timer&#39;);</span>
<span class="c"></span> <span class="nx">q</span><span class="o">.</span><span class="nx">timer</span> <span class="o">=</span> <span class="nx">L</span><span class="o">.</span><span class="nx">later</span><span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">timeout</span><span class="o">,</span> <span class="nx">q</span><span class="o">,</span> <span class="nx">_timeout</span><span class="o">,</span> <span class="nx">id</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">type</span> <span class="o">===</span> <span class="s2">&quot;script&quot;</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">n</span> <span class="o">=</span> <span class="nx">_scriptNode</span><span class="o">(</span><span class="nx">url</span><span class="o">,</span> <span class="nx">w</span><span class="o">,</span> <span class="nx">q</span><span class="o">.</span><span class="nx">charset</span><span class="o">);</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="nx">n</span> <span class="o">=</span> <span class="nx">_linkNode</span><span class="o">(</span><span class="nx">url</span><span class="o">,</span> <span class="nx">w</span><span class="o">,</span> <span class="nx">q</span><span class="o">.</span><span class="nx">charset</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">// track this node&#39;s load progress</span>
<span class="c"></span> <span class="nx">_track</span><span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">type</span><span class="o">,</span> <span class="nx">n</span><span class="o">,</span> <span class="nx">id</span><span class="o">,</span> <span class="nx">url</span><span class="o">,</span> <span class="nx">w</span><span class="o">,</span> <span class="nx">q</span><span class="o">.</span><span class="nx">url</span><span class="o">.</span><span class="nx">length</span><span class="o">);</span>
<span class="c">// add the node to the queue so we can return it to the user supplied callback</span>
<span class="c"></span> <span class="nx">q</span><span class="o">.</span><span class="nx">nodes</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">n</span><span class="o">);</span>
<span class="c">// add it to the head or insert it before &#39;insertBefore&#39;</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="nx">_get</span><span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">insertBefore</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">s</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">s</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">n</span><span class="o">,</span> <span class="nx">s</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">h</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">n</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;Appending node: &quot;</span> <span class="o">+</span> <span class="nx">url</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Get&quot;</span><span class="o">);</span>
<span class="c">// FireFox does not support the onload event for link nodes, so there is</span>
<span class="c"></span> <span class="c">// no way to make the css requests synchronous. This means that the css </span>
<span class="c"></span> <span class="c">// rules in multiple files could be applied out of order in this browser</span>
<span class="c"></span> <span class="c">// if a later request returns before an earlier one. Safari too.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">((</span><span class="nx">ua</span><span class="o">.</span><span class="nx">webkit</span> <span class="o">||</span> <span class="nx">ua</span><span class="o">.</span><span class="nx">gecko</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">q</span><span class="o">.</span><span class="nx">type</span> <span class="o">===</span> <span class="s2">&quot;css&quot;</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_next</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">url</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Removes processed queues and corresponding nodes</span>
<span class="c"> * @method _autoPurge</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_autoPurge</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="nx">purging</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="nx">purging</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="k">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">queues</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">q</span> <span class="o">=</span> <span class="nx">queues</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">q</span><span class="o">.</span><span class="nx">autopurge</span> <span class="o">&amp;&amp;</span> <span class="nx">q</span><span class="o">.</span><span class="nx">finished</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_purge</span><span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">tId</span><span class="o">);</span>
<span class="nx">delete</span> <span class="nx">queues</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="nx">purging</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Removes the nodes for the specified queue</span>
<span class="c"> * @method _purge</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_purge</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">tId</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">q</span><span class="o">=</span><span class="nx">queues</span><span class="o">[</span><span class="nx">tId</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">q</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">n</span><span class="o">=</span><span class="nx">q</span><span class="o">.</span><span class="nx">nodes</span><span class="o">,</span> <span class="nx">l</span><span class="o">=</span><span class="nx">n</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span> <span class="nx">d</span><span class="o">=</span><span class="nx">q</span><span class="o">.</span><span class="nx">win</span><span class="o">.</span><span class="nb">document</span><span class="o">,</span>
<span class="nx">h</span><span class="o">=</span><span class="nx">d</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="s2">&quot;head&quot;</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">q</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="nx">_get</span><span class="o">(</span><span class="nx">q</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">,</span> <span class="nx">tId</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">s</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">h</span> <span class="o">=</span> <span class="nx">s</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
<span class="o">}</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">l</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">h</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">n</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">nodes</span> <span class="o">=</span> <span class="o">[];</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Saves the state for the request and begins loading</span>
<span class="c"> * the requested urls</span>
<span class="c"> * @method queue</span>
<span class="c"> * @param type {string} the type of node to insert</span>
<span class="c"> * @param url {string} the url to load</span>
<span class="c"> * @param opts the hash of options for this request</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_queue</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">url</span><span class="o">,</span> <span class="nx">opts</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="s2">&quot;q&quot;</span> <span class="o">+</span> <span class="o">(</span><span class="nx">qidx</span><span class="o">++);</span>
<span class="nx">opts</span> <span class="o">=</span> <span class="nx">opts</span> <span class="o">||</span> <span class="o">{};</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">qidx</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">PURGE_THRESH</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_autoPurge</span><span class="o">();</span>
<span class="o">}</span>
<span class="nx">queues</span><span class="o">[</span><span class="nx">id</span><span class="o">]</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">merge</span><span class="o">(</span><span class="nx">opts</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">tId</span><span class="o">:</span> <span class="nx">id</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">url</span><span class="o">:</span> <span class="nx">url</span><span class="o">,</span>
<span class="nx">finished</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
<span class="nx">nodes</span><span class="o">:</span> <span class="o">[]</span>
<span class="o">});</span>
<span class="k">var</span> <span class="nx">q</span> <span class="o">=</span> <span class="nx">queues</span><span class="o">[</span><span class="nx">id</span><span class="o">];</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">win</span> <span class="o">=</span> <span class="nx">q</span><span class="o">.</span><span class="nx">win</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">win</span><span class="o">;</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">scope</span> <span class="o">=</span> <span class="nx">q</span><span class="o">.</span><span class="nx">scope</span> <span class="o">||</span> <span class="nx">q</span><span class="o">;</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">autopurge</span> <span class="o">=</span> <span class="o">(</span><span class="s2">&quot;autopurge&quot;</span> <span class="k">in</span> <span class="nx">q</span><span class="o">)</span> <span class="o">?</span> <span class="nx">q</span><span class="o">.</span><span class="nx">autopurge</span> <span class="o">:</span>
<span class="o">(</span><span class="nx">type</span> <span class="o">===</span> <span class="s2">&quot;script&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>
<span class="nx">L</span><span class="o">.</span><span class="nx">later</span><span class="o">(</span><span class="m">0</span><span class="o">,</span> <span class="nx">q</span><span class="o">,</span> <span class="nx">_next</span><span class="o">,</span> <span class="nx">id</span><span class="o">);</span>
<span class="k">return</span> <span class="o">{</span>
<span class="nx">tId</span><span class="o">:</span> <span class="nx">id</span>
<span class="o">};</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Detects when a node has been loaded. In the case of</span>
<span class="c"> * script nodes, this does not guarantee that contained</span>
<span class="c"> * script is ready to use.</span>
<span class="c"> * @method _track</span>
<span class="c"> * @param type {string} the type of node to track</span>
<span class="c"> * @param n {HTMLElement} the node to track</span>
<span class="c"> * @param id {string} the id of the request</span>
<span class="c"> * @param url {string} the url that is being loaded</span>
<span class="c"> * @param win {Window} the targeted window</span>
<span class="c"> * @param qlength the number of remaining items in the queue,</span>
<span class="c"> * including this one</span>
<span class="c"> * @param trackfn {Function} function to execute when finished</span>
<span class="c"> * the default is _next</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">_track</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">n</span><span class="o">,</span> <span class="nx">id</span><span class="o">,</span> <span class="nx">url</span><span class="o">,</span> <span class="nx">win</span><span class="o">,</span> <span class="nx">qlength</span><span class="o">,</span> <span class="nx">trackfn</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">trackfn</span> <span class="o">||</span> <span class="nx">_next</span><span class="o">;</span>
<span class="c">// IE supports the readystatechange event for script and css nodes</span>
<span class="c"></span> <span class="k">if</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">n</span><span class="o">.</span><span class="nx">onreadystatechange</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">rs</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">readyState</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="s2">&quot;loaded&quot;</span> <span class="o">===</span> <span class="nx">rs</span> <span class="o">||</span> <span class="s2">&quot;complete&quot;</span> <span class="o">===</span> <span class="nx">rs</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="nx">id</span> <span class="o">+</span> <span class="s2">&quot; onload &quot;</span> <span class="o">+</span> <span class="nx">url</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Get&quot;</span><span class="o">);</span>
<span class="nx">f</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">url</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">// webkit prior to 3.x is no longer supported</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="nx">ua</span><span class="o">.</span><span class="nx">webkit</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">type</span> <span class="o">===</span> <span class="s2">&quot;script&quot;</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Safari 3.x supports the load event for script nodes (DOM2)</span>
<span class="c"></span> <span class="nx">n</span><span class="o">.</span><span class="nx">addEventListener</span><span class="o">(</span><span class="s2">&quot;load&quot;</span><span class="o">,</span> <span class="k">function</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="nx">id</span> <span class="o">+</span> <span class="s2">&quot; DOM2 onload &quot;</span> <span class="o">+</span> <span class="nx">url</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Get&quot;</span><span class="o">);</span>
<span class="nx">f</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">url</span><span class="o">);</span>
<span class="o">});</span>
<span class="o">}</span>
<span class="c">// FireFox and Opera support onload (but not DOM2 in FF) handlers for</span>
<span class="c"></span> <span class="c">// script nodes. Opera, but not FF, supports the onload event for link</span>
<span class="c"></span> <span class="c">// nodes.</span>
<span class="c"></span> <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="nx">n</span><span class="o">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="k">function</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="nx">id</span> <span class="o">+</span> <span class="s2">&quot; onload &quot;</span> <span class="o">+</span> <span class="nx">url</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Get&quot;</span><span class="o">);</span>
<span class="nx">f</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">url</span><span class="o">);</span>
<span class="o">};</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 default poll freqency in ms, when needed</span>
<span class="c"> * @property POLL_FREQ</span>
<span class="c"> * @static</span>
<span class="c"> * @type int</span>
<span class="c"> * @default 10</span>
<span class="c"> */</span>
<span class="nx">POLL_FREQ</span><span class="o">:</span> <span class="m">10</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * The number of request required before an automatic purge.</span>
<span class="c"> * property PURGE_THRESH</span>
<span class="c"> * @static</span>
<span class="c"> * @type int</span>
<span class="c"> * @default 20</span>
<span class="c"> */</span>
<span class="nx">PURGE_THRESH</span><span class="o">:</span> <span class="m">20</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * The length time to poll for varName when loading a script in</span>
<span class="c"> * Safari 2.x before the transaction fails.</span>
<span class="c"> * property TIMEOUT</span>
<span class="c"> * @static</span>
<span class="c"> * @type int</span>
<span class="c"> * @default 2000</span>
<span class="c"> */</span>
<span class="nx">TIMEOUT</span><span class="o">:</span> <span class="m">2000</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * Called by the the helper for detecting script load in Safari</span>
<span class="c"> * @method _finalize</span>
<span class="c"> * @param id {string} the transaction id</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_finalize</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="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot; finalized &quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Get&quot;</span><span class="o">);</span>
<span class="nx">L</span><span class="o">.</span><span class="nx">later</span><span class="o">(</span><span class="m">0</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="nx">_finish</span><span class="o">,</span> <span class="nx">id</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Abort a transaction</span>
<span class="c"> * @method abort</span>
<span class="c"> * @param {string|object} either the tId or the object returned from</span>
<span class="c"> * script() or css()</span>
<span class="c"> */</span>
<span class="nx">abort</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">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="o">(</span><span class="nx">L</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">o</span><span class="o">))</span> <span class="o">?</span> <span class="nx">o</span> <span class="o">:</span> <span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">q</span> <span class="o">=</span> <span class="nx">queues</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">q</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;Aborting &quot;</span> <span class="o">+</span> <span class="nx">id</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Get&quot;</span><span class="o">);</span>
<span class="nx">q</span><span class="o">.</span><span class="nx">aborted</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Fetches and inserts one or more script nodes into the head</span>
<span class="c"> * of the current document or the document in a specified window.</span>
<span class="c"> *</span>
<span class="c"> * @method script</span>
<span class="c"> * @static</span>
<span class="c"> * @param url {string|string[]} the url or urls to the script(s)</span>
<span class="c"> * @param opts {object} Options: </span>
<span class="c"> * &lt;dl&gt;</span>
<span class="c"> * &lt;dt&gt;onSuccess&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;</span>
<span class="c"> * callback to execute when the script(s) are finished loading</span>
<span class="c"> * The callback receives an object back with the following</span>
<span class="c"> * data:</span>
<span class="c"> * &lt;dl&gt;</span>
<span class="c"> * &lt;dt&gt;win&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;the window the script(s) were inserted into&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;data&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;the data object passed in when the request was made&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;nodes&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;An array containing references to the nodes that were</span>
<span class="c"> * inserted&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;purge&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;A function that, when executed, will remove the nodes</span>
<span class="c"> * that were inserted&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> * &lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;onFailure&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;</span>
<span class="c"> * callback to execute when the script load operation fails</span>
<span class="c"> * The callback receives an object back with the following</span>
<span class="c"> * data:</span>
<span class="c"> * &lt;dl&gt;</span>
<span class="c"> * &lt;dt&gt;win&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;the window the script(s) were inserted into&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;data&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;the data object passed in when the request was made&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;nodes&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;An array containing references to the nodes that were</span>
<span class="c"> * inserted successfully&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;purge&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;A function that, when executed, will remove any nodes</span>
<span class="c"> * that were inserted&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> * &lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;scope&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;the execution context for the callbacks&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;win&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;a window other than the one the utility occupies&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;autopurge&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;</span>
<span class="c"> * setting to true will let the utilities cleanup routine purge </span>
<span class="c"> * the script once loaded</span>
<span class="c"> * &lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;data&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;</span>
<span class="c"> * data that is supplied to the callback when the script(s) are</span>
<span class="c"> * loaded.</span>
<span class="c"> * &lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;varName&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;</span>
<span class="c"> * variable that should be available when a script is finished</span>
<span class="c"> * loading. Used to help Safari 2.x and below with script load </span>
<span class="c"> * detection. The type of this property should match what was</span>
<span class="c"> * passed into the url parameter: if loading a single url, a</span>
<span class="c"> * string can be supplied. If loading multiple scripts, you</span>
<span class="c"> * must supply an array that contains the variable name for</span>
<span class="c"> * each script.</span>
<span class="c"> * &lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;insertBefore&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;node or node id that will become the new node&#39;s nextSibling&lt;/dd&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> * &lt;dt&gt;charset&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;Node charset, default utf-8&lt;/dd&gt;</span>
<span class="c"> * &lt;pre&gt;</span>
<span class="c"> * // assumes yahoo, dom, and event are already on the page</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;Y.Get.script(</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;[&quot;http://yui.yahooapis.com/2.3.1/build/dragdrop/dragdrop-min.js&quot;,</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;http://yui.yahooapis.com/2.3.1/build/animation/animation-min.js&quot;], &amp;#123;</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;onSuccess: function(o) &amp;#123;</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(o.data); // foo</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new Y.DDProxy(&quot;dd1&quot;); // also new o.reference(&quot;dd1&quot;); would work</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.log(&quot;won&#39;t cause error because Y is the scope&quot;);</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.log(o.nodes.length === 2) // true</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// o.purge(); // optionally remove the script nodes immediately</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#125;,</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;onFailure: function(o) &amp;#123;</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(&quot;transaction failed&quot;);</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#125;,</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;data: &quot;foo&quot;,</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;scope: Y,</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// win: otherframe // target another window/frame</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;autopurge: true // allow the utility to choose when to remove the nodes</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;#125;);</span>
<span class="c"> * &lt;/pre&gt;</span>
<span class="c"> * @return {tId: string} an object containing info about the transaction</span>
<span class="c"> */</span>
<span class="nx">script</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">url</span><span class="o">,</span> <span class="nx">opts</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="nx">_queue</span><span class="o">(</span><span class="s2">&quot;script&quot;</span><span class="o">,</span> <span class="nx">url</span><span class="o">,</span> <span class="nx">opts</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Fetches and inserts one or more css link nodes into the </span>
<span class="c"> * head of the current document or the document in a specified</span>
<span class="c"> * window.</span>
<span class="c"> * @method css</span>
<span class="c"> * @static</span>
<span class="c"> * @param url {string} the url or urls to the css file(s)</span>
<span class="c"> * @param opts Options: </span>
<span class="c"> * &lt;dl&gt;</span>
<span class="c"> * &lt;dt&gt;onSuccess&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;</span>
<span class="c"> * callback to execute when the css file(s) are finished loading</span>
<span class="c"> * The callback receives an object back with the following</span>
<span class="c"> * data:</span>
<span class="c"> * &lt;dl&gt;win&lt;/dl&gt;</span>
<span class="c"> * &lt;dd&gt;the window the link nodes(s) were inserted into&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;data&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;the data object passed in when the request was made&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;nodes&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;An array containing references to the nodes that were</span>
<span class="c"> * inserted&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;purge&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;A function that, when executed, will remove the nodes</span>
<span class="c"> * that were inserted&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> * &lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;scope&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;the execution context for the callbacks&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;win&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;a window other than the one the utility occupies&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;data&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;</span>
<span class="c"> * data that is supplied to the callbacks when the nodes(s) are</span>
<span class="c"> * loaded.</span>
<span class="c"> * &lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;insertBefore&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;node or node id that will become the new node&#39;s nextSibling&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;charset&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;Node charset, default utf-8&lt;/dd&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> * &lt;pre&gt;</span>
<span class="c"> * Y.Get.css(&quot;http://yui.yahooapis.com/2.3.1/build/menu/assets/skins/sam/menu.css&quot;);</span>
<span class="c"> * &lt;/pre&gt;</span>
<span class="c"> * &lt;pre&gt;</span>
<span class="c"> * Y.Get.css([&quot;http://yui.yahooapis.com/2.3.1/build/menu/assets/skins/sam/menu.css&quot;,</span>
<span class="c"> * &quot;http://yui.yahooapis.com/2.3.1/build/logger/assets/skins/sam/logger.css&quot;]);</span>
<span class="c"> * &lt;/pre&gt;</span>
<span class="c"> * @return {tId: string} an object containing info about the transaction</span>
<span class="c"> */</span>
<span class="nx">css</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">url</span><span class="o">,</span> <span class="nx">opts</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="nx">_queue</span><span class="o">(</span><span class="s2">&quot;css&quot;</span><span class="o">,</span> <span class="nx">url</span><span class="o">,</span> <span class="nx">opts</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="o">}();</span>
<span class="o">},</span> <span class="s2">&quot;@VERSION@&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_animation.html">animation</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_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_node.html">node</a></li>
<li class=""><a href="module_node-region.html">node-region</a></li>
<li class=""><a href="module_nodeclassname.html">nodeclassname</a></li>
<li class=""><a href="module_nodeextras.html">nodeextras</a></li>
<li class="selected"><a href="module_yui.html">yui</a></li>
</ul>
</div>
<div class="module">
<h4>Classes</h4>
<ul class="content">
<li class=""><a href="Array.html">Array</a></li>
<li class=""><a href="Get.html">Get</a></li>
<li class=""><a href="Lang.html">Lang</a></li>
<li class=""><a href="Object.html">Object</a></li>
<li class=""><a href="UA.html">UA</a></li>
<li class=""><a href="YUI.html">YUI</a></li>
</ul>
</div>
<div class="module">
<h4>Files</h4>
<ul class="content">
<li class=""><a href="yui-array.js.html">yui-array.js</a></li>
<li class=""><a href="yui-core.js.html">yui-core.js</a></li>
<li class=""><a href="yui-dump.js.html">yui-dump.js</a></li>
<li class="selected"><a href="yui-get.js.html">yui-get.js</a></li>
<li class=""><a href="yui-init.js.html">yui-init.js</a></li>
<li class=""><a href="yui-lang.js.html">yui-lang.js</a></li>
<li class=""><a href="yui-later.js.html">yui-later.js</a></li>
<li class=""><a href="yui-log.js.html">yui-log.js</a></li>
<li class=""><a href="yui-object.js.html">yui-object.js</a></li>
<li class=""><a href="yui-ua.js.html">yui-ua.js</a></li>
<li class=""><a href="yui.js.html">yui.js</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright &copy; 2008 Yahoo! Inc. All rights reserved.
</div>
</div>
</body>
</html>