loader.js revision ea6060eacdf2c9b092739bdca5533ac8c47e5a58
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Loader dynamically loads script and css files. It includes the dependency
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * info for the version of the library in use, and will automatically pull in
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * dependencies for the modules requested. It supports rollup files and will
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * automatically use these when appropriate in order to minimize the number of
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * http connections required to load all of the dependencies. It can load the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * files from the Yahoo! CDN, and it can utilize the combo service provided on
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * this network to reduce the number of http connections required to download
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * YUI files.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @module yui
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @submodule loader
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Loader dynamically loads script and css files. It includes the dependency
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * info for the version of the library in use, and will automatically pull in
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * dependencies for the modules requested. It supports rollup files and will
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * automatically use these when appropriate in order to minimize the number of
f96bd5c800e73e351b0b6e4bd7f00b578dad29bbAlan Wright * http connections required to load all of the dependencies. It can load the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * files from the Yahoo! CDN, and it can utilize the combo service provided on
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * this network to reduce the number of http connections required to download
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * YUI files.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @class Loader
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @constructor
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @param o an optional set of configuration options. Valid options:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * <li>base:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The base dir</li>
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * <li>secureBase:
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * The secure base dir (not implemented)</li>
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * <li>comboBase:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * <li>root:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * <li>filter:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * A filter to apply to result urls. This filter will modify the default
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * path for all modules. The default path for the YUI library is the
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * minified version of the files (e.g., event-min.js). The filter property
3db3f65c6274eb042354801a308c8e9bc4994553amw * can be a predefined filter or a custom filter. The valid predefined
3db3f65c6274eb042354801a308c8e9bc4994553amw * filters are:
3db3f65c6274eb042354801a308c8e9bc4994553amw * <dt>DEBUG</dt>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <dd>Selects the debug versions of the library (e.g., event-debug.js).
3db3f65c6274eb042354801a308c8e9bc4994553amw * This option will automatically include the Logger widget</dd>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <dt>RAW</dt>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
3db3f65c6274eb042354801a308c8e9bc4994553amw * You can also define a custom filter, which must be an object literal
3db3f65c6274eb042354801a308c8e9bc4994553amw * containing a search expression and a replace string:
3db3f65c6274eb042354801a308c8e9bc4994553amw * myFilter: {
3db3f65c6274eb042354801a308c8e9bc4994553amw * 'searchExp': "-min\\.js",
3db3f65c6274eb042354801a308c8e9bc4994553amw * 'replaceStr': "-debug.js"
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * <li>combine:
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * <li>ignore:
3db3f65c6274eb042354801a308c8e9bc4994553amw * A list of modules that should never be dynamically loaded</li>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <li>force:
3db3f65c6274eb042354801a308c8e9bc4994553amw * A list of modules that should always be loaded when required, even if already present on the page</li>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <li>insertBefore:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Node or id for a node that should be used as the insertion point for new nodes</li>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * <li>charset:
3db3f65c6274eb042354801a308c8e9bc4994553amw * charset for dynamic nodes</li>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <li>timeout:
3db3f65c6274eb042354801a308c8e9bc4994553amw * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <li>context:
3db3f65c6274eb042354801a308c8e9bc4994553amw * execution context for all callbacks</li>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <li>onSuccess:
3db3f65c6274eb042354801a308c8e9bc4994553amw * callback for the 'success' event</li>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <li>onFailure:
3db3f65c6274eb042354801a308c8e9bc4994553amw * callback for the 'failure' event</li>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <li>onTimeout:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * callback for the 'timeout' event</li>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <li>onProgress:
3db3f65c6274eb042354801a308c8e9bc4994553amw * callback executed each time a script or css file is loaded</li>
3db3f65c6274eb042354801a308c8e9bc4994553amw * <li>modules:
3db3f65c6274eb042354801a308c8e9bc4994553amw * A list of module definitions. See Loader.addModule for the supported module metadata</li>
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross// @TODO backed out the custom event changes so that the event system
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross// isn't required in the seed build. If needed, we may want to
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross// add them back if the event system is detected.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Executed when the loader successfully completes an insert operation
3db3f65c6274eb042354801a308c8e9bc4994553amw * This can be subscribed to normally, or a listener can be passed
3db3f65c6274eb042354801a308c8e9bc4994553amw * as an onSuccess config option.
3db3f65c6274eb042354801a308c8e9bc4994553amw * @event success
3db3f65c6274eb042354801a308c8e9bc4994553amw * Executed when the loader fails to complete an insert operation.
3db3f65c6274eb042354801a308c8e9bc4994553amw * This can be subscribed to normally, or a listener can be passed
3db3f65c6274eb042354801a308c8e9bc4994553amw * as an onFailure config option.
3db3f65c6274eb042354801a308c8e9bc4994553amw * @event failure
3db3f65c6274eb042354801a308c8e9bc4994553amw * Executed when a Get operation times out.
3db3f65c6274eb042354801a308c8e9bc4994553amw * This can be subscribed to normally, or a listener can be passed
3db3f65c6274eb042354801a308c8e9bc4994553amw * as an onTimeout config option.
3db3f65c6274eb042354801a308c8e9bc4994553amw * @event timeout
3db3f65c6274eb042354801a308c8e9bc4994553amw// 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"
3db3f65c6274eb042354801a308c8e9bc4994553amw CSS_AFTER = [CSSRESET, CSSFONTS, CSSGRIDS, 'cssreset-context', 'cssfonts-context', 'cssgrids-context'],
3db3f65c6274eb042354801a308c8e9bc4994553amw //rollup: 3
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dom-base': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dom-style': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dom-screen': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'node-base': {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 'node-style': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'node-screen': {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross 'node-event-simulate': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'anim-base': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'anim-color': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'anim-curve': {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 'anim-easing': {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross 'anim-scroll': {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross 'anim-xy': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'anim-node-plugin': {
3db3f65c6274eb042354801a308c8e9bc4994553amw // Note: CSS attributes are modified programmatically to reduce metadata size
3db3f65c6274eb042354801a308c8e9bc4994553amw // cssbase: {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // after: CSS_AFTER
3db3f65c6274eb042354801a308c8e9bc4994553amw // cssgrids: {
3db3f65c6274eb042354801a308c8e9bc4994553amw // requires: [CSSFONTS],
3db3f65c6274eb042354801a308c8e9bc4994553amw // optional: [CSSRESET]
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dd-ddm-base': {
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego 'dd-ddm-drop':{
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dd-drag':{
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dd-drop':{
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dd-proxy':{
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego 'dd-constrain':{
f96bd5c800e73e351b0b6e4bd7f00b578dad29bbAlan Wright 'dd-plugin':{
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego 'dd-drop-plugin':{
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-base': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-xdr': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-form': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-upload-iframe': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-queue': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'json-parse': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'json-stringify': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'node-menunav': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['widget', 'widget-position', 'widget-position-ext', 'widget-stack', 'widget-stdmod'],
3db3f65c6274eb042354801a308c8e9bc4994553amw 'widget-position': { },
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 'widget-position-ext': {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 'widget-stack': {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'widget-stdmod': { }
3db3f65c6274eb042354801a308c8e9bc4994553amw // Since YUI is required for everything else, it should not be specified as
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // a dependency.
3db3f65c6274eb042354801a308c8e9bc4994553amw 'yui-base': { },
3db3f65c6274eb042354801a308c8e9bc4994553amwvar _cssmeta = function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw // modify the meta info for YUI CSS
3db3f65c6274eb042354801a308c8e9bc4994553amw // define -context module
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw Y.Loader = function(o) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Internal callback to handle multiple internal insert() calls
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * so that css is inserted prior to js
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property _internalCallback
3db3f65c6274eb042354801a308c8e9bc4994553amw * @private
3db3f65c6274eb042354801a308c8e9bc4994553amw * Use the YUI environment listener to detect script load. This
3db3f65c6274eb042354801a308c8e9bc4994553amw * is only switched on for Safari 2.x and below.
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property _useYahooListener
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @private
3db3f65c6274eb042354801a308c8e9bc4994553amw this._useYahooListener = false;
3db3f65c6274eb042354801a308c8e9bc4994553amw * Callback that will be executed when the loader is finished
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * with an insert
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method onSuccess
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type function
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.onSuccess = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw * Callback that will be executed if there is a failure
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @method onFailure
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type function
3db3f65c6274eb042354801a308c8e9bc4994553amw this.onFailure = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw * Callback executed each time a script or css file is loaded
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @method onProgress
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type function
3db3f65c6274eb042354801a308c8e9bc4994553amw this.onProgress = null;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Callback that will be executed if a timeout occurs
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method onTimeout
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type function
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.onTimeout = null;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The execution context for all callbacks
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property context
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default {YUI} the YUI instance
3db3f65c6274eb042354801a308c8e9bc4994553amw * Data that is passed to all callbacks
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property data
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.data = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw * Node reference or id where new nodes should be inserted before
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property insertBefore
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type string|HTMLElement
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.insertBefore = null;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The charset attribute for inserted nodes
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * @property charset
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type string
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default utf-8
3db3f65c6274eb042354801a308c8e9bc4994553amw this.charset = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw * The base directory.
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property base
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type string
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default http://yui.yahooapis.com/[YUI VERSION]/build/
3db3f65c6274eb042354801a308c8e9bc4994553amw * Base path for the combo service
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property comboBase
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type string
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If configured, YUI JS resources will use the combo
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property combine
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type boolean
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * @default true if a base dir isn't in the config
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * Ignore modules registered on the YUI global
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property ignoreRegistered
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @default false
3db3f65c6274eb042354801a308c8e9bc4994553amw this.ignoreRegistered = false;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Root path to prepend to module path for the combo
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * @property root
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type string
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default [YUI VERSION]/build/
3db3f65c6274eb042354801a308c8e9bc4994553amw * Timeout value in milliseconds. If set, this value will be used by
3db3f65c6274eb042354801a308c8e9bc4994553amw * the get utility. the timeout event will fire if
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * a timeout occurs.
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property timeout
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type int
3db3f65c6274eb042354801a308c8e9bc4994553amw * A list of modules that should not be loaded, even if
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego * they turn up in the dependency tree
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property ignore
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type string[]
3db3f65c6274eb042354801a308c8e9bc4994553amw this.ignore = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw * A list of modules that should always be loaded, even
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * if they have already been inserted into the page.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property force
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * @type string[]
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross this.force = null;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Should we allow rollups
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property allowRollup
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type boolean
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * @default true
3db3f65c6274eb042354801a308c8e9bc4994553amw this.allowRollup = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw * A filter to apply to result urls. This filter will modify the default
3db3f65c6274eb042354801a308c8e9bc4994553amw * path for all modules. The default path for the YUI library is the
3db3f65c6274eb042354801a308c8e9bc4994553amw * minified version of the files (e.g., event-min.js). The filter property
3db3f65c6274eb042354801a308c8e9bc4994553amw * can be a predefined filter or a custom filter. The valid predefined
3db3f65c6274eb042354801a308c8e9bc4994553amw * filters are:
3db3f65c6274eb042354801a308c8e9bc4994553amw * <dt>DEBUG</dt>
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego * <dd>Selects the debug versions of the library (e.g., event-debug.js).
3db3f65c6274eb042354801a308c8e9bc4994553amw * This option will automatically include the Logger widget</dd>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * <dt>RAW</dt>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
3db3f65c6274eb042354801a308c8e9bc4994553amw * You can also define a custom filter, which must be an object literal
3db3f65c6274eb042354801a308c8e9bc4994553amw * containing a search expression and a replace string:
3db3f65c6274eb042354801a308c8e9bc4994553amw * myFilter: {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 'searchExp': "-min\\.js",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 'replaceStr': "-debug.js"
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property filter
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type string|{searchExp: string, replaceStr: string}
3db3f65c6274eb042354801a308c8e9bc4994553amw this.filter = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw * The list of requested modules
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property required
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type {string: boolean}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The library metadata
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property moduleInfo
3db3f65c6274eb042354801a308c8e9bc4994553amw // this.moduleInfo = Y.merge(Y.Env.meta.moduleInfo);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Provides the information used to skin the skinnable components.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The following skin definition would result in 'skin1' and 'skin2'
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * being loaded for calendar (if calendar was requested), and
3db3f65c6274eb042354801a308c8e9bc4994553amw * 'sam' for all other skinnable components:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * // The default skin, which is automatically applied if not
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * // overriden by a component-specific skin definition.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * // Change this in to apply a different skin globally
3db3f65c6274eb042354801a308c8e9bc4994553amw * defaultSkin: 'sam',
3db3f65c6274eb042354801a308c8e9bc4994553amw * // This is combined with the loader base property to get
3db3f65c6274eb042354801a308c8e9bc4994553amw * // the default root directory for a skin. ex:
3db3f65c6274eb042354801a308c8e9bc4994553amw * // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * base: 'assets/skins/',
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * // The name of the rollup css file for the skin
3db3f65c6274eb042354801a308c8e9bc4994553amw * path: 'skin.css',
3db3f65c6274eb042354801a308c8e9bc4994553amw * // The number of skinnable components requested that are
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * // required before using the rollup file rather than the
3db3f65c6274eb042354801a308c8e9bc4994553amw * // individual component css files
3db3f65c6274eb042354801a308c8e9bc4994553amw * rollup: 3,
3db3f65c6274eb042354801a308c8e9bc4994553amw * // Any component-specific overrides can be specified here,
3db3f65c6274eb042354801a308c8e9bc4994553amw * // making it possible to load different skins for different
3db3f65c6274eb042354801a308c8e9bc4994553amw * // components. It is possible to load more than one skin
3db3f65c6274eb042354801a308c8e9bc4994553amw * // for a given component as well.
3db3f65c6274eb042354801a308c8e9bc4994553amw * overrides: {
3db3f65c6274eb042354801a308c8e9bc4994553amw * calendar: ['skin1', 'skin2']
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property skin
3db3f65c6274eb042354801a308c8e9bc4994553amw for (var i in defaults) {
3db3f65c6274eb042354801a308c8e9bc4994553amw this._internal = true;
12b65585e720714b31036daaa2b30eb76014048eGordon Ross this._internal = false;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * List of rollup files found in the library metadata
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property rollups
3db3f65c6274eb042354801a308c8e9bc4994553amw this.rollups = null;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * Whether or not to load optional dependencies for
3db3f65c6274eb042354801a308c8e9bc4994553amw * the requested modules
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property loadOptional
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type boolean
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default false
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.loadOptional = false;
3db3f65c6274eb042354801a308c8e9bc4994553amw * All of the derived dependencies in sorted order, which
3db3f65c6274eb042354801a308c8e9bc4994553amw * will be populated when either calculate() or insert()
3db3f65c6274eb042354801a308c8e9bc4994553amw * is called
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property sorted
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type string[]
3db3f65c6274eb042354801a308c8e9bc4994553amw * Set when beginning to compute the dependency tree.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Composed of what YUI reports to be loaded combined
3db3f65c6274eb042354801a308c8e9bc4994553amw * with what has been loaded by the tool
3db3f65c6274eb042354801a308c8e9bc4994553amw * @propery loaded
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type {string: boolean}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * A list of modules to attach to the YUI instance when complete.
3db3f65c6274eb042354801a308c8e9bc4994553amw * If not supplied, the sorted list of dependencies are applied.
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property attaching
3db3f65c6274eb042354801a308c8e9bc4994553amw this.attaching = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw * Flag to indicate the dependency tree needs to be recomputed
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * if insert is called again.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property dirty
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type boolean
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default true
12b65585e720714b31036daaa2b30eb76014048eGordon Ross this.dirty = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw * List of modules inserted by the utility
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property inserted
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type {string: boolean}
3db3f65c6274eb042354801a308c8e9bc4994553amw // Y.on('yui:load', this.loadNext, this);
3db3f65c6274eb042354801a308c8e9bc4994553amw _config: function(o) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // apply config values
3db3f65c6274eb042354801a308c8e9bc4994553amw for (var i in o) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var val = o[i];
3db3f65c6274eb042354801a308c8e9bc4994553amw if (i == 'require') {
3db3f65c6274eb042354801a308c8e9bc4994553amw } else if (i == 'modules') {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross // add a hash of module definitions
3db3f65c6274eb042354801a308c8e9bc4994553amw for (var j in val) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // fix filter
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross var f = this.filter;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (L.isString(f)) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * Returns the skin module name for the specified skin name. If a
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * module name is supplied, the returned skin module name is
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * specific to the module passed in.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @method formatSkin
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @param skin {string} the name of the skin
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @param mod {string} optional: the name of a module to skin
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @return {string} the full skin module name
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * Reverses <code>formatSkin</code>, providing the skin name and
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * module name if the string matches the pattern for skins.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @method parseSkin
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @param mod {string} the module name to parse
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @return {skin: string, module: string} the parsed skin name
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * and module name, or null if the supplied string does not match
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * the skin pattern
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return null;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * Adds the skin def to the module info
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @method _addSkin
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @param skin {string} the name of the skin
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @param mod {string} the name of the module
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @param parent {string} parent module if this is a skin of a
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * submodule or plugin
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @return {string} the module name for the skin
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross var name = this.formatSkin(skin), info = this.moduleInfo,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross sinf = this.skin, ext = info[mod] && info[mod].ext;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Add a module definition for the skin rollup css
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (!info[name]) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross this.addModule({
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'name': name,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'type': 'css',
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'path': sinf.base + skin + '/' + sinf.path,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross //'supersedes': '*',
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'after': sinf.after,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'rollup': sinf.rollup,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Add a module definition for the module-specific skin css
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'path': (parent || pkg) + '/' + sinf.base + skin + '/' + mod + '.css',
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /** Add a new module to the component metadata.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>name:</dt> <dd>required, the component name</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>type:</dt> <dd>required, the component type (js or css)</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>path:</dt> <dd>required, the path to the script from "base"</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>requires:</dt> <dd>array of modules required by this component</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>optional:</dt> <dd>array of optional modules for this component</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>rollup:</dt> <dd>the number of superseded modules required for automatic rollup</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>skinnable:</dt> <dd>flag to determine if skin assets should automatically be pulled in</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dt>submodules:</dt> <dd>a has of submodules</dd>
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @method addModule
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @param o An object containing the module data
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @param name the module name (optional), required if not in the module data
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * @return {boolean} true if the module was added, false if
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * the object passed in did not provide all required attributes
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (!o || !o.name) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return false;
3db3f65c6274eb042354801a308c8e9bc4994553amw // o.path = name + "/" + name + "-min." + o.type;
3db3f65c6274eb042354801a308c8e9bc4994553amw o.ext = ('ext' in o) ? o.ext : (this._internal) ? false : true;
3db3f65c6274eb042354801a308c8e9bc4994553amw // Handle submodule logic
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross for (i in subs) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var s = subs[i];
3db3f65c6274eb042354801a308c8e9bc4994553amw this.addModule(s, i);
3db3f65c6274eb042354801a308c8e9bc4994553amw var smod = this._addSkin(this.skin.defaultSkin, i, name);
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in plugins) {
3db3f65c6274eb042354801a308c8e9bc4994553amw this.dirty = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw * Add a requirement for one or more module
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method require
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * @param what {string[] | string*} the modules to load
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross var a = (typeof what === "string") ? arguments : what;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.dirty = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw * Returns an object containing properties for all modules required
3db3f65c6274eb042354801a308c8e9bc4994553amw * in order to load the requested module
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method getRequires
3db3f65c6274eb042354801a308c8e9bc4994553amw * @param mod The module definition from moduleInfo
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return [];
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(r[i]);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // get the requirements from superseded modules, if any
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(r[i]);
3db3f65c6274eb042354801a308c8e9bc4994553amw if (o && this.loadOptional) {
3db3f65c6274eb042354801a308c8e9bc4994553amw * Returns an object literal of the modules the supplied module satisfies
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @method getProvides
3db3f65c6274eb042354801a308c8e9bc4994553amw * @param name{string} The name of the module
3db3f65c6274eb042354801a308c8e9bc4994553amw * @param notMe {string} don't add this module name, only include superseded modules
3db3f65c6274eb042354801a308c8e9bc4994553amw * @return what this module provides
3db3f65c6274eb042354801a308c8e9bc4994553amw return m[ckey];
3db3f65c6274eb042354801a308c8e9bc4994553amw // use worker to break cycles
3db3f65c6274eb042354801a308c8e9bc4994553amw // we always want the return value normal behavior
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // (provides) for superseded modules.
3db3f65c6274eb042354801a308c8e9bc4994553amw // calculate superseded modules
3db3f65c6274eb042354801a308c8e9bc4994553amw // supersedes cache
3db3f65c6274eb042354801a308c8e9bc4994553amw // provides cache
3db3f65c6274eb042354801a308c8e9bc4994553amw return m[ckey];
3db3f65c6274eb042354801a308c8e9bc4994553amw * Calculates the dependency tree, the result is stored in the sorted
3db3f65c6274eb042354801a308c8e9bc4994553amw * property
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method calculate
3db3f65c6274eb042354801a308c8e9bc4994553amw * @param o optional options object
3db3f65c6274eb042354801a308c8e9bc4994553amw calculate: function(o) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (o || this.dirty) {
3db3f65c6274eb042354801a308c8e9bc4994553amw this.dirty = false;
3db3f65c6274eb042354801a308c8e9bc4994553amw * Investigates the current YUI configuration on the page. By default,
3db3f65c6274eb042354801a308c8e9bc4994553amw * modules already detected will not be loaded again unless a force
3db3f65c6274eb042354801a308c8e9bc4994553amw * option is encountered. Called by calculate()
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method _setup
3db3f65c6274eb042354801a308c8e9bc4994553amw _setup: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw // Create skin modules
3db3f65c6274eb042354801a308c8e9bc4994553amw if (m && m.skinnable) {
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown if (o && o[name]) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross smod = this._addSkin(this.skin.defaultSkin, name);
3db3f65c6274eb042354801a308c8e9bc4994553amw // available modules
3db3f65c6274eb042354801a308c8e9bc4994553amw // add the ignore list to the list of loaded packages
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.ignore) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // OU.appendArray(l, this.ignore);
3db3f65c6274eb042354801a308c8e9bc4994553amw // expand the list to include superseded modules
3db3f65c6274eb042354801a308c8e9bc4994553amw for (j in l) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // remove modules on the force list from the loaded list
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.force) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.force[i] in l) {
3db3f65c6274eb042354801a308c8e9bc4994553amw delete l[this.force[i]];
3db3f65c6274eb042354801a308c8e9bc4994553amw * Inspects the required modules list looking for additional
3db3f65c6274eb042354801a308c8e9bc4994553amw * dependencies. Expands the required list to include all
3db3f65c6274eb042354801a308c8e9bc4994553amw * required modules. Called by calculate()
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method _explode
3db3f65c6274eb042354801a308c8e9bc4994553amw * @private
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw _explode: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in r) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // create the default module
3db3f65c6274eb042354801a308c8e9bc4994553amw // if (!m) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // m = this.addModule({ext: false}, name);
3db3f65c6274eb042354801a308c8e9bc4994553amw * Look for rollup packages to determine if all of the modules a
3db3f65c6274eb042354801a308c8e9bc4994553amw * rollup supersedes are required. If so, include the rollup to
3db3f65c6274eb042354801a308c8e9bc4994553amw * help reduce the total number of connections required. Called
3db3f65c6274eb042354801a308c8e9bc4994553amw * by calculate()
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method _rollup
3db3f65c6274eb042354801a308c8e9bc4994553amw * @private
3db3f65c6274eb042354801a308c8e9bc4994553amw _rollup: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw // find and cache rollup modules
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in info) {
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(i);
3db3f65c6274eb042354801a308c8e9bc4994553amw // if (m && m.rollup && m.supersedes) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (m && m.rollup) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // make as many passes as needed to pick up rollup rollups
3db3f65c6274eb042354801a308c8e9bc4994553amw for (;;) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var rolled = false;
3db3f65c6274eb042354801a308c8e9bc4994553amw // go through the rollup candidates
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in rollups) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // there can be only one
3db3f65c6274eb042354801a308c8e9bc4994553amw if (!r[i] && !this.loaded[i]) {
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(i);
3db3f65c6274eb042354801a308c8e9bc4994553amw s = m.supersedes || [];
3db3f65c6274eb042354801a308c8e9bc4994553amw // @TODO remove continue
3db3f65c6274eb042354801a308c8e9bc4994553amw // check the threshold
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // if the superseded module is loaded, we can't load the rollup
3db3f65c6274eb042354801a308c8e9bc4994553amw // if (this.loaded[s[j]] && (!_Y.dupsAllowed[s[j]])) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.loaded[s[j]]) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // increment the counter if this module is required. if we are
3db3f65c6274eb042354801a308c8e9bc4994553amw // beyond the rollup threshold, we will use the rollup module
3db3f65c6274eb042354801a308c8e9bc4994553amw } else if (r[s[j]]) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // add the rollup
3db3f65c6274eb042354801a308c8e9bc4994553amw r[i] = true;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // expand the rollup's dependencies
3db3f65c6274eb042354801a308c8e9bc4994553amw // if we made it here w/o rolling up something, we are done
3db3f65c6274eb042354801a308c8e9bc4994553amw * Remove superceded modules and loaded modules. Called by
3db3f65c6274eb042354801a308c8e9bc4994553amw * calculate() after we have the mega list of all dependencies
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method _reduce
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @private
3db3f65c6274eb042354801a308c8e9bc4994553amw _reduce: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw var i, j, s, m, r=this.required;
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in r) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // remove if already loaded
3db3f65c6274eb042354801a308c8e9bc4994553amw if (i in this.loaded) {
3db3f65c6274eb042354801a308c8e9bc4994553amw delete r[i];
3db3f65c6274eb042354801a308c8e9bc4994553amw // remove anything this module supersedes
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(i);
3db3f65c6274eb042354801a308c8e9bc4994553amw if (s[j] in r) {
3db3f65c6274eb042354801a308c8e9bc4994553amw delete r[s[j]];
3db3f65c6274eb042354801a308c8e9bc4994553amw _attach: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw // this is the full list of items the YUI needs attached,
3db3f65c6274eb042354801a308c8e9bc4994553amw // which is needed if some dependencies are already on
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // the page without their dependencies.
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.attaching) {
3db3f65c6274eb042354801a308c8e9bc4994553amw _onSuccess: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (var i in skipped) {
3db3f65c6274eb042354801a308c8e9bc4994553amw delete this.inserted[i];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // this.fire('success', {
3db3f65c6274eb042354801a308c8e9bc4994553amw // data: this.data
3db3f65c6274eb042354801a308c8e9bc4994553amw var f = this.onSuccess;
3db3f65c6274eb042354801a308c8e9bc4994553amw // this.fire('failure', {
3db3f65c6274eb042354801a308c8e9bc4994553amw // msg: 'operation failed: ' + msg,
3db3f65c6274eb042354801a308c8e9bc4994553amw // data: this.data
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw var f = this.onFailure;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States f.call(this.context, {
3db3f65c6274eb042354801a308c8e9bc4994553amw _onTimeout: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw // this.fire('timeout', {
3db3f65c6274eb042354801a308c8e9bc4994553amw // data: this.data
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw var f = this.onTimeout;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States });
3db3f65c6274eb042354801a308c8e9bc4994553amw * Sorts the dependency tree. The last step of calculate()
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method _sort
3db3f65c6274eb042354801a308c8e9bc4994553amw * @private
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States _sort: function() {
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai // create an indexed list
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai var s=Y.Object.keys(this.required), info=this.moduleInfo, loaded=this.loaded,
3db3f65c6274eb042354801a308c8e9bc4994553amw // returns true if b is not loaded, and is required
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown // directly or by means of modules it supersedes.
3db3f65c6274eb042354801a308c8e9bc4994553amw return false;
3db3f65c6274eb042354801a308c8e9bc4994553amw // check if this module requires the other directly
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (rr && Y.Array.indexOf(rr, bb) > -1) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return true;
3db3f65c6274eb042354801a308c8e9bc4994553amw // check if this module should be sorted after the other
3db3f65c6274eb042354801a308c8e9bc4994553amw return true;
3db3f65c6274eb042354801a308c8e9bc4994553amw // check if this module requires one the other supersedes
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown return true;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States // external css files should be sorted below yui css
3db3f65c6274eb042354801a308c8e9bc4994553amw if (mm.ext && mm.type == CSS && !other.ext && other.type == CSS) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return true;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return false;
3db3f65c6274eb042354801a308c8e9bc4994553amw // pointer to the first unsorted item
3db3f65c6274eb042354801a308c8e9bc4994553amw // keep going until we make a pass without moving anything
3db3f65c6274eb042354801a308c8e9bc4994553amw for (;;) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // start the loop after items that are already sorted
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for (j=p; j<l; j=j+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // check the next module on the list to see if its
3db3f65c6274eb042354801a308c8e9bc4994553amw // dependencies have been met
3db3f65c6274eb042354801a308c8e9bc4994553amw // check everything below current item and move if we
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // find a requirement for the current item
3db3f65c6274eb042354801a308c8e9bc4994553amw if (requires(a, s[k])) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // extract the dependency so we can move it up
3db3f65c6274eb042354801a308c8e9bc4994553amw // insert the dependency above the item that
3db3f65c6274eb042354801a308c8e9bc4994553amw // requires it
3db3f65c6274eb042354801a308c8e9bc4994553amw // jump out of loop if we moved something
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // this item is sorted, move our pointer and keep going
3db3f65c6274eb042354801a308c8e9bc4994553amw p = p + 1;
3db3f65c6274eb042354801a308c8e9bc4994553amw // when we make it here and moved is false, we are
3db3f65c6274eb042354801a308c8e9bc4994553amw // finished sorting
3db3f65c6274eb042354801a308c8e9bc4994553amw * inserts the requested modules and their dependencies.
3db3f65c6274eb042354801a308c8e9bc4994553amw * <code>type</code> can be "js" or "css". Both script and
f96bd5c800e73e351b0b6e4bd7f00b578dad29bbAlan Wright * css are inserted if type is not provided.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @method insert
3db3f65c6274eb042354801a308c8e9bc4994553amw * @param o optional options object
3db3f65c6274eb042354801a308c8e9bc4994553amw * @param type {string} the type of dependency to insert
3db3f65c6274eb042354801a308c8e9bc4994553amw // build the dependency list
3db3f65c6274eb042354801a308c8e9bc4994553amw var self = this;
3db3f65c6274eb042354801a308c8e9bc4994553amw this._internalCallback = function() {
7b6a044acdb057a3bcb993c4abd028d0f35595bbjose borrego // set a flag to indicate the load has started
3db3f65c6274eb042354801a308c8e9bc4994553amw // flag to indicate we are done with the combo service
3db3f65c6274eb042354801a308c8e9bc4994553amw // and any additional files will need to be loaded
3db3f65c6274eb042354801a308c8e9bc4994553amw // individually
3db3f65c6274eb042354801a308c8e9bc4994553amw // keep the loadType (js, css or undefined) cached
3db3f65c6274eb042354801a308c8e9bc4994553amw // start the load
3db3f65c6274eb042354801a308c8e9bc4994553amw * Executed every time a module is loaded, and if we are in a load
3db3f65c6274eb042354801a308c8e9bc4994553amw * cycle, we attempt to load the next script. Public so that it
3db3f65c6274eb042354801a308c8e9bc4994553amw * is possible to call this if using a method other than
3db3f65c6274eb042354801a308c8e9bc4994553amw * Y.register to determine when scripts are fully loaded
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @method loadNext
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * @param mname {string} optional the name of the module that has
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * been loaded (which is usually why it is time to load the next
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai // It is possible that this function is executed due to something
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai // else one the page loading a YUI module. Only react when we
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai // are actively loading something
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai var s, len, i, m, url, self=this, type=this.loadType, fn;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai // @TODO this will need to handle the two phase insert when
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai // CSS support is added
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai if (this.combine && (!this._combineComplete[type])) {
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai m = this.getModule(s[i]);
var callback=function(o) {
this.inserted[c[i]] = true;
if (mname) {
if (this.onProgress) {
s=this.sorted;
if (s[i] in this.inserted) {
if (s[i] === this._loading) {
m = this.getModule(s[i]);
this.inserted[s[i]] = true;
this.skipped[s[i]] = true;
this._loading = s[i];
var onsuccess=function(o) {
data: s[i],
this._loading = null;
if (fn) {
this._internalCallback = null;
this._onSuccess();
* In IE, the onAvailable/onDOMReady events need help when Event is
_pushEvents: function() {
if (Y.Event) {
_filter: function(u) {
var f = this.filter;
var useFilter = true;
useFilter = false;
useFilter = false;
if (useFilter) {