loader.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 loader.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; loader.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="c">/**</span>
<span class="c"> * Loader dynamically loads script and css files. It includes the dependency</span>
<span class="c"> * info for the version of the library in use, and will automatically pull in</span>
<span class="c"> * dependencies for the modules requested. It supports rollup files and will</span>
<span class="c"> * automatically use these when appropriate in order to minimize the number of</span>
<span class="c"> * http connections required to load all of the dependencies. It can load the</span>
<span class="c"> * files from the Yahoo! CDN, and it can utilize the combo service provided on</span>
<span class="c"> * this network to reduce the number of http connections required to download </span>
<span class="c"> * YUI files.</span>
<span class="c"> *</span>
<span class="c"> * @module yui</span>
<span class="c"> * @submodule loader</span>
<span class="c"> */</span>
<span class="c">/**</span>
<span class="c"> * Loader dynamically loads script and css files. It includes the dependency</span>
<span class="c"> * info for the version of the library in use, and will automatically pull in</span>
<span class="c"> * dependencies for the modules requested. It supports rollup files and will</span>
<span class="c"> * automatically use these when appropriate in order to minimize the number of</span>
<span class="c"> * http connections required to load all of the dependencies. It can load the</span>
<span class="c"> * files from the Yahoo! CDN, and it can utilize the combo service provided on</span>
<span class="c"> * this network to reduce the number of http connections required to download </span>
<span class="c"> * YUI files.</span>
<span class="c"> * @class Loader</span>
<span class="c"> * @constructor</span>
<span class="c"> * @param o an optional set of configuration options. Valid options:</span>
<span class="c"> * &lt;ul&gt;</span>
<span class="c"> * &lt;li&gt;base:</span>
<span class="c"> * The base dir&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;secureBase:</span>
<span class="c"> * The secure base dir (not implemented)&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;comboBase:</span>
<span class="c"> * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;root:</span>
<span class="c"> * The root path to prepend to module names for the combo service. Ex: 2.5.2/build/&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;filter:</span>
<span class="c"> * </span>
<span class="c"> * A filter to apply to result urls. This filter will modify the default</span>
<span class="c"> * path for all modules. The default path for the YUI library is the</span>
<span class="c"> * minified version of the files (e.g., event-min.js). The filter property</span>
<span class="c"> * can be a predefined filter or a custom filter. The valid predefined </span>
<span class="c"> * filters are:</span>
<span class="c"> * &lt;dl&gt;</span>
<span class="c"> * &lt;dt&gt;DEBUG&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;Selects the debug versions of the library (e.g., event-debug.js).</span>
<span class="c"> * This option will automatically include the logger widget&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;RAW&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;Selects the non-minified version of the library (e.g., event.js).&lt;/dd&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> * You can also define a custom filter, which must be an object literal </span>
<span class="c"> * containing a search expression and a replace string:</span>
<span class="c"> * &lt;pre&gt;</span>
<span class="c"> * myFilter: &amp;#123; </span>
<span class="c"> * &#39;searchExp&#39;: &quot;-min\\.js&quot;, </span>
<span class="c"> * &#39;replaceStr&#39;: &quot;-debug.js&quot;</span>
<span class="c"> * &amp;#125;</span>
<span class="c"> * &lt;/pre&gt;</span>
<span class="c"> *</span>
<span class="c"> * &lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;combine:</span>
<span class="c"> * Use the YUI combo service to reduce the number of http connections required to load your dependencies&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;ignore:</span>
<span class="c"> * A list of modules that should never be dynamically loaded&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;force:</span>
<span class="c"> * A list of modules that should always be loaded when required, even if already present on the page&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;insertBefore:</span>
<span class="c"> * Node or id for a node that should be used as the insertion point for new nodes&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;charset:</span>
<span class="c"> * charset for dynamic nodes&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;timeout:</span>
<span class="c"> * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;context:</span>
<span class="c"> * execution context for all callbacks&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;onSuccess:</span>
<span class="c"> * callback for the &#39;success&#39; event&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;onFailure:</span>
<span class="c"> * callback for the &#39;failure&#39; event&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;onTimeout:</span>
<span class="c"> * callback for the &#39;timeout&#39; event&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;onProgress:</span>
<span class="c"> * callback executed each time a script or css file is loaded&lt;/li&gt;</span>
<span class="c"> * &lt;li&gt;modules:</span>
<span class="c"> * A list of module definitions. See Loader.addModule for the supported module metadata&lt;/li&gt;</span>
<span class="c"> * &lt;/ul&gt;</span>
<span class="c"> */</span>
<span class="c">// @TODO backed out the custom event changes so that the event system</span>
<span class="c">// isn&#39;t required in the seed build. If needed, we may want to </span>
<span class="c">// add them back if the event system is detected.</span>
<span class="c"></span>
<span class="c">/*</span>
<span class="c"> * Executed when the loader successfully completes an insert operation</span>
<span class="c"> * This can be subscribed to normally, or a listener can be passed</span>
<span class="c"> * as an onSuccess config option.</span>
<span class="c"> * @event success</span>
<span class="c"> */</span>
<span class="c">/*</span>
<span class="c"> * Executed when the loader fails to complete an insert operation.</span>
<span class="c"> * This can be subscribed to normally, or a listener can be passed</span>
<span class="c"> * as an onFailure config option.</span>
<span class="c"> *</span>
<span class="c"> * @event failure</span>
<span class="c"> */</span>
<span class="c">/*</span>
<span class="c"> * Executed when a Get operation times out.</span>
<span class="c"> * This can be subscribed to normally, or a listener can be passed</span>
<span class="c"> * as an onTimeout config option.</span>
<span class="c"> *</span>
<span class="c"> * @event timeout</span>
<span class="c"> */</span>
<span class="c">// http://yui.yahooapis.com/combo?2.5.2/build/yahoo/yahoo-min.js&amp;2.5.2/build/dom/dom-min.js&amp;2.5.2/build/event/event-min.js&amp;2.5.2/build/autocomplete/autocomplete-min.js&quot;</span>
<span class="c"></span>
<span class="nx">YUI</span><span class="o">.</span><span class="nx">add</span><span class="o">(</span><span class="s2">&quot;loader&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">BASE</span> <span class="o">=</span> <span class="s1">&#39;base&#39;</span><span class="o">,</span>
<span class="nx">CSS</span> <span class="o">=</span> <span class="s1">&#39;css&#39;</span><span class="o">,</span>
<span class="nx">JS</span> <span class="o">=</span> <span class="s1">&#39;js&#39;</span><span class="o">,</span>
<span class="nx">RESET</span> <span class="o">=</span> <span class="s1">&#39;cssreset&#39;</span><span class="o">,</span>
<span class="nx">FONTS</span> <span class="o">=</span> <span class="s1">&#39;cssfonts&#39;</span><span class="o">,</span>
<span class="nx">GRIDS</span> <span class="o">=</span> <span class="s1">&#39;cssgrids&#39;</span><span class="o">,</span>
<span class="nx">VERSION</span> <span class="o">=</span> <span class="s1">&#39;@VERSION@&#39;</span><span class="o">,</span>
<span class="nx">ROOT</span> <span class="o">=</span> <span class="nx">VERSION</span> <span class="o">+</span> <span class="s1">&#39;/build/&#39;</span><span class="o">;</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">Env</span><span class="o">.</span><span class="nx">meta</span> <span class="o">=</span> <span class="o">{</span>
<span class="nx">version</span><span class="o">:</span> <span class="nx">VERSION</span><span class="o">,</span>
<span class="nx">root</span><span class="o">:</span> <span class="nx">ROOT</span><span class="o">,</span>
<span class="nx">base</span><span class="o">:</span> <span class="s1">&#39;http://yui.yahooapis.com/&#39;</span> <span class="o">+</span> <span class="nx">ROOT</span><span class="o">,</span>
<span class="c">// base: &#39;/build/&#39;,</span>
<span class="c"></span>
<span class="nx">comboBase</span><span class="o">:</span> <span class="s1">&#39;http://yui.yahooapis.com/combo?&#39;</span><span class="o">,</span>
<span class="nx">modules</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">dom</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;event&#39;</span><span class="o">],</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dom-base&#39;</span><span class="o">,</span> <span class="s1">&#39;dom-style&#39;</span><span class="o">,</span> <span class="s1">&#39;dom-screen&#39;</span><span class="o">,</span> <span class="s1">&#39;selector&#39;</span><span class="o">],</span>
<span class="nx">rollup</span><span class="o">:</span> <span class="m">3</span>
<span class="o">},</span>
<span class="s1">&#39;dom-base&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dom/dom-base-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;event&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dom-style&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dom/dom-style-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dom-base&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dom-screen&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dom/dom-screen-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dom-base&#39;</span><span class="o">,</span> <span class="s1">&#39;dom-style&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">selector</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dom/selector-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dom-base&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">node</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;node-base&#39;</span><span class="o">,</span> <span class="s1">&#39;node-style&#39;</span><span class="o">,</span> <span class="s1">&#39;node-screen&#39;</span><span class="o">],</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dom&#39;</span><span class="o">],</span>
<span class="nx">rollup</span><span class="o">:</span> <span class="m">2</span>
<span class="o">},</span>
<span class="s1">&#39;node-base&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;node/node-base-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dom-base&#39;</span><span class="o">,</span> <span class="s1">&#39;selector&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;node-style&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;node/node-style-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dom-style&#39;</span><span class="o">,</span> <span class="s1">&#39;node-base&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;node-screen&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;node/node-screen-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dom-screen&#39;</span><span class="o">,</span> <span class="s1">&#39;node-base&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">anim</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;anim-base&#39;</span><span class="o">,</span> <span class="s1">&#39;anim-color&#39;</span><span class="o">,</span> <span class="s1">&#39;anim-curve&#39;</span><span class="o">,</span> <span class="s1">&#39;anim-easing&#39;</span><span class="o">,</span> <span class="s1">&#39;anim-scroll&#39;</span><span class="o">,</span> <span class="s1">&#39;anim-xy&#39;</span><span class="o">],</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;base&#39;</span><span class="o">,</span> <span class="s1">&#39;node&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;anim-base&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;anim/anim-base-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;base&#39;</span><span class="o">,</span> <span class="s1">&#39;node-style&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;anim-color&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;anim/anim-color-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;anim-base&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;anim-curve&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;anim/anim-curve-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;anim-xy&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;anim-easing&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;anim/anim-easing-min.js&#39;</span>
<span class="o">},</span>
<span class="s1">&#39;anim-scroll&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;anim/anim-scroll-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;anim-base&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;anim-xy&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;anim/anim-xy-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;anim-base&#39;</span><span class="o">,</span> <span class="s1">&#39;node-screen&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">attribute</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;event&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">base</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;attribute&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">compat</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;node&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">cookie</span><span class="o">:</span> <span class="o">{</span> <span class="o">},</span>
<span class="nx">cssbase</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">type</span><span class="o">:</span> <span class="nx">CSS</span><span class="o">,</span>
<span class="nx">after</span><span class="o">:</span> <span class="o">[</span><span class="nx">RESET</span><span class="o">,</span> <span class="nx">FONTS</span><span class="o">,</span> <span class="nx">GRIDS</span><span class="o">],</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;cssbase/base.css&#39;</span>
<span class="o">},</span>
<span class="nx">cssfonts</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">type</span><span class="o">:</span> <span class="nx">CSS</span><span class="o">,</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;cssfonts/fonts.css&#39;</span>
<span class="o">},</span>
<span class="nx">cssgrids</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">type</span><span class="o">:</span> <span class="nx">CSS</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="nx">FONTS</span><span class="o">],</span>
<span class="nx">optional</span><span class="o">:</span> <span class="o">[</span><span class="nx">RESET</span><span class="o">],</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;cssgrids/grids.css&#39;</span>
<span class="o">},</span>
<span class="nx">cssreset</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">type</span><span class="o">:</span> <span class="nx">CSS</span><span class="o">,</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;cssreset/reset.css&#39;</span>
<span class="o">},</span>
<span class="s1">&#39;dd-ddm-base&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-ddm-base-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;node&#39;</span><span class="o">,</span> <span class="nx">BASE</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dd-ddm&#39;</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-ddm-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-ddm-base&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dd-ddm-drop&#39;</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-ddm-drop-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-ddm&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dd-drag&#39;</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-drag-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-ddm-base&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dd-drop&#39;</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-drop-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-ddm-drop&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dd-proxy&#39;</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-proxy-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-drag&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dd-constrain&#39;</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-constrain-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-drag&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-proxy&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dd-plugin&#39;</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-plugin-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-drag&#39;</span><span class="o">],</span>
<span class="nx">optional</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-constrain&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-proxy&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dd-drop-plugin&#39;</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-drop-plugin-min.js&#39;</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-drop&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;dd&#39;</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;dd/dd-min.js&#39;</span><span class="o">,</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dd-ddm-base&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-ddm&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-ddm-drop&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-drag&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-proxy&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-constrain&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-plugin&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-drop&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-drop-plugin&#39;</span><span class="o">,</span> <span class="s1">&#39;dd-drag-proxy&#39;</span><span class="o">],</span>
<span class="nx">rollup</span><span class="o">:</span> <span class="m">5</span>
<span class="o">},</span>
<span class="nx">dump</span><span class="o">:</span> <span class="o">{</span> <span class="o">},</span>
<span class="nx">event</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;oop&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">io</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;node&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;json-parse&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;json/json-parse-min.js&#39;</span>
<span class="o">},</span>
<span class="s1">&#39;json-stringify&#39;</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">&#39;json/json-stringify-min.js&#39;</span>
<span class="o">},</span>
<span class="nx">json</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;json-parse&#39;</span><span class="o">,</span> <span class="s1">&#39;json-stringify&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">oop</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;yui-base&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">queue</span><span class="o">:</span> <span class="o">{</span> <span class="o">},</span>
<span class="nx">substitute</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">optional</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;dump&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="c">// Since YUI is required for everything else, it should not be specified as</span>
<span class="c"></span> <span class="c">// a dependency.</span>
<span class="c"></span> <span class="nx">yui</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;yui-base&#39;</span><span class="o">,</span> <span class="s1">&#39;get&#39;</span><span class="o">,</span> <span class="s1">&#39;loader&#39;</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">&#39;yui-base&#39;</span><span class="o">:</span> <span class="o">{</span> <span class="o">}</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="k">var</span> <span class="nx">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="nx">env</span><span class="o">=</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Env</span><span class="o">,</span>
<span class="nx">PROV</span> <span class="o">=</span> <span class="s2">&quot;_provides&quot;</span><span class="o">,</span> <span class="nx">SUPER</span> <span class="o">=</span> <span class="s2">&quot;_supersedes&quot;</span><span class="o">,</span>
<span class="nx">REQ</span> <span class="o">=</span> <span class="s2">&quot;expanded&quot;</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">_Y</span> <span class="o">=</span> <span class="o">{</span>
<span class="c">// dupsAllowed: {&#39;yahoo&#39;: true, &#39;get&#39;: true},</span>
<span class="c"></span> <span class="nx">dupsAllowed</span><span class="o">:</span> <span class="o">{},</span>
<span class="c">/*</span>
<span class="c"> * The library metadata for the current release</span>
<span class="c"> * @property YUIInfo</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="c">// info: &#39;@yuiinfo@&#39;, </span>
<span class="c"></span> <span class="nx">info</span><span class="o">:</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Env</span><span class="o">.</span><span class="nx">meta</span>
<span class="o">};</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">Loader</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="c">/**</span>
<span class="c"> * Internal callback to handle multiple internal insert() calls</span>
<span class="c"> * so that css is inserted prior to js</span>
<span class="c"> * @property _internalCallback</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_internalCallback</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Use the YUI environment listener to detect script load. This</span>
<span class="c"> * is only switched on for Safari 2.x and below.</span>
<span class="c"> * @property _useYahooListener</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_useYahooListener</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Callback that will be executed when the loader is finished</span>
<span class="c"> * with an insert</span>
<span class="c"> * @method onSuccess</span>
<span class="c"> * @type function</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">onSuccess</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Callback that will be executed if there is a failure</span>
<span class="c"> * @method onFailure</span>
<span class="c"> * @type function</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">onFailure</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="c">/**</span>
<span class="c"> * Callback executed each time a script or css file is loaded</span>
<span class="c"> * @method onProgress</span>
<span class="c"> * @type function</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">onProgress</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Callback that will be executed if a timeout occurs</span>
<span class="c"> * @method onTimeout</span>
<span class="c"> * @type function</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">onTimeout</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * The execution context for all callbacks</span>
<span class="c"> * @property context</span>
<span class="c"> * @default {YUI} the YUI instance</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">context</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Data that is passed to all callbacks</span>
<span class="c"> * @property data</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">data</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Node reference or id where new nodes should be inserted before</span>
<span class="c"> * @property insertBefore</span>
<span class="c"> * @type string|HTMLElement</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">insertBefore</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * The charset attribute for inserted nodes</span>
<span class="c"> * @property charset</span>
<span class="c"> * @type string</span>
<span class="c"> * @default utf-8</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">charset</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * The base directory.</span>
<span class="c"> * @property base</span>
<span class="c"> * @type string</span>
<span class="c"> * @default http://yui.yahooapis.com/[YUI VERSION]/build/</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">base</span> <span class="o">=</span> <span class="nx">_Y</span><span class="o">.</span><span class="nx">info</span><span class="o">.</span><span class="nx">base</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Base path for the combo service</span>
<span class="c"> * @property comboBase</span>
<span class="c"> * @type string</span>
<span class="c"> * @default http://yui.yahooapis.com/combo?</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">comboBase</span> <span class="o">=</span> <span class="nx">_Y</span><span class="o">.</span><span class="nx">info</span><span class="o">.</span><span class="nx">comboBase</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * If configured, YUI JS resources will use the combo</span>
<span class="c"> * handler</span>
<span class="c"> * @property combine</span>
<span class="c"> * @type boolean</span>
<span class="c"> * @default false</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">combine</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Ignore modules registered on the YUI global</span>
<span class="c"> * @property ignoreRegistered</span>
<span class="c"> * @default false</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">ignoreRegistered</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Root path to prepend to module path for the combo</span>
<span class="c"> * service</span>
<span class="c"> * @property root</span>
<span class="c"> * @type string</span>
<span class="c"> * @default [YUI VERSION]/build/</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">root</span> <span class="o">=</span> <span class="nx">_Y</span><span class="o">.</span><span class="nx">info</span><span class="o">.</span><span class="nx">root</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Timeout value in milliseconds. If set, this value will be used by</span>
<span class="c"> * the get utility. the timeout event will fire if</span>
<span class="c"> * a timeout occurs.</span>
<span class="c"> * @property timeout</span>
<span class="c"> * @type int</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">timeout</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * A list of modules that should not be loaded, even if</span>
<span class="c"> * they turn up in the dependency tree</span>
<span class="c"> * @property ignore</span>
<span class="c"> * @type string[]</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">ignore</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * A list of modules that should always be loaded, even</span>
<span class="c"> * if they have already been inserted into the page.</span>
<span class="c"> * @property force</span>
<span class="c"> * @type string[]</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">force</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Should we allow rollups</span>
<span class="c"> * @property allowRollup</span>
<span class="c"> * @type boolean</span>
<span class="c"> * @default true</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">allowRollup</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * A filter to apply to result urls. This filter will modify the default</span>
<span class="c"> * path for all modules. The default path for the YUI library is the</span>
<span class="c"> * minified version of the files (e.g., event-min.js). The filter property</span>
<span class="c"> * can be a predefined filter or a custom filter. The valid predefined </span>
<span class="c"> * filters are:</span>
<span class="c"> * &lt;dl&gt;</span>
<span class="c"> * &lt;dt&gt;DEBUG&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;Selects the debug versions of the library (e.g., event-debug.js).</span>
<span class="c"> * This option will automatically include the logger widget&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;RAW&lt;/dt&gt;</span>
<span class="c"> * &lt;dd&gt;Selects the non-minified version of the library (e.g., event.js).&lt;/dd&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> * You can also define a custom filter, which must be an object literal </span>
<span class="c"> * containing a search expression and a replace string:</span>
<span class="c"> * &lt;pre&gt;</span>
<span class="c"> * myFilter: &amp;#123; </span>
<span class="c"> * &#39;searchExp&#39;: &quot;-min\\.js&quot;, </span>
<span class="c"> * &#39;replaceStr&#39;: &quot;-debug.js&quot;</span>
<span class="c"> * &amp;#125;</span>
<span class="c"> * &lt;/pre&gt;</span>
<span class="c"> * @property filter</span>
<span class="c"> * @type string|{searchExp: string, replaceStr: string}</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">filter</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * The list of requested modules</span>
<span class="c"> * @property required</span>
<span class="c"> * @type {string: boolean}</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">required</span> <span class="o">=</span> <span class="o">{};</span>
<span class="c">/**</span>
<span class="c"> * The library metadata</span>
<span class="c"> * @property moduleInfo</span>
<span class="c"> */</span>
<span class="c">// this.moduleInfo = Y.merge(_Y.info.moduleInfo);</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">moduleInfo</span> <span class="o">=</span> <span class="o">{};</span>
<span class="k">var</span> <span class="nx">defaults</span> <span class="o">=</span> <span class="nx">_Y</span><span class="o">.</span><span class="nx">info</span><span class="o">.</span><span class="nx">modules</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">defaults</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">defaults</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">this</span><span class="o">.</span><span class="nx">_internal</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">this</span><span class="o">.</span><span class="nx">addModule</span><span class="o">(</span><span class="nx">defaults</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="k">this</span><span class="o">.</span><span class="nx">_internal</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">/**</span>
<span class="c"> * List of rollup files found in the library metadata</span>
<span class="c"> * @property rollups</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">rollups</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Whether or not to load optional dependencies for </span>
<span class="c"> * the requested modules</span>
<span class="c"> * @property loadOptional</span>
<span class="c"> * @type boolean</span>
<span class="c"> * @default false</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">loadOptional</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * All of the derived dependencies in sorted order, which</span>
<span class="c"> * will be populated when either calculate() or insert()</span>
<span class="c"> * is called</span>
<span class="c"> * @property sorted</span>
<span class="c"> * @type string[]</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">sorted</span> <span class="o">=</span> <span class="o">[];</span>
<span class="c">/**</span>
<span class="c"> * Set when beginning to compute the dependency tree. </span>
<span class="c"> * Composed of what YUI reports to be loaded combined</span>
<span class="c"> * with what has been loaded by the tool</span>
<span class="c"> * @propery loaded</span>
<span class="c"> * @type {string: boolean}</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">loaded</span> <span class="o">=</span> <span class="o">{};</span>
<span class="c">/**</span>
<span class="c"> * A list of modules to attach to the YUI instance when complete.</span>
<span class="c"> * If not supplied, the sorted list of dependencies are applied.</span>
<span class="c"> * @property attaching</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">attaching</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Flag to indicate the dependency tree needs to be recomputed</span>
<span class="c"> * if insert is called again.</span>
<span class="c"> * @property dirty</span>
<span class="c"> * @type boolean</span>
<span class="c"> * @default true</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">dirty</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * List of modules inserted by the utility</span>
<span class="c"> * @property inserted</span>
<span class="c"> * @type {string: boolean}</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">inserted</span> <span class="o">=</span> <span class="o">{};</span>
<span class="k">this</span><span class="o">.</span><span class="nx">skipped</span> <span class="o">=</span> <span class="o">{};</span>
<span class="c">// Y.on(&#39;yui:load&#39;, this.loadNext, this);</span>
<span class="c"></span>
<span class="k">this</span><span class="o">.</span><span class="nx">_config</span><span class="o">(</span><span class="nx">o</span><span class="o">);</span>
<span class="o">};</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">Loader</span><span class="o">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="o">{</span>
<span class="nx">FILTERS</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">RAW</span><span class="o">:</span> <span class="o">{</span>
<span class="s1">&#39;searchExp&#39;</span><span class="o">:</span> <span class="s2">&quot;-min\\.js&quot;</span><span class="o">,</span>
<span class="s1">&#39;replaceStr&#39;</span><span class="o">:</span> <span class="s2">&quot;.js&quot;</span>
<span class="o">},</span>
<span class="nx">DEBUG</span><span class="o">:</span> <span class="o">{</span>
<span class="s1">&#39;searchExp&#39;</span><span class="o">:</span> <span class="s2">&quot;-min\\.js&quot;</span><span class="o">,</span>
<span class="s1">&#39;replaceStr&#39;</span><span class="o">:</span> <span class="s2">&quot;-debug.js&quot;</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="nx">_config</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="c">// apply config values</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">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="k">in</span> <span class="nx">o</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">val</span> <span class="o">=</span> <span class="nx">o</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">o</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">if</span> <span class="o">(</span><span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;require&#39;</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">require</span><span class="o">(</span><span class="nx">val</span><span class="o">);</span>
<span class="c">// support the old callback syntax</span>
<span class="c"></span> <span class="c">// } else if (i.indexOf(&#39;on&#39;) === 0) {</span>
<span class="c"></span> <span class="c">// this.subscribe(i.substr(2).toLowerCase(), o[i], o.context || this);</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">i</span> <span class="o">==</span> <span class="s1">&#39;modules&#39;</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// add a hash of module definitions</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">j</span> <span class="k">in</span> <span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">addModule</span><span class="o">(</span><span class="nx">val</span><span class="o">[</span><span class="nx">j</span><span class="o">],</span> <span class="nx">j</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="k">this</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">=</span> <span class="nx">val</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// fix filter</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">filter</span><span class="o">;</span>
<span class="k">if</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">f</span><span class="o">))</span> <span class="o">{</span>
<span class="nx">f</span> <span class="o">=</span> <span class="nx">f</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>
<span class="c">// the logger must be available in order to use the debug</span>
<span class="c"></span> <span class="c">// versions of the library</span>
<span class="c"></span> <span class="c">// @TODO review when logreader is available</span>
<span class="c"></span> <span class="c">// if (f === &quot;DEBUG&quot;) {</span>
<span class="c"></span> <span class="c">// this.require(&quot;log&quot;);</span>
<span class="c"></span> <span class="c">// }</span>
<span class="c"></span>
<span class="k">this</span><span class="o">.</span><span class="nx">filter</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">FILTERS</span><span class="o">[</span><span class="nx">f</span><span class="o">];</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/** Add a new module to the component metadata. </span>
<span class="c"> * &lt;dl&gt;</span>
<span class="c"> * &lt;dt&gt;name:&lt;/dt&gt; &lt;dd&gt;required, the component name&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;type:&lt;/dt&gt; &lt;dd&gt;required, the component type (js or css)&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;path:&lt;/dt&gt; &lt;dd&gt;required, the path to the script from &quot;base&quot;&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;requires:&lt;/dt&gt; &lt;dd&gt;array of modules required by this component&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;optional:&lt;/dt&gt; &lt;dd&gt;array of optional modules for this component&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;supersedes:&lt;/dt&gt; &lt;dd&gt;array of the modules this component replaces&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;after:&lt;/dt&gt; &lt;dd&gt;array of modules the components which, if present, should be sorted above this one&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;rollup:&lt;/dt&gt; &lt;dd&gt;the number of superseded modules required for automatic rollup&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;fullpath:&lt;/dt&gt; &lt;dd&gt;If fullpath is specified, this is used instead of the configured base + path&lt;/dd&gt;</span>
<span class="c"> * &lt;dt&gt;skinnable:&lt;/dt&gt; &lt;dd&gt;flag to determine if skin assets should automatically be pulled in&lt;/dd&gt;</span>
<span class="c"> * &lt;/dl&gt;</span>
<span class="c"> * @method addModule</span>
<span class="c"> * @param o An object containing the module data</span>
<span class="c"> * @param name the module name (optional), required if not in the module data</span>
<span class="c"> * @return {boolean} true if the module was added, false if </span>
<span class="c"> * the object passed in did not provide all required attributes</span>
<span class="c"> */</span>
<span class="nx">addModule</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="nx">name</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">name</span> <span class="o">||</span> <span class="nx">name</span><span class="o">;</span>
<span class="k">if</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">name</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">o</span><span class="o">.</span><span class="nx">type</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">type</span> <span class="o">=</span> <span class="nx">JS</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">o</span><span class="o">.</span><span class="nx">path</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">o</span><span class="o">.</span><span class="nx">fullpath</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">path</span> <span class="o">=</span> <span class="nx">name</span> <span class="o">+</span> <span class="s2">&quot;/&quot;</span> <span class="o">+</span> <span class="nx">name</span> <span class="o">+</span> <span class="s2">&quot;-min.&quot;</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">type</span><span class="o">;</span>
<span class="o">}</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">ext</span> <span class="o">=</span> <span class="o">(</span><span class="s1">&#39;ext&#39;</span> <span class="k">in</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">ext</span> <span class="o">:</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_internal</span><span class="o">)</span> <span class="o">?</span> <span class="kc">false</span> <span class="o">:</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">requires</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">requires</span> <span class="o">||</span> <span class="o">[];</span>
<span class="k">this</span><span class="o">.</span><span class="nx">moduleInfo</span><span class="o">[</span><span class="nx">name</span><span class="o">]</span> <span class="o">=</span> <span class="nx">o</span><span class="o">;</span>
<span class="k">this</span><span class="o">.</span><span class="nx">dirty</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="c">//Y.log(&#39;New module &#39; + name);</span>
<span class="c"></span>
<span class="k">return</span> <span class="nx">o</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Add a requirement for one or more module</span>
<span class="c"> * @method require</span>
<span class="c"> * @param what {string[] | string*} the modules to load</span>
<span class="c"> */</span>
<span class="nx">require</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">what</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">what</span> <span class="o">===</span> <span class="s2">&quot;string&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">arguments</span> <span class="o">:</span> <span class="nx">what</span><span class="o">;</span>
<span class="k">this</span><span class="o">.</span><span class="nx">dirty</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">required</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">.</span><span class="nx">hash</span><span class="o">(</span><span class="nx">a</span><span class="o">));</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Returns an object containing properties for all modules required</span>
<span class="c"> * in order to load the requested module</span>
<span class="c"> * @method getRequires</span>
<span class="c"> * @param mod The module definition from moduleInfo</span>
<span class="c"> */</span>
<span class="nx">getRequires</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">mod</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">mod</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;getRequires, no module&#39;);</span>
<span class="c"></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="k">this</span><span class="o">.</span><span class="nx">dirty</span> <span class="o">&amp;&amp;</span> <span class="nx">mod</span><span class="o">.</span><span class="nx">expanded</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;already expanded&#39;);</span>
<span class="c"></span> <span class="k">return</span> <span class="nx">mod</span><span class="o">.</span><span class="nx">expanded</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">var</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">d</span><span class="o">=[],</span> <span class="nx">r</span><span class="o">=</span><span class="nx">mod</span><span class="o">.</span><span class="nx">requires</span><span class="o">,</span> <span class="nx">o</span><span class="o">=</span><span class="nx">mod</span><span class="o">.</span><span class="nx">optional</span><span class="o">,</span>
<span class="nx">info</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">moduleInfo</span><span class="o">,</span> <span class="nx">m</span><span class="o">,</span> <span class="nx">j</span><span class="o">,</span> <span class="nx">add</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">r</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">=</span><span class="nx">i</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(mod.name + &#39; requiring &#39; + r[i]);</span>
<span class="c"></span> <span class="nx">d</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">r</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
<span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getModule</span><span class="o">(</span><span class="nx">r</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
<span class="nx">add</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRequires</span><span class="o">(</span><span class="nx">m</span><span class="o">);</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span><span class="nx">j</span><span class="o">&lt;</span><span class="nx">add</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span><span class="nx">j</span><span class="o">=</span><span class="nx">j</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">d</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">add</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// get the requirements from superseded modules, if any</span>
<span class="c"></span> <span class="nx">r</span><span class="o">=</span><span class="nx">mod</span><span class="o">.</span><span class="nx">supersedes</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">r</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">r</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">=</span><span class="nx">i</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(mod.name + &#39; requiring &#39; + r[i]);</span>
<span class="c"></span> <span class="nx">d</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">r</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
<span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getModule</span><span class="o">(</span><span class="nx">r</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
<span class="nx">add</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRequires</span><span class="o">(</span><span class="nx">m</span><span class="o">);</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span><span class="nx">j</span><span class="o">&lt;</span><span class="nx">add</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span><span class="nx">j</span><span class="o">=</span><span class="nx">j</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">d</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">add</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">o</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">loadOptional</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">o</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">=</span><span class="nx">i</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">d</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">o</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
<span class="nx">add</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRequires</span><span class="o">(</span><span class="nx">info</span><span class="o">[</span><span class="nx">o</span><span class="o">[</span><span class="nx">i</span><span class="o">]]);</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span><span class="nx">j</span><span class="o">&lt;</span><span class="nx">add</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span><span class="nx">j</span><span class="o">=</span><span class="nx">j</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">d</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">add</span><span class="o">[</span><span class="nx">j</span><span class="o">]);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="nx">mod</span><span class="o">.</span><span class="nx">expanded</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Object</span><span class="o">.</span><span class="nx">keys</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">.</span><span class="nx">hash</span><span class="o">(</span><span class="nx">d</span><span class="o">));</span>
<span class="c">// Y.log(mod.expanded);</span>
<span class="c"></span>
<span class="k">return</span> <span class="nx">mod</span><span class="o">.</span><span class="nx">expanded</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Returns an object literal of the modules the supplied module satisfies</span>
<span class="c"> * @method getProvides</span>
<span class="c"> * @param name{string} The name of the module</span>
<span class="c"> * @param notMe {string} don&#39;t add this module name, only include superseded modules</span>
<span class="c"> * @return what this module provides</span>
<span class="c"> */</span>
<span class="nx">getProvides</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">name</span><span class="o">,</span> <span class="nx">notMe</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">addMe</span> <span class="o">=</span> <span class="o">!(</span><span class="nx">notMe</span><span class="o">),</span> <span class="nx">ckey</span> <span class="o">=</span> <span class="o">(</span><span class="nx">addMe</span><span class="o">)</span> <span class="o">?</span> <span class="nx">PROV</span> <span class="o">:</span> <span class="nx">SUPER</span><span class="o">,</span>
<span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getModule</span><span class="o">(</span><span class="nx">name</span><span class="o">),</span> <span class="nx">o</span> <span class="o">=</span> <span class="o">{};</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">m</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="nx">o</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">m</span><span class="o">[</span><span class="nx">ckey</span><span class="o">])</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;cached: &#39; + name + &#39; &#39; + ckey + &#39; &#39; + L.dump(this.moduleInfo[name][ckey], 0));</span>
<span class="c"></span> <span class="k">return</span> <span class="nx">m</span><span class="o">[</span><span class="nx">ckey</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">m</span><span class="o">.</span><span class="nx">supersedes</span><span class="o">,</span> <span class="nx">done</span><span class="o">={},</span> <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
<span class="c">// use worker to break cycles</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">add</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">mm</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">done</span><span class="o">[</span><span class="nx">mm</span><span class="o">])</span> <span class="o">{</span>
<span class="c">// Y.log(name + &#39; provides worker trying: &#39; + mm);</span>
<span class="c"></span> <span class="nx">done</span><span class="o">[</span><span class="nx">mm</span><span class="o">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="c">// we always want the return value normal behavior </span>
<span class="c"></span> <span class="c">// (provides) for superseded modules.</span>
<span class="c"></span> <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">me</span><span class="o">.</span><span class="nx">getProvides</span><span class="o">(</span><span class="nx">mm</span><span class="o">));</span>
<span class="o">}</span>
<span class="c">// else {</span>
<span class="c"></span> <span class="c">// Y.log(name + &#39; provides worker skipping done: &#39; + mm);</span>
<span class="c"></span> <span class="c">// }</span>
<span class="c"></span> <span class="o">};</span>
<span class="c">// calculate superseded modules</span>
<span class="c"></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="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">s</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">=</span><span class="nx">i</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">add</span><span class="o">(</span><span class="nx">s</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// supersedes cache</span>
<span class="c"></span> <span class="nx">m</span><span class="o">[</span><span class="nx">SUPER</span><span class="o">]</span> <span class="o">=</span> <span class="nx">o</span><span class="o">;</span>
<span class="c">// provides cache</span>
<span class="c"></span> <span class="nx">m</span><span class="o">[</span><span class="nx">PROV</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">o</span><span class="o">);</span>
<span class="nx">m</span><span class="o">[</span><span class="nx">PROV</span><span class="o">][</span><span class="nx">name</span><span class="o">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="c">// Y.log(name + &quot; supersedes &quot; + L.dump(m[SUPER], 0));</span>
<span class="c">// Y.log(name + &quot; provides &quot; + L.dump(m[PROV], 0));</span>
<span class="c"></span>
<span class="k">return</span> <span class="nx">m</span><span class="o">[</span><span class="nx">ckey</span><span class="o">];</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Calculates the dependency tree, the result is stored in the sorted </span>
<span class="c"> * property</span>
<span class="c"> * @method calculate</span>
<span class="c"> * @param o optional options object</span>
<span class="c"> */</span>
<span class="nx">calculate</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">if</span> <span class="o">(</span><span class="nx">o</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">dirty</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_config</span><span class="o">(</span><span class="nx">o</span><span class="o">);</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_setup</span><span class="o">();</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_explode</span><span class="o">();</span>
<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">allowRollup</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_rollup</span><span class="o">();</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_reduce</span><span class="o">();</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_sort</span><span class="o">();</span>
<span class="c">// Y.log(&quot;after calculate: &quot; + this.sorted);</span>
<span class="c"></span>
<span class="k">this</span><span class="o">.</span><span class="nx">dirty</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Investigates the current YUI configuration on the page. By default,</span>
<span class="c"> * modules already detected will not be loaded again unless a force</span>
<span class="c"> * option is encountered. Called by calculate()</span>
<span class="c"> * @method _setup</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_setup</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">info</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">moduleInfo</span><span class="o">,</span> <span class="nx">name</span><span class="o">,</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">j</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">l</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="k">this</span><span class="o">.</span><span class="nx">inserted</span><span class="o">);</span> <span class="c">// shallow clone</span>
<span class="c"></span>
<span class="c">// available modules</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">ignoreRegistered</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">l</span><span class="o">,</span> <span class="nx">YUI</span><span class="o">.</span><span class="nx">Env</span><span class="o">.</span><span class="nx">mods</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">// Y.log(&quot;Already loaded stuff: &quot; + L.dump(l, 0));</span>
<span class="c"></span>
<span class="c">// add the ignore list to the list of loaded packages</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">ignore</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// OU.appendArray(l, this.ignore);</span>
<span class="c"></span> <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</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="nb">Array</span><span class="o">.</span><span class="nx">hash</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">ignore</span><span class="o">));</span>
<span class="o">}</span>
<span class="c">// expand the list to include superseded modules</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="nx">j</span> <span class="k">in</span> <span class="nx">l</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&quot;expanding: &quot; + j);</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">l</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="nx">j</span><span class="o">))</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">l</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">getProvides</span><span class="o">(</span><span class="nx">j</span><span class="o">));</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// remove modules on the force list from the loaded list</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">force</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="k">this</span><span class="o">.</span><span class="nx">force</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">=</span><span class="nx">i</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">force</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="k">in</span> <span class="nx">l</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">delete</span> <span class="nx">l</span><span class="o">[</span><span class="k">this</span><span class="o">.</span><span class="nx">force</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="c">// Y.log(&quot;loaded expanded: &quot; + L.dump(l, 0));</span>
<span class="c"></span>
<span class="k">this</span><span class="o">.</span><span class="nx">loaded</span> <span class="o">=</span> <span class="nx">l</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Inspects the required modules list looking for additional </span>
<span class="c"> * dependencies. Expands the required list to include all </span>
<span class="c"> * required modules. Called by calculate()</span>
<span class="c"> * @method _explode</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_explode</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">r</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">required</span><span class="o">,</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">mod</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">r</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">r</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="nx">mod</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getModule</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
<span class="c">// Y.log(&#39;exploding &#39; + i);</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">req</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getRequires</span><span class="o">(</span><span class="nx">mod</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">req</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;via explode: &#39; + req);</span>
<span class="c"></span> <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">r</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">.</span><span class="nx">hash</span><span class="o">(</span><span class="nx">req</span><span class="o">));</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="nx">getModule</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">name</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">moduleInfo</span><span class="o">[</span><span class="nx">name</span><span class="o">];</span>
<span class="c">// create the default module</span>
<span class="c"></span> <span class="c">// if (!m) {</span>
<span class="c"></span> <span class="c">// Y.log(&#39;Module does not exist: &#39; + name + &#39;, creating with defaults&#39;);</span>
<span class="c"></span> <span class="c">// m = this.addModule({ext: false}, name);</span>
<span class="c"></span> <span class="c">// }</span>
<span class="c"></span>
<span class="k">return</span> <span class="nx">m</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Look for rollup packages to determine if all of the modules a</span>
<span class="c"> * rollup supersedes are required. If so, include the rollup to</span>
<span class="c"> * help reduce the total number of connections required. Called</span>
<span class="c"> * by calculate()</span>
<span class="c"> * @method _rollup</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_rollup</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">i</span><span class="o">,</span> <span class="nx">j</span><span class="o">,</span> <span class="nx">m</span><span class="o">,</span> <span class="nx">s</span><span class="o">,</span> <span class="nx">rollups</span><span class="o">={},</span> <span class="nx">r</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">required</span><span class="o">,</span> <span class="nx">roll</span><span class="o">,</span>
<span class="nx">info</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">moduleInfo</span><span class="o">;</span>
<span class="c">// find and cache rollup modules</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">dirty</span> <span class="o">||</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">rollups</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">info</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">info</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="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getModule</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
<span class="c">// if (m &amp;&amp; m.rollup &amp;&amp; m.supersedes) {</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">m</span> <span class="o">&amp;&amp;</span> <span class="nx">m</span><span class="o">.</span><span class="nx">rollup</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">rollups</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">=</span> <span class="nx">m</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">rollups</span> <span class="o">=</span> <span class="nx">rollups</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// make as many passes as needed to pick up rollup rollups</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(;;)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">rolled</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="c">// go through the rollup candidates</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">rollups</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// there can be only one</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="nx">r</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">loaded</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">{</span>
<span class="nx">m</span> <span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">getModule</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span> <span class="nx">s</span> <span class="o">=</span> <span class="nx">m</span><span class="o">.</span><span class="nx">supersedes</span> <span class="o">||[];</span> <span class="nx">roll</span><span class="o">=</span><span class="kc">false</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(!</span><span class="nx">m</span><span class="o">.</span><span class="nx">rollup</span><span class="o">)</span> <span class="o">{</span>
<span class="k">continue</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="m">0</span><span class="o">;</span>
<span class="c">// check the threshold</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span><span class="nx">j</span><span class="o">&lt;</span><span class="nx">s</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span><span class="nx">j</span><span class="o">=</span><span class="nx">j</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// if the superseded module is loaded, we can&#39;t load the rollup</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">loaded</span><span class="o">[</span><span class="nx">s</span><span class="o">[</span><span class="nx">j</span><span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="o">(!</span><span class="nx">_Y</span><span class="o">.</span><span class="nx">dupsAllowed</span><span class="o">[</span><span class="nx">s</span><span class="o">[</span><span class="nx">j</span><span class="o">]]))</span> <span class="o">{</span>
<span class="nx">roll</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="k">break</span><span class="o">;</span>
<span class="c">// increment the counter if this module is required. if we are</span>
<span class="c"></span> <span class="c">// beyond the rollup threshold, we will use the rollup module</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">r</span><span class="o">[</span><span class="nx">s</span><span class="o">[</span><span class="nx">j</span><span class="o">]])</span> <span class="o">{</span>
<span class="nx">c</span><span class="o">++;</span>
<span class="nx">roll</span> <span class="o">=</span> <span class="o">(</span><span class="nx">c</span> <span class="o">&gt;=</span> <span class="nx">m</span><span class="o">.</span><span class="nx">rollup</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">roll</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&quot;over thresh &quot; + c + &quot;, &quot; + L.dump(r));</span>
<span class="c"></span> <span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">roll</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&quot;rollup: &quot; + i + &quot;, &quot; + L.dump(this, 1));</span>
<span class="c"></span> <span class="c">// add the rollup</span>
<span class="c"></span> <span class="nx">r</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">rolled</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="c">// expand the rollup&#39;s dependencies</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">getRequires</span><span class="o">(</span><span class="nx">m</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// if we made it here w/o rolling up something, we are done</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="nx">rolled</span><span class="o">)</span> <span class="o">{</span>
<span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Remove superceded modules and loaded modules. Called by</span>
<span class="c"> * calculate() after we have the mega list of all dependencies</span>
<span class="c"> * @method _reduce</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_reduce</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">i</span><span class="o">,</span> <span class="nx">j</span><span class="o">,</span> <span class="nx">s</span><span class="o">,</span> <span class="nx">m</span><span class="o">,</span> <span class="nx">r</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">required</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">r</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// remove if already loaded</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">i</span> <span class="k">in</span> <span class="k">this</span><span class="o">.</span><span class="nx">loaded</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">delete</span> <span class="nx">r</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="c">// remove anything this module supersedes</span>
<span class="c"></span> <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getModule</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
<span class="nx">s</span> <span class="o">=</span> <span class="nx">m</span> <span class="o">&amp;&amp;</span> <span class="nx">m</span><span class="o">.</span><span class="nx">supersedes</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="k">for</span> <span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">s</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">=</span><span class="nx">j</span><span class="o">+</span><span class="m">1</span><span class="o">)</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="nx">j</span><span class="o">]</span> <span class="k">in</span> <span class="nx">r</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">delete</span> <span class="nx">r</span><span class="o">[</span><span class="nx">s</span><span class="o">[</span><span class="nx">j</span><span class="o">]];</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="nx">_attach</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="c">// this is the full list of items the YUI needs attached,</span>
<span class="c"></span> <span class="c">// which is needed if some dependencies are already on</span>
<span class="c"></span> <span class="c">// the page without their dependencies.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">attaching</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="s1">&#39;attaching Y supplied deps: &#39;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">attaching</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Loader&quot;</span><span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">_attach</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">attaching</span><span class="o">);</span>
<span class="o">}</span> <span class="k">else</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="s1">&#39;attaching sorted list: &#39;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">sorted</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Loader&quot;</span><span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">_attach</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sorted</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="nx">_onSuccess</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_pushEvents</span><span class="o">();</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_attach</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="k">this</span><span class="o">.</span><span class="nx">skipped</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">delete</span> <span class="k">this</span><span class="o">.</span><span class="nx">inserted</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">skipped</span> <span class="o">=</span> <span class="o">{};</span>
<span class="c">// this.fire(&#39;success&#39;, {</span>
<span class="c"></span> <span class="c">// data: this.data</span>
<span class="c"></span> <span class="c">// });</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">onSuccess</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">f</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">f</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">context</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">data</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">data</span>
<span class="o">});</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="nx">_onFailure</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">msg</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_attach</span><span class="o">();</span>
<span class="c">// this.fire(&#39;failure&#39;, {</span>
<span class="c"></span> <span class="c">// msg: &#39;operation failed: &#39; + msg,</span>
<span class="c"></span> <span class="c">// data: this.data</span>
<span class="c"></span> <span class="c">// });</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">onFailure</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">f</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">f</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">context</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">msg</span><span class="o">:</span> <span class="s1">&#39;operation failed: &#39;</span> <span class="o">+</span> <span class="nx">msg</span><span class="o">,</span>
<span class="nx">data</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">data</span>
<span class="o">});</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="nx">_onTimeout</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">msg</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_attach</span><span class="o">();</span>
<span class="c">// this.fire(&#39;timeout&#39;, {</span>
<span class="c"></span> <span class="c">// data: this.data</span>
<span class="c"></span> <span class="c">// });</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">onTimeout</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">f</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">f</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">context</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">data</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">data</span>
<span class="o">});</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Sorts the dependency tree. The last step of calculate()</span>
<span class="c"> * @method _sort</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_sort</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="c">// create an indexed list</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">s</span><span class="o">=</span><span class="nx">Y</span><span class="o">.</span><span class="nb">Object</span><span class="o">.</span><span class="nx">keys</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">required</span><span class="o">),</span> <span class="nx">info</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">moduleInfo</span><span class="o">,</span> <span class="nx">loaded</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">loaded</span><span class="o">,</span>
<span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
<span class="c">// returns true if b is not loaded, and is required</span>
<span class="c"></span> <span class="c">// directly or by means of modules it supersedes.</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">requires</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">aa</span><span class="o">,</span> <span class="nx">bb</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">mm</span><span class="o">=</span><span class="nx">info</span><span class="o">[</span><span class="nx">aa</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="nx">bb</span><span class="o">]</span> <span class="o">||</span> <span class="o">!</span><span class="nx">mm</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">var</span> <span class="nx">ii</span><span class="o">,</span> <span class="nx">rr</span> <span class="o">=</span> <span class="nx">mm</span><span class="o">.</span><span class="nx">expanded</span><span class="o">,</span>
<span class="nx">after</span> <span class="o">=</span> <span class="nx">mm</span><span class="o">.</span><span class="nx">after</span><span class="o">,</span> <span class="nx">other</span><span class="o">=</span><span class="nx">info</span><span class="o">[</span><span class="nx">bb</span><span class="o">];</span>
<span class="c">// check if this module requires the other directly</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">rr</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">rr</span><span class="o">,</span> <span class="nx">bb</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// check if this module should be sorted after the other</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">after</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">after</span><span class="o">,</span> <span class="nx">bb</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// check if this module requires one the other supersedes</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">ss</span><span class="o">=</span><span class="nx">info</span><span class="o">[</span><span class="nx">bb</span><span class="o">]</span> <span class="o">&amp;&amp;</span> <span class="nx">info</span><span class="o">[</span><span class="nx">bb</span><span class="o">].</span><span class="nx">supersedes</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">ss</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">ii</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">ii</span><span class="o">&lt;</span><span class="nx">ss</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">ii</span><span class="o">=</span><span class="nx">ii</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">requires</span><span class="o">(</span><span class="nx">aa</span><span class="o">,</span> <span class="nx">ss</span><span class="o">[</span><span class="nx">ii</span><span class="o">]))</span> <span class="o">{</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// external css files should be sorted below yui css</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">mm</span><span class="o">.</span><span class="nx">ext</span> <span class="o">&amp;&amp;</span> <span class="nx">mm</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="nx">CSS</span> <span class="o">&amp;&amp;</span> <span class="o">(!</span><span class="nx">other</span><span class="o">.</span><span class="nx">ext</span><span class="o">))</span> <span class="o">{</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">// pointer to the first unsorted item</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">p</span><span class="o">=</span><span class="m">0</span><span class="o">;</span>
<span class="c">// keep going until we make a pass without moving anything</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(;;)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">l</span><span class="o">=</span><span class="nx">s</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span> <span class="nx">a</span><span class="o">,</span> <span class="nx">b</span><span class="o">,</span> <span class="nx">j</span><span class="o">,</span> <span class="nx">k</span><span class="o">,</span> <span class="nx">moved</span><span class="o">=</span><span class="kc">false</span><span class="o">;</span>
<span class="c">// start the loop after items that are already sorted</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="nx">j</span><span class="o">=</span><span class="nx">p</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">l</span><span class="o">;</span> <span class="nx">j</span><span class="o">=</span><span class="nx">j</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// check the next module on the list to see if its</span>
<span class="c"></span> <span class="c">// dependencies have been met</span>
<span class="c"></span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">s</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
<span class="c">// check everything below current item and move if we</span>
<span class="c"></span> <span class="c">// find a requirement for the current item</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="nx">k</span><span class="o">=</span><span class="nx">j</span><span class="o">+</span><span class="m">1</span><span class="o">;</span> <span class="nx">k</span><span class="o">&lt;</span><span class="nx">l</span><span class="o">;</span> <span class="nx">k</span><span class="o">=</span><span class="nx">k</span><span class="o">+</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">requires</span><span class="o">(</span><span class="nx">a</span><span class="o">,</span> <span class="nx">s</span><span class="o">[</span><span class="nx">k</span><span class="o">]))</span> <span class="o">{</span>
<span class="c">// extract the dependency so we can move it up</span>
<span class="c"></span> <span class="nx">b</span> <span class="o">=</span> <span class="nx">s</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">k</span><span class="o">,</span> <span class="m">1</span><span class="o">);</span>
<span class="c">// insert the dependency above the item that </span>
<span class="c"></span> <span class="c">// requires it</span>
<span class="c"></span> <span class="nx">s</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span> <span class="m">0</span><span class="o">,</span> <span class="nx">b</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
<span class="nx">moved</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// jump out of loop if we moved something</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">moved</span><span class="o">)</span> <span class="o">{</span>
<span class="k">break</span><span class="o">;</span>
<span class="c">// this item is sorted, move our pointer and keep going</span>
<span class="c"></span> <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="nx">p</span> <span class="o">=</span> <span class="nx">p</span> <span class="o">+</span> <span class="m">1</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// when we make it here and moved is false, we are </span>
<span class="c"></span> <span class="c">// finished sorting</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="nx">moved</span><span class="o">)</span> <span class="o">{</span>
<span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">sorted</span> <span class="o">=</span> <span class="nx">s</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * inserts the requested modules and their dependencies. </span>
<span class="c"> * &lt;code&gt;type&lt;/code&gt; can be &quot;js&quot; or &quot;css&quot;. Both script and </span>
<span class="c"> * css are inserted if type is not provided.</span>
<span class="c"> * @method insert</span>
<span class="c"> * @param o optional options object</span>
<span class="c"> * @param type {string} the type of dependency to insert</span>
<span class="c"> */</span>
<span class="nx">insert</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="nx">type</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;Insert() &quot;</span> <span class="o">+</span> <span class="o">(</span><span class="nx">type</span> <span class="o">||</span> <span class="s1">&#39;&#39;</span><span class="o">),</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Loader&quot;</span><span class="o">);</span>
<span class="c">// build the dependency list</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">calculate</span><span class="o">(</span><span class="nx">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="o">{</span>
<span class="c">// Y.log(&quot;trying to load css first&quot;);</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_internalCallback</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="nx">self</span><span class="o">.</span><span class="nx">_internalCallback</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="nx">self</span><span class="o">.</span><span class="nx">insert</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="nx">JS</span><span class="o">);</span>
<span class="o">};</span>
<span class="k">this</span><span class="o">.</span><span class="nx">insert</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="nx">CSS</span><span class="o">);</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// set a flag to indicate the load has started</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">_loading</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="c">// flag to indicate we are done with the combo service</span>
<span class="c"></span> <span class="c">// and any additional files will need to be loaded</span>
<span class="c"></span> <span class="c">// individually</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">_combineComplete</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="c">// keep the loadType (js, css or undefined) cached</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">loadType</span> <span class="o">=</span> <span class="nx">type</span><span class="o">;</span>
<span class="c">// start the load</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">loadNext</span><span class="o">();</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Executed every time a module is loaded, and if we are in a load</span>
<span class="c"> * cycle, we attempt to load the next script. Public so that it</span>
<span class="c"> * is possible to call this if using a method other than</span>
<span class="c"> * Y.register to determine when scripts are fully loaded</span>
<span class="c"> * @method loadNext</span>
<span class="c"> * @param mname {string} optional the name of the module that has</span>
<span class="c"> * been loaded (which is usually why it is time to load the next</span>
<span class="c"> * one)</span>
<span class="c"> */</span>
<span class="nx">loadNext</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">mname</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// It is possible that this function is executed due to something</span>
<span class="c"></span> <span class="c">// else one the page loading a YUI module. Only react when we</span>
<span class="c"></span> <span class="c">// are actively loading something</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_loading</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">var</span> <span class="nx">s</span><span class="o">,</span> <span class="nx">len</span><span class="o">,</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">m</span><span class="o">,</span> <span class="nx">url</span><span class="o">,</span> <span class="nx">self</span><span class="o">=</span><span class="k">this</span><span class="o">;</span>
<span class="c">// @TODO this will need to handle the two phase insert when</span>
<span class="c"></span> <span class="c">// CSS support is added</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">loadType</span> <span class="o">!==</span> <span class="nx">CSS</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">combine</span> <span class="o">&amp;&amp;</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_combineComplete</span><span class="o">))</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_combining</span> <span class="o">=</span> <span class="o">[];</span>
<span class="nx">s</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">sorted</span><span class="o">;</span>
<span class="nx">len</span><span class="o">=</span><span class="nx">s</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
<span class="nx">url</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">comboBase</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</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">m</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getModule</span><span class="o">(</span><span class="nx">s</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
<span class="c">// @TODO we can&#39;t combine CSS yet until we deliver files with absolute paths to the assets</span>
<span class="c"></span> <span class="c">// Do not try to combine non-yui JS</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">m</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="nx">JS</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">m</span><span class="o">.</span><span class="nx">ext</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">url</span> <span class="o">+=</span> <span class="k">this</span><span class="o">.</span><span class="nx">root</span> <span class="o">+</span> <span class="nx">m</span><span class="o">.</span><span class="nx">path</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">url</span> <span class="o">+=</span> <span class="s1">&#39;&amp;&#39;</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_combining</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">s</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">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_combining</span><span class="o">.</span><span class="nx">length</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="s1">&#39;Attempting to combine: &#39;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_combining</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Loader&quot;</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">callback</span><span class="o">=</span><span class="k">function</span><span class="o">(</span><span class="nx">o</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="s1">&#39;Combo complete: &#39;</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">data</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Loader&quot;</span><span class="o">);</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_combineComplete</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">c</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">_combining</span><span class="o">,</span> <span class="nx">len</span><span class="o">=</span><span class="nx">c</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">m</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</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="k">this</span><span class="o">.</span><span class="nx">inserted</span><span class="o">[</span><span class="nx">c</span><span class="o">[</span><span class="nx">i</span><span class="o">]]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">loadNext</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">data</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">// @TODO get rid of the redundant Get code</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="nx">script</span><span class="o">(</span><span class="nx">url</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">data</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_loading</span><span class="o">,</span>
<span class="nx">onSuccess</span><span class="o">:</span> <span class="nx">callback</span><span class="o">,</span>
<span class="nx">onFailure</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFailure</span><span class="o">,</span>
<span class="nx">onTimeout</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTimeout</span><span class="o">,</span>
<span class="nx">insertBefore</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">,</span>
<span class="nx">charset</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">charset</span><span class="o">,</span>
<span class="nx">timeout</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">timeout</span><span class="o">,</span>
<span class="nx">context</span><span class="o">:</span> <span class="nx">self</span>
<span class="o">});</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_combineComplete</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">mname</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// if the module that was just loaded isn&#39;t what we were expecting,</span>
<span class="c"></span> <span class="c">// continue to wait</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">mname</span> <span class="o">!==</span> <span class="k">this</span><span class="o">.</span><span class="nx">_loading</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">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;loadNext executing, just loaded &quot;</span> <span class="o">+</span> <span class="nx">mname</span> <span class="o">||</span> <span class="s2">&quot;&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Loader&quot;</span><span class="o">);</span>
<span class="c">// The global handler that is called when each module is loaded</span>
<span class="c"></span> <span class="c">// will pass that module name to this function. Storing this</span>
<span class="c"></span> <span class="c">// data to avoid loading the same module multiple times</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">inserted</span><span class="o">[</span><span class="nx">mname</span><span class="o">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="c">// this.fire(&#39;progress&#39;, {</span>
<span class="c"></span> <span class="c">// name: mname,</span>
<span class="c"></span> <span class="c">// data: this.data</span>
<span class="c"></span> <span class="c">// });</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">onProgress</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">onProgress</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">context</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">name</span><span class="o">:</span> <span class="nx">mname</span><span class="o">,</span>
<span class="nx">data</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">data</span>
<span class="o">});</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="nx">s</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">sorted</span><span class="o">;</span>
<span class="nx">len</span><span class="o">=</span><span class="nx">s</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</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="c">// this.inserted keeps track of what the loader has loaded.</span>
<span class="c"></span> <span class="c">// move on if this item is done.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">s</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="k">in</span> <span class="k">this</span><span class="o">.</span><span class="nx">inserted</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(s[i] + &quot; alread loaded &quot;);</span>
<span class="c"></span> <span class="k">continue</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// Because rollups will cause multiple load notifications</span>
<span class="c"></span> <span class="c">// from Y, loadNext may be called multiple times for</span>
<span class="c"></span> <span class="c">// the same module when loading a rollup. We can safely</span>
<span class="c"></span> <span class="c">// skip the subsequent requests</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">s</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">===</span> <span class="k">this</span><span class="o">.</span><span class="nx">_loading</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;still loading &quot;</span> <span class="o">+</span> <span class="nx">s</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">+</span> <span class="s2">&quot;, waiting&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Loader&quot;</span><span class="o">);</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// log(&quot;inserting &quot; + s[i]);</span>
<span class="c"></span> <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getModule</span><span class="o">(</span><span class="nx">s</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">m</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;Undefined module &quot;</span> <span class="o">+</span> <span class="nx">s</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">+</span> <span class="s2">&quot; skipped&quot;</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">msg</span><span class="o">,</span> <span class="s1">&#39;warn&#39;</span><span class="o">,</span> <span class="s1">&#39;Loader&#39;</span><span class="o">);</span>
<span class="k">this</span><span class="o">.</span><span class="nx">inserted</span><span class="o">[</span><span class="nx">s</span><span class="o">[</span><span class="nx">i</span><span class="o">]]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">this</span><span class="o">.</span><span class="nx">skipped</span><span class="o">[</span><span class="nx">s</span><span class="o">[</span><span class="nx">i</span><span class="o">]]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">continue</span><span class="o">;</span>
<span class="c">// this.fire(&#39;failure&#39;, {</span>
<span class="c"></span> <span class="c">// msg: msg,</span>
<span class="c"></span> <span class="c">// data: this.data</span>
<span class="c"></span> <span class="c">// });</span>
<span class="c"></span> <span class="o">}</span>
<span class="c">// The load type is stored to offer the possibility to load</span>
<span class="c"></span> <span class="c">// the css separately from the script.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">loadType</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">loadType</span> <span class="o">===</span> <span class="nx">m</span><span class="o">.</span><span class="nx">type</span><span class="o">)</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_loading</span> <span class="o">=</span> <span class="nx">s</span><span class="o">[</span><span class="nx">i</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">s</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">base</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="s2">&quot;Loader&quot;</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">fn</span><span class="o">=(</span><span class="nx">m</span><span class="o">.</span><span class="nx">type</span> <span class="o">===</span> <span class="nx">CSS</span><span class="o">)</span> <span class="o">?</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Get</span><span class="o">.</span><span class="nx">css</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">script</span><span class="o">,</span>
<span class="nx">onsuccess</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="c">// Y.log(&#39;loading next, just loaded&#39; + o.data);</span>
<span class="c"></span> <span class="nx">self</span><span class="o">.</span><span class="nx">loadNext</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">data</span><span class="o">);</span>
<span class="o">};</span>
<span class="nx">url</span><span class="o">=</span><span class="nx">m</span><span class="o">.</span><span class="nx">fullpath</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">_url</span><span class="o">(</span><span class="nx">m</span><span class="o">.</span><span class="nx">path</span><span class="o">);</span>
<span class="nx">self</span><span class="o">=</span><span class="k">this</span><span class="o">;</span>
<span class="nx">fn</span><span class="o">(</span><span class="nx">url</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">data</span><span class="o">:</span> <span class="nx">s</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span>
<span class="nx">onSuccess</span><span class="o">:</span> <span class="nx">onsuccess</span><span class="o">,</span>
<span class="nx">insertBefore</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">,</span>
<span class="nx">charset</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">charset</span><span class="o">,</span>
<span class="nx">onFailure</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFailure</span><span class="o">,</span>
<span class="nx">onTimeout</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onTimeout</span><span class="o">,</span>
<span class="nx">timeout</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">timeout</span><span class="o">,</span>
<span class="nx">context</span><span class="o">:</span> <span class="nx">self</span>
<span class="o">});</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="c">// we are finished</span>
<span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">_loading</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">// internal callback for loading css first</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_internalCallback</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;loader internal&#39;);</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_internalCallback</span><span class="o">;</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_internalCallback</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="nx">f</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
<span class="c">// } else if (this.onSuccess) {</span>
<span class="c"></span> <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="c">// Y.log(&#39;loader complete&#39;);</span>
<span class="c"></span>
<span class="c">// call Y.use passing this instance. Y will use the sorted</span>
<span class="c"></span> <span class="c">// dependency list.</span>
<span class="c"></span>
<span class="k">this</span><span class="o">.</span><span class="nx">_onSuccess</span><span class="o">();</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * In IE, the onAvailable/onDOMReady events need help when Event is</span>
<span class="c"> * loaded dynamically</span>
<span class="c"> * @method _pushEvents</span>
<span class="c"> * @param {Function} optional function reference</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_pushEvents</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">ref</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">r</span> <span class="o">=</span> <span class="nx">ref</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">r</span><span class="o">.</span><span class="nx">Event</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">r</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">_load</span><span class="o">();</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Generates the full url for a module</span>
<span class="c"> * method _url</span>
<span class="c"> * @param path {string} the path fragment</span>
<span class="c"> * @return {string} the full url</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_url</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">path</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">u</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">base</span> <span class="o">||</span> <span class="s2">&quot;&quot;</span><span class="o">,</span> <span class="nx">f</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">filter</span><span class="o">;</span>
<span class="nx">u</span> <span class="o">=</span> <span class="nx">u</span> <span class="o">+</span> <span class="nx">path</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">f</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Y.log(&quot;filter: &quot; + f + &quot;, &quot; + f.searchExp + </span>
<span class="c"></span> <span class="c">// &quot;, &quot; + f.replaceStr);</span>
<span class="c"></span> <span class="nx">u</span> <span class="o">=</span> <span class="nx">u</span><span class="o">.</span><span class="nx">replace</span><span class="o">(</span><span class="k">new</span> <span class="nb">RegExp</span><span class="o">(</span><span class="nx">f</span><span class="o">.</span><span class="nx">searchExp</span><span class="o">),</span> <span class="nx">f</span><span class="o">.</span><span class="nx">replaceStr</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">// Y.log(u);</span>
<span class="c"></span>
<span class="k">return</span> <span class="nx">u</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">// Y.augment(Y.Loader, Y.Event.Target);</span>
<span class="c"></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=""><a href="get.js.html">get.js</a></li>
<li class="selected"><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>