loader.js revision ba32d7c55eb4c846ff8ce5fc4054a77f5d6702bb
'gallerycss-': {
type:
'css' } }
// this makes skins in builds earlier than 2.6.0 work as long as combine is false * Loader dynamically loads script and css files. It includes the dependency * info for the version of the library in use, and will automatically pull in * dependencies for the modules requested. It supports rollup files and will * automatically use these when appropriate in order to minimize the number of * http connections required to load all of the dependencies. It can load the * files from the Yahoo! CDN, and it can utilize the combo service provided on * this network to reduce the number of http connections required to download * Loader dynamically loads script and css files. It includes the dependency * info for the version of the library in use, and will automatically pull in * dependencies for the modules requested. It supports rollup files and will * automatically use these when appropriate in order to minimize the number of * http connections required to load all of the dependencies. It can load the * files from the Yahoo! CDN, and it can utilize the combo service provided on * this network to reduce the number of http connections required to download * While the loader can be instantiated by the end user, it normally is not. * @see YUI.use for the normal use case. The use function automatically will * pull in missing dependencies. * @param o an optional set of configuration options. Valid options: * The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li> * A filter to apply to result urls. This filter will modify the default * path for all modules. The default path for the YUI library is the * minified version of the files (e.g., event-min.js). The filter property * can be a predefined filter or a custom filter. The valid predefined * <dd>Selects the debug versions of the library (e.g., event-debug.js). * This option will automatically include the Logger widget</dd> * <dd>Selects the non-minified version of the library (e.g., event.js).</dd> * You can also define a custom filter, which must be an object literal * containing a search expression and a replace string: * 'searchExp': "-min\\.js", * <li>filters: per-component filter specification. If specified for a given component, this overrides the filter config</li> * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li> * A list of modules that should never be dynamically loaded</li> * A list of modules that should always be loaded when required, even if already present on the page</li> * Node or id for a node that should be used as the insertion point for new nodes</li> * charset for dynamic nodes (deprecated, use jsAttributes or cssAttributes)</li> * <li>jsAttributes: object literal containing attributes to add to script nodes</li> * <li>cssAttributes: object literal containing attributes to add to link nodes</li> * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li> * execution context for all callbacks</li> * callback for the 'success' event</li> * <li>onFailure: callback for the 'failure' event</li> * <li>onCSS: callback for the 'CSSComplete' event. When loading YUI components with CSS * the CSS is loaded first, then the script. This provides a moment you can tie into to improve * the presentation of the page while the script is loading.</li> * callback for the 'timeout' event</li> * callback executed each time a script or css file is loaded</li> * A list of module definitions. See Loader.addModule for the supported module metadata</li> * A list of group definitions. Each group can contain specific definitions for base, comboBase, * combine, and accepts a list of modules. See above for the description of these properties.</li> * Internal callback to handle multiple internal insert() calls * so that css is inserted prior to js * @property _internalCallback // self._internalCallback = null; * Callback that will be executed when the loader is finished // self.onSuccess = null; * Callback that will be executed if there is a failure // self.onFailure = null; * Callback for the 'CSSComplete' event. When loading YUI components with CSS * the CSS is loaded first, then the script. This provides a moment you can tie into to improve * the presentation of the page while the script is loading. * Callback executed each time a script or css file is loaded // self.onProgress = null; * Callback that will be executed if a timeout occurs // self.onTimeout = null; * The execution context for all callbacks * @default {YUI} the YUI instance * Data that is passed to all callbacks * Node reference or id where new nodes should be inserted before * @type string|HTMLElement // self.insertBefore = null; * The charset attribute for inserted nodes * @deprecated, use cssAttributes or jsAttributes * An object literal containing attributes to add to link nodes * @property cssAttributes // self.cssAttributes = null; * An object literal containing attributes to add to script nodes * Base path for the combo service * Base path for language packs. // self.langBase = Y.Env.meta.langBase; * If configured, the loader will attempt to use the combo * service for YUI resources and configured external resources. * @default true if a base dir isn't in the config * Max url length for combo urls. The default is 2048 for * internet explorer, and 8192 otherwise. This is the URL * limit for the Yahoo! hosted combo servers. If consuming * a different combo service that has a different URL limit * it is possible to override this default by supplying * the maxURLLength config option. The config option will * only take effect if lower than the default. * Other A-Grade Browsers: Higher that what is typically supported * 'capable' mobile browsers: @TODO * Ignore modules registered on the YUI global * @property ignoreRegistered // self.ignoreRegistered = false; * Root path to prepend to module path for the combo * @default [YUI VERSION]/build/ * Timeout value in milliseconds. If set, self value will be used by * the get utility. the timeout event will fire if * A list of modules that should not be loaded, even if * they turn up in the dependency tree * A list of modules that should always be loaded, even * if they have already been inserted into the page. * Should we allow rollups * A filter to apply to result urls. This filter will modify the default * path for all modules. The default path for the YUI library is the * minified version of the files (e.g., event-min.js). The filter property * can be a predefined filter or a custom filter. The valid predefined * <dd>Selects the debug versions of the library (e.g., event-debug.js). * This option will automatically include the Logger widget</dd> * <dd>Selects the non-minified version of the library (e.g., event.js).</dd> * You can also define a custom filter, which must be an object literal * containing a search expression and a replace string: * 'searchExp': "-min\\.js", * @type string|{searchExp: string, replaceStr: string} * per-component filter specification. If specified for a given component, this * overrides the filter config. * The list of requested modules * @type {string: boolean} * If a module name is predefined when requested, it is checked againsts * the patterns provided in this property. If there is a match, the * module is added with the default configuration. * At the moment only supporting module prefixes, but anticipate supporting * at least regular expressions. // self.patterns = Y.merge(Y.Env.meta.patterns); // self.moduleInfo = Y.merge(Y.Env.meta.moduleInfo); * Provides the information used to skin the skinnable components. * The following skin definition would result in 'skin1' and 'skin2' * being loaded for calendar (if calendar was requested), and * 'sam' for all other skinnable components: * // The default skin, which is automatically applied if not * // overriden by a component-specific skin definition. * // Change this in to apply a different skin globally * // This is combined with the loader base property to get * // the default root directory for a skin. ex: * // Any component-specific overrides can be specified here, * // making it possible to load different skins for different * // components. It is possible to load more than one skin * // for a given component as well. * calendar: ['skin1', 'skin2'] // if (defaults.hasOwnProperty(i)) { // self.addModule(defaults[i], i); // if ((!(i in self.moduleInfo)) && onPage[i].details) { // self.addModule(onPage[i].details, i); * List of rollup files found in the library metadata * Whether or not to load optional dependencies for // self.loadOptional = false; * All of the derived dependencies in sorted order, which * will be populated when either calculate() or insert() * Set when beginning to compute the dependency tree. * Composed of what YUI reports to be loaded combined * with what has been loaded by any instance on the page * with the version number specified in the metadata. * @type {string: boolean} * A list of modules to attach to the YUI instance when complete. * If not supplied, the sorted list of dependencies are applied. // self.attaching = null; * Flag to indicate the dependency tree needs to be recomputed * if insert is called again. * List of modules inserted by the utility * @type {string: boolean} * List of skipped modules during insert() because the module // Y.on('yui:load', self.loadNext, self); 'searchExp':
"-min\\.js",
'searchExp':
"-min\\.js",
}
else if (i ==
'skin') {
}
else if (i ==
'groups') {
}
else if (i ==
'modules') {
// add a hash of module definitions }
else if (i ==
'maxURLLength') {
* Returns the skin module name for the specified skin name. If a * module name is supplied, the returned skin module name is * specific to the module passed in. * @param skin {string} the name of the skin * @param mod {string} optional: the name of a module to skin * @return {string} the full skin module name * Adds the skin def to the module info * @param skin {string} the name of the skin * @param mod {string} the name of the module * @param parent {string} parent module if this is a skin of a * @return {string} the module name for the skin // Add a module definition for the module-specific skin css // console.log(info[name]); /** Add a new module group * <dt>name:</dt> <dd>required, the group name</dd> * <dt>base:</dt> <dd>The base dir for this module group</dd> * <dt>root:</dt> <dd>The root path to add to each combo resource path</dd> * <dt>combine:</dt> <dd>combo handle</dd> * <dt>comboBase:</dt> <dd>combo service base path</dd> * <dt>modules:</dt> <dd>the group of modules</dd> * @param o An object containing the module data * @param name the module name (optional), required if not in the module data * @return {boolean} true if the module was added, false if * the object passed in did not provide all required attributes /** Add a new module to the component metadata. * <dt>name:</dt> <dd>required, the component name</dd> * <dt>type:</dt> <dd>required, the component type (js or css)</dd> * <dt>path:</dt> <dd>required, the path to the script from "base"</dd> * <dt>requires:</dt> <dd>array of modules required by this component</dd> * <dt>optional:</dt> <dd>array of optional modules for this component</dd> * <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd> * <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd> * <dt>rollup:</dt> <dd>the number of superseded modules required for automatic rollup</dd> * <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd> * <dt>skinnable:</dt> <dd>flag to determine if skin assets should automatically be pulled in</dd> * <dt>submodules:</dt> <dd>a hash of submodules</dd> * <dt>group:</dt> <dd>The group the module belongs to -- this is set automatically when * it is added as part of a group configuration.</dd> * <dt>lang:</dt> <dd>array of BCP 47 language tags of * languages for which this module has localized resource bundles, * e.g., ["en-GB","zh-Hans-CN"]</dd> * @param o An object containing the module data * @param name the module name (optional), required if not in the module data * @return the module definition or null if * the object passed in did not provide all required attributes // Handle submodule logic // , existing = this.moduleInfo[name], newr; // Adding a module again merges requirements to pick up new // requirements when the module arrives. We allow this only // once to prevent redundant checks when an application calls // if (existing && !existing.reparsed) { // for (i=0; i<o.requires.length; i++) { // if (YArray.indexOf(existing.requires, newr) == -1) { // existing.requires.push(newr); // delete existing.expanded; // existing.reparsed = true; // console.log('submodule: ' + i); // looks like we are expected to work out the metadata // for the parent module language packs from what is // specified in the child modules. // Add rollup file, need to add to supersedes list too // plug.requires.push(name); * Add a requirement for one or more module * @param what {string[] | string*} the modules to load * Returns an object containing properties for all modules required * in order to load the requested module * @param mod The module definition from moduleInfo // get the requirements from superseded modules, if any * Returns a hash of module names the supplied module satisfies. * @param name {string} The name of the module * @return what this module provides * Calculates the dependency tree, the result is stored in the sorted * @param o optional options object * @param type optional argument to prune modules * Investigates the current YUI configuration on the page. By default, * modules already detected will not be loaded again unless a force * option is encountered. Called by calculate() // Create lang pack modules // Setup root package if the module has lang defined, // it needs to provide a root language pack // add the ignore list to the list of loaded packages // expand the list to include superseded modules // remove modules on the force list from the loaded list if (
this.
force[i]
in l) {
* Builds a module name for a language pack * @function getLangPackName * @param lang {string} the language code * @param mname {string} the module to build it for * @return {string} the language pack module name * Inspects the required modules list looking for additional * dependencies. Expands the required list to include all * required modules. Called by calculate() // the setup phase is over, all modules have been created //TODO: Remove name check - it's a quick hack to fix pattern WIP // check the patterns library to see if we should automatically add // the module with defaults // use the metadata supplied for the pattern // as the module definition. // impl in rollup submodule * Remove superceded modules and loaded modules. Called by * calculate() after we have the mega list of all dependencies // remove if already loaded // remove anything this module supersedes for (j=
0; j<s.
length; j=j+
1) {
* Sorts the dependency tree. The last step of calculate() // create an indexed list // returns true if b is not loaded, and is required // directly or by means of modules it supersedes. // if (loaded[mod2] || !m || !other) { // check if this module requires the other directly // check if this module should be sorted after the other // check if this module requires one the other supersedes for (i=
0; i<s.
length; i=i+
1) {
// external css files should be sorted below yui css // keep going until we make a pass without moving anything // start the loop after items that are already sorted // check the next module on the list to see if its // dependencies have been met // check everything below current item and move if we // find a requirement for the current item for (k=j+
1; k<l; k=k+
1) {
// extract the dependency so we can move it up // insert the dependency above the item that // only swap two dependencies once to short circut // jump out of loop if we moved something // this item is sorted, move our pointer and keep going // when we make it here and moved is false, we are // restore the state at the time of the request // build the dependency list this.
calculate(o);
// don't include type so we can process CSS and script in // one pass when the type is not specified. // IE hack for style overrides that are not being applied // set a flag to indicate the load has started // flag to indicate we are done with the combo service // and any additional files will need to be loaded // Once a loader operation is completely finished, process // any additional queued items. * inserts the requested modules and their dependencies. * <code>type</code> can be "js" or "css". Both script and * css are inserted if type is not provided. * @param o optional options object * @param type {string} the type of dependency to insert * Executed every time a module is loaded, and if we are in a load * cycle, we attempt to load the next script. Public so that it * is possible to call this if using a method other than * Y.register to determine when scripts are fully loaded * @param mname {string} optional the name of the module that has * been loaded (which is usually why it is time to load the next // It is possible that this function is executed due to something // else one the page loading a YUI module. Only react when we // are actively loading something var s,
len, i, m,
url,
fn,
msg,
attr,
group,
groupName, j,
frag,
// the default combo base // m = this.getModule(s[i]); // Do not try to combine non-yui JS unless combo def is found // if the module that was just loaded isn't what we were expecting, // The global handler that is called when each module is loaded // will pass that module name to this function. Storing this // data to avoid loading the same module multiple times // centralize this in the callback for (i=
0; i<
len; i=i+
1) {
// this.inserted keeps track of what the loader has loaded. // move on if this item is done. // Because rollups will cause multiple load notifications // from Y, loadNext may be called multiple times for // the same module when loading a rollup. We can safely // skip the subsequent requests // log("inserting " + s[i]); msg =
"Undefined module " + s[i] +
" skipped";
// The load type is stored to offer the possibility to load // the css separately from the script. // internal callback for loading css first * Apply filter defined for this instance to a url/path * @param u {string} the string to filter * @param name {string} the name of the module, if we are processing * a single module as opposed to a combined url * @return {string} the filtered string * Generates the full url for a module * @param path {string} the path fragment * @return {string} the full url YUI.
add(
'loader-rollup',
function(Y) {
* Optional automatic rollup logic for reducing http connections * when not using a combo service. * Look for rollup packages to determine if all of the modules a * rollup supersedes are required. If so, include the rollup to * help reduce the total number of connections required. Called * by calculate(). This is an optional feature, and requires the * appropriate submodule to function. // find and cache rollup modules // if (m && m.rollup && m.supersedes) { // make as many passes as needed to pick up rollup rollups // go through the rollup candidates // there can be only one, unless forced // if the superseded module is loaded, we can't load the rollup // unless it has been forced // increment the counter if this module is required. if we are // beyond the rollup threshold, we will use the rollup module // expand the rollup's dependencies // if we made it here w/o rolling up something, we are done },
'@VERSION@' ,{
requires:[
'loader-base']});
YUI.
add(
'loader-yui3',
function(Y) {
"datasource-arrayschema": {
"datasource-jsonschema": {
"datasource-textschema": {
"datasource-xmlschema": {
"datatype-date-format": {
"event-custom-complex": {
"querystring-stringify-simple" "widget-position-constrain" "querystring-stringify": {
"querystring-parse-simple": {
"querystring-stringify-simple": {
"widget-position-align": {
"widget-position-constrain": {
},
'@VERSION@' ,{
requires:[
'loader-base']});
YUI.
add(
'loader',
function(Y){},
'@VERSION@' ,{
use:[
'loader-base',
'loader-rollup',
'loader-yui3' ]});