loader.js.html revision 4faa10dce2a190bcfe47119e70fc48011fde9023
<html>
<head>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<h3>loader <span class="subtitle">3.00PR1</span></h3>
<p>
> 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" /> Show Private</span>
<span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
<span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> Show Deprecated</span>
</form>
<div id="srcout">
<style>
#doc3 #classopts { display:none; }
</style>
<div class="highlight" ><pre><span class="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 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"> * <ul></span>
<span class="c"> * <li>base:</span>
<span class="c"> * The base dir</li></span>
<span class="c"> * <li>secureBase:</span>
<span class="c"> * The secure base dir (not implemented)</li></span>
<span class="c"> * <li>comboBase:</span>
<span class="c"> * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li></span>
<span class="c"> * <li>root:</span>
<span class="c"> * The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li></span>
<span class="c"> * <li>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"> * can be a predefined filter or a custom filter. The valid predefined </span>
<span class="c"> * filters are:</span>
<span class="c"> * <dl></span>
<span class="c"> * <dt>DEBUG</dt></span>
<span class="c"> * <dd>Selects the debug versions of the library (e.g., event-debug.js).</span>
<span class="c"> * This option will automatically include the logger widget</dd></span>
<span class="c"> * <dt>RAW</dt></span>
<span class="c"> * <dd>Selects the non-minified version of the library (e.g., event.js).</dd></span>
<span class="c"> * </dl></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"> * <pre></span>
<span class="c"> * myFilter: &#123; </span>
<span class="c"> * 'searchExp': "-min\\.js", </span>
<span class="c"> * &#125;</span>
<span class="c"> * </pre></span>
<span class="c"> *</span>
<span class="c"> * </li></span>
<span class="c"> * <li>combine:</span>
<span class="c"> * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li></span>
<span class="c"> * <li>ignore:</span>
<span class="c"> * A list of modules that should never be dynamically loaded</li></span>
<span class="c"> * <li>force:</span>
<span class="c"> * A list of modules that should always be loaded when required, even if already present on the page</li></span>
<span class="c"> * <li>insertBefore:</span>
<span class="c"> * Node or id for a node that should be used as the insertion point for new nodes</li></span>
<span class="c"> * <li>charset:</span>
<span class="c"> * charset for dynamic nodes</li></span>
<span class="c"> * <li>timeout:</span>
<span class="c"> * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li></span>
<span class="c"> * <li>context:</span>
<span class="c"> * execution context for all callbacks</li></span>
<span class="c"> * <li>onSuccess:</span>
<span class="c"> * callback for the 'success' event</li></span>
<span class="c"> * <li>onFailure:</span>
<span class="c"> * callback for the 'failure' event</li></span>
<span class="c"> * <li>onTimeout:</span>
<span class="c"> * callback for the 'timeout' event</li></span>
<span class="c"> * <li>onProgress:</span>
<span class="c"> * callback executed each time a script or css file is loaded</li></span>
<span class="c"> * <li>modules:</span>
<span class="c"> * A list of module definitions. See Loader.addModule for the supported module metadata</li></span>
<span class="c"> * </ul></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&2.5.2/build/dom/dom-min.js&2.5.2/build/event/event-min.js&2.5.2/build/autocomplete/autocomplete-min.js"</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">"loader"</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">'base'</span><span class="o">,</span>
<span class="nx">CSS</span> <span class="o">=</span> <span class="s1">'css'</span><span class="o">,</span>
<span class="nx">JS</span> <span class="o">=</span> <span class="s1">'js'</span><span class="o">,</span>
<span class="nx">RESET</span> <span class="o">=</span> <span class="s1">'cssreset'</span><span class="o">,</span>
<span class="nx">FONTS</span> <span class="o">=</span> <span class="s1">'cssfonts'</span><span class="o">,</span>
<span class="nx">GRIDS</span> <span class="o">=</span> <span class="s1">'cssgrids'</span><span class="o">,</span>
<span class="nx">VERSION</span> <span class="o">=</span> <span class="s1">'@VERSION@'</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">'/build/'</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="c"></span> <span class="nx">base</span><span class="o">:</span> <span class="s1">'/build/'</span><span class="o">,</span>
<span class="nx">comboBase</span><span class="o">:</span> <span class="s1">'http://yui.yahooapis.com/combo?'</span><span class="o">,</span>
<span class="nx">modules</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">'cssbase/base.css'</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">'cssfonts/fonts.css'</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">'cssgrids/grids.css'</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">'cssreset/reset.css'</span>
<span class="o">},</span>
<span class="c">// node, dom, event included in the yui dist, so we are not including the metadata for PR1</span>
<span class="c"></span>
<span class="nx">animation</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">'base'</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">'event'</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">'attribute'</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">compat</span><span class="o">:</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="s1">'dd-ddm-base'</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-ddm-base-min.js'</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'node'</span><span class="o">,</span> <span class="nx">BASE</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-ddm'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-ddm-min.js'</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-ddm-base'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-ddm-drop'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-ddm-drop-min.js'</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-ddm'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-drag'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-drag-min.js'</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-ddm-base'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-drop'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-drop-min.js'</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-ddm-drop'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-proxy'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-proxy-min.js'</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-drag'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-constrain'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-constrain-min.js'</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-drag'</span><span class="o">,</span> <span class="s1">'dd-proxy'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-plugin'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-plugin-min.js'</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-drag'</span><span class="o">],</span>
<span class="nx">optional</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-constrain'</span><span class="o">,</span> <span class="s1">'dd-proxy'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-drop-plugin'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-drop-plugin-min.js'</span><span class="o">,</span>
<span class="nx">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-drop'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-drag-all'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-drag-all-min.js'</span><span class="o">,</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-ddm-base'</span><span class="o">,</span> <span class="s1">'dd-ddm'</span><span class="o">,</span> <span class="s1">'dd-drag'</span><span class="o">,</span> <span class="s1">'dd-proxy'</span><span class="o">,</span> <span class="s1">'dd-constrain'</span><span class="o">,</span> <span class="s1">'dd-plugin'</span><span class="o">,</span> <span class="s1">'dd-drag-core'</span><span class="o">,</span> <span class="s1">'dd-drag-proxy'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-dragdrop-all'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-dragdrop-all-min.js'</span><span class="o">,</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-ddm-base'</span><span class="o">,</span> <span class="s1">'dd-ddm'</span><span class="o">,</span> <span class="s1">'dd-ddm-drop'</span><span class="o">,</span> <span class="s1">'dd-drag'</span><span class="o">,</span> <span class="s1">'dd-proxy'</span><span class="o">,</span> <span class="s1">'dd-constrain'</span><span class="o">,</span> <span class="s1">'dd-plugin'</span><span class="o">,</span> <span class="s1">'dd-drop'</span><span class="o">,</span> <span class="s1">'dd-drop-plugin'</span><span class="o">,</span> <span class="s1">'dd-drag-core'</span><span class="o">,</span> <span class="s1">'dd-drag-proxy'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-drop-core'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-drop-core-min.js'</span><span class="o">,</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-ddm-drop'</span><span class="o">,</span> <span class="s1">'dd-drop'</span><span class="o">,</span> <span class="s1">'dd-plugin-drop'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-drag-core'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-drag-core-min.js'</span><span class="o">,</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-ddm-base'</span><span class="o">,</span> <span class="s1">'dd-ddm'</span><span class="o">,</span> <span class="s1">'dd-drag'</span><span class="o">,</span> <span class="s1">'dd-plugin'</span><span class="o">]</span>
<span class="o">},</span>
<span class="s1">'dd-drag-proxy'</span><span class="o">:{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'dd/dd-drag-proxy-min.js'</span><span class="o">,</span>
<span class="nx">supersedes</span><span class="o">:</span> <span class="o">[</span><span class="s1">'dd-ddm-base'</span><span class="o">,</span> <span class="s1">'dd-ddm'</span><span class="o">,</span> <span class="s1">'dd-drag'</span><span class="o">,</span> <span class="s1">'dd-proxy'</span><span class="o">,</span> <span class="s1">'dd-plugin'</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">dom</span><span class="o">:</span> <span class="o">{</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">'oop'</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">io</span><span class="o">:</span> <span class="o">{</span> <span class="o">},</span>
<span class="s1">'json-parse'</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'json/json-parse-min.js'</span>
<span class="o">},</span>
<span class="s1">'json-stringify'</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">path</span><span class="o">:</span> <span class="s1">'json/json-stringify-min.js'</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">'json-parse'</span><span class="o">,</span> <span class="s1">'json-stringify'</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">requires</span><span class="o">:</span> <span class="o">[</span><span class="s1">'event'</span><span class="o">,</span> <span class="s1">'dom'</span><span class="o">]</span>
<span class="o">},</span>
<span class="nx">oop</span><span class="o">:</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">'dump'</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">"_provides"</span><span class="o">,</span> <span class="nx">SUPER</span> <span class="o">=</span> <span class="s2">"_supersedes"</span><span class="o">,</span>
<span class="nx">REQ</span> <span class="o">=</span> <span class="s2">"expanded"</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: {'yahoo': true, 'get': 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: '@yuiinfo@', </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"> * @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"> */</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"> */</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"> * can be a predefined filter or a custom filter. The valid predefined </span>
<span class="c"> * filters are:</span>
<span class="c"> * <dl></span>
<span class="c"> * <dt>DEBUG</dt></span>
<span class="c"> * <dd>Selects the debug versions of the library (e.g., event-debug.js).</span>
<span class="c"> * This option will automatically include the logger widget</dd></span>
<span class="c"> * <dt>RAW</dt></span>
<span class="c"> * <dd>Selects the non-minified version of the library (e.g., event.js).</dd></span>
<span class="c"> * </dl></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"> * <pre></span>
<span class="c"> * myFilter: &#123; </span>
<span class="c"> * 'searchExp': "-min\\.js", </span>
<span class="c"> * &#125;</span>
<span class="c"> * </pre></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"></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"></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">'searchExp'</span><span class="o">:</span> <span class="s2">"-min\\.js"</span><span class="o">,</span>
<span class="s1">'replaceStr'</span><span class="o">:</span> <span class="s2">".js"</span>
<span class="o">},</span>
<span class="nx">DEBUG</span><span class="o">:</span> <span class="o">{</span>
<span class="s1">'searchExp'</span><span class="o">:</span> <span class="s2">"-min\\.js"</span><span class="o">,</span>
<span class="s1">'replaceStr'</span><span class="o">:</span> <span class="s2">"-debug.js"</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">'require'</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">// 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">'modules'</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="k">if</span> <span class="o">(</span><span class="nx">f</span> <span class="o">===</span> <span class="s2">"DEBUG"</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="s2">"log"</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">// hack to handle a a bug where LogWriter is being instantiated</span>
<span class="c"></span> <span class="c">// at load time, and the loader has no way to sort above it</span>
<span class="c"></span> <span class="c">// at the moment.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="nx">Y</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">LogWriter</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">return</span> <span class="nx">Y</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">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"> * <dl></span>
<span class="c"> * <dt>name:</dt> <dd>required, the component name</dd></span>
<span class="c"> * <dt>type:</dt> <dd>required, the component type (js or css)</dd></span>
<span class="c"> * <dt>path:</dt> <dd>required, the path to the script from "base"</dd></span>
<span class="c"> * <dt>requires:</dt> <dd>array of modules required by this component</dd></span>
<span class="c"> * <dt>optional:</dt> <dd>array of optional modules for this component</dd></span>
<span class="c"> * <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd></span>
<span class="c"> * <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd></span>
<span class="c"> * <dt>rollup:</dt> <dd>the number of superseded modules required for automatic rollup</dd></span>
<span class="c"> * <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd></span>
<span class="c"> * <dt>skinnable:</dt> <dd>flag to determine if skin assets should automatically be pulled in</dd></span>
<span class="c"> * </dl></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">&&</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">"/"</span> <span class="o">+</span> <span class="nx">name</span> <span class="o">+</span> <span class="s2">"-min."</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">'ext'</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"></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">"string"</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="c"></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"></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">&&</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="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"><</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"></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="c"></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"><</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"><</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"></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="c"></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"><</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">&&</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"><</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"><</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="c"></span>
<span class="c"></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"></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'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('cached: ' + name + ' ' + ckey + ' ' + 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"></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 + ' provides worker skipping done: ' + 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"><</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"></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"></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"></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"></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">// 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"><</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">// 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"></span> <span class="k">if</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">owns</span><span class="o">(</span><span class="nx">l</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"></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"></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"></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('Module does not exist: ' + name + ', creating with defaults');</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"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">m</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="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">&&</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"><</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'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">&&</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">>=</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"></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"></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'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">&&</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"><</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">_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">_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"></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"></span> <span class="c">// msg: 'operation failed: ' + msg,</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">'operation failed: '</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"></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">&&</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">></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">&&</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">></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">&&</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"><</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">&&</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">&&</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"><</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"><</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"> * <code>type</code> can be "js" or "css". 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="c">// if (o) {</span>
<span class="c"></span> <span class="c">// Y.log("insert: " + L.dump(o, 1) + ", " + type);</span>
<span class="c"></span> <span class="c">// } else {</span>
<span class="c"></span> <span class="c">// Y.log("insert: " + this.toString() + ", " + type);</span>
<span class="c"></span> <span class="c">// }</span>
<span class="c"></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"></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"> * @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="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">combine</span> <span class="o">&&</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"><</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'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">&&</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"><</span> <span class="nx">len</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">url</span> <span class="o">+=</span> <span class="s1">'&'</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="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">'loading combo, just loaded'</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">"info"</span><span class="o">,</span> <span class="s2">"Loader"</span><span class="o">);</span>
<span class="nx">self</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="nx">self</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"><</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">self</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="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="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="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">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'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">"loadNext executing, just loaded "</span> <span class="o">+</span> <span class="nx">mname</span> <span class="o">||</span> <span class="s2">""</span><span class="o">,</span> <span class="s2">"info"</span><span class="o">,</span> <span class="s2">"Loader"</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"></span> <span class="c">// name: mname,</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"><</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"></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"></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">"still 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="o">+</span> <span class="s2">", waiting"</span><span class="o">,</span> <span class="s2">"info"</span><span class="o">,</span> <span class="s2">"Loader"</span><span class="o">);</span>
<span class="k">return</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// log("inserting " + 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">"Undefined module "</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">" skipped"</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">'warn'</span><span class="o">,</span> <span class="s1">'Loader'</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"></span> <span class="c">// msg: msg,</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">"attempting to load "</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">", "</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">"info"</span><span class="o">,</span> <span class="s2">"Loader"</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"></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"></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"></span> <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
<span class="c"></span>
<span class="c"></span> <span class="c">// 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"> * 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">""</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"></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"></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"></span>
<span class="o">},</span> <span class="s2">"@VERSION@"</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">
</ul>
</div>
<div class="module">
<h4>Classes</h4>
<ul class="content">
</ul>
</div>
<div class="module">
<h4>Files</h4>
<ul class="content">
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright © 2008 Yahoo! Inc. All rights reserved.
</div>
</div>
</body>
</html>