get.js.html revision 4fcbec6145d16637205990699912fb90f6a3807c
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>API: yui get.js (YUI Library)</title>
<link rel="stylesheet" type="text/css" href="assets/api.css">
<script type="text/javascript" src="assets/api-js"></script>
<script type="text/javascript" src="assets/ac-js"></script>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
<h3>yui&nbsp; <span class="subtitle">3.00PR1</span></h3>
<p>
<a href="/index.html">Yahoo! UI Library</a>
&gt; <a href="/module_yui.html">yui</a>
&gt; get.js (source view)
</p>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="yui-classopts-form">
<span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> <label for="showprivate">Show Private</label></span>
<span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> <label for="showprotected">Show Protected</label></span>
<span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> <label for="showdeprecated">Show Deprecated</label></span>
</form>
<div id="srcout">
<style>
#doc3 #classopts { display:none; }
</style>
<div class="highlight" ><pre><span class="nx">YUI</span><span class="o">.</span><span class="nx">add</span><span class="o">(</span><span class="s2">&quot;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>
<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>
<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>
<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 yui</span>
<span class="c"> * @submodule 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"> * 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">context</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="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"> * 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"> * 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="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="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="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">context</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;Timeout &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="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">context</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">if</span> <span class="o">(</span><span class="nx">queues</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="nx">i</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="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"> * 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">context</span> <span class="o">=</span> <span class="nx">q</span><span class="o">.</span><span class="nx">context</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 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"> * 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 o {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;onTimeout&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;</span>
<span class="c"> * callback to execute when a timeout occurs.</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;context&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;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;dt&gt;timeout&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;Number of milliseconds to wait before aborting and firing the timeout event&lt;/dd&gt;</span>
<span class="c"> * &lt;pre&gt;</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.5.2/build/yahoo/yahoo-min.js&quot;,</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;http://yui.yahooapis.com/2.5.2/build/event/event-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;this.log(&quot;won&#39;t cause error because Y is the context&quot;);</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Y.log(o.data); // foo</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Y.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;Y.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;onTimeout: function(o) &amp;#123;</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Y.log(&quot;transaction timed out&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;timeout: 10000, // 10 second timeout</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context: Y, // make the YUI instance</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;context&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"> * &amp;nbsp;&amp;nbsp;Y.Get.css(</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;[&quot;http://yui.yahooapis.com/2.3.1/build/menu/assets/skins/sam/menu.css&quot;,</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;http://yui.yahooapis.com/2.3.1/build/logger/assets/skins/sam/logger.css&quot;], &amp;#123;</span>
<span class="c"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;insertBefore: &#39;custom-styles&#39; // nodes will be inserted before the specified node</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">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_anim.html">anim</a></li>
<li class=""><a href="module_attribute.html">attribute</a></li>
<li class=""><a href="module_base.html">base</a></li>
<li class=""><a href="module_dd.html">dd</a></li>
<li class=""><a href="module_dd-plugin.html">dd-plugin</a></li>
<li class=""><a href="module_dump.html">dump</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_node.html">node</a></li>
<li class=""><a href="module_oop.html">oop</a></li>
<li class=""><a href="module_queue.html">queue</a></li>
<li class=""><a href="module_substitute.html">substitute</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="Loader.html">Loader</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="selected"><a href="get.js.html">get.js</a></li>
<li class=""><a href="loader.js.html">loader.js</a></li>
<li class=""><a href="yui-array.js.html">yui-array.js</a></li>
<li class=""><a href="yui-base.js.html">yui-base.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=""><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>