loader.js revision ea6060eacdf2c9b092739bdca5533ac8c47e5a58
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwYUI.add('loader', function(Y) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/**
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 *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @module yui
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @submodule loader
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/**
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 * <ul>
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 *
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 * <dl>
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 * </dl>
3db3f65c6274eb042354801a308c8e9bc4994553amw * You can also define a custom filter, which must be an object literal
3db3f65c6274eb042354801a308c8e9bc4994553amw * containing a search expression and a replace string:
3db3f65c6274eb042354801a308c8e9bc4994553amw * <pre>
3db3f65c6274eb042354801a308c8e9bc4994553amw * myFilter: &#123;
3db3f65c6274eb042354801a308c8e9bc4994553amw * 'searchExp': "-min\\.js",
3db3f65c6274eb042354801a308c8e9bc4994553amw * 'replaceStr': "-debug.js"
3db3f65c6274eb042354801a308c8e9bc4994553amw * &#125;
3db3f65c6274eb042354801a308c8e9bc4994553amw * </pre>
3db3f65c6274eb042354801a308c8e9bc4994553amw *
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * </li>
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>
3db3f65c6274eb042354801a308c8e9bc4994553amw * </ul>
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw
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.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
3db3f65c6274eb042354801a308c8e9bc4994553amw/*
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 */
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw/*
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 *
3db3f65c6274eb042354801a308c8e9bc4994553amw * @event failure
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw/*
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 *
3db3f65c6274eb042354801a308c8e9bc4994553amw * @event timeout
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw
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
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amwvar BASE = 'base',
3db3f65c6274eb042354801a308c8e9bc4994553amw CSS = 'css',
3db3f65c6274eb042354801a308c8e9bc4994553amw JS = 'js',
3db3f65c6274eb042354801a308c8e9bc4994553amw CSSRESET = 'cssreset',
3db3f65c6274eb042354801a308c8e9bc4994553amw CSSFONTS = 'cssfonts',
3db3f65c6274eb042354801a308c8e9bc4994553amw CSSGRIDS = 'cssgrids',
3db3f65c6274eb042354801a308c8e9bc4994553amw CSSBASE = 'cssbase',
3db3f65c6274eb042354801a308c8e9bc4994553amw CSS_AFTER = [CSSRESET, CSSFONTS, CSSGRIDS, 'cssreset-context', 'cssfonts-context', 'cssgrids-context'],
3db3f65c6274eb042354801a308c8e9bc4994553amw YUI_CSS = ['reset', 'fonts', 'grids', 'base'],
3db3f65c6274eb042354801a308c8e9bc4994553amw VERSION = '@VERSION@',
3db3f65c6274eb042354801a308c8e9bc4994553amw ROOT = VERSION + '/build/',
3db3f65c6274eb042354801a308c8e9bc4994553amw CONTEXT = '-context',
3db3f65c6274eb042354801a308c8e9bc4994553amw META = {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw version: VERSION,
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw root: ROOT,
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw base: 'http://yui.yahooapis.com/' + ROOT,
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw comboBase: 'http://yui.yahooapis.com/combo?',
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw skin: {
3db3f65c6274eb042354801a308c8e9bc4994553amw defaultSkin: 'sam',
3db3f65c6274eb042354801a308c8e9bc4994553amw base: 'assets/skins/',
3db3f65c6274eb042354801a308c8e9bc4994553amw path: 'skin.css',
3db3f65c6274eb042354801a308c8e9bc4994553amw after: ['reset', 'fonts', 'grids', 'base']
3db3f65c6274eb042354801a308c8e9bc4994553amw //rollup: 3
3db3f65c6274eb042354801a308c8e9bc4994553amw },
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw modules: {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw dom: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['event'],
3db3f65c6274eb042354801a308c8e9bc4994553amw submodules: {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dom-base': {
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego requires: ['event']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dom-style': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['dom-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dom-screen': {
12b65585e720714b31036daaa2b30eb76014048eGordon Ross requires: ['dom-base', 'dom-style']
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
12b65585e720714b31036daaa2b30eb76014048eGordon Ross selector: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['dom-base']
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw node: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['dom'],
3db3f65c6274eb042354801a308c8e9bc4994553amw submodules: {
12b65585e720714b31036daaa2b30eb76014048eGordon Ross
3db3f65c6274eb042354801a308c8e9bc4994553amw 'node-base': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['dom-base', 'selector']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
12b65585e720714b31036daaa2b30eb76014048eGordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 'node-style': {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw requires: ['dom-style', 'node-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'node-screen': {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross requires: ['dom-screen', 'node-base']
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross },
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross 'node-event-simulate': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['node-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw anim: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: [BASE, 'node'],
3db3f65c6274eb042354801a308c8e9bc4994553amw submodules: {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'anim-base': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['base', 'node-style']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'anim-color': {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw requires: ['anim-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'anim-curve': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['anim-xy']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 'anim-easing': {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross },
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross 'anim-scroll': {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross requires: ['anim-base']
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross },
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross 'anim-xy': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['anim-base', 'node-screen']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'anim-node-plugin': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['node', 'anim-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw attribute: {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw requires: ['event']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw base: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['attribute']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw compat: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['node', 'dump', 'substitute']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw classnamemanager: { },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw console: {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw requires: ['widget', 'substitute'],
3db3f65c6274eb042354801a308c8e9bc4994553amw skinnable: true
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw cookie: { },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // Note: CSS attributes are modified programmatically to reduce metadata size
3db3f65c6274eb042354801a308c8e9bc4994553amw // cssbase: {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // after: CSS_AFTER
3db3f65c6274eb042354801a308c8e9bc4994553amw // },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // cssgrids: {
3db3f65c6274eb042354801a308c8e9bc4994553amw // requires: [CSSFONTS],
3db3f65c6274eb042354801a308c8e9bc4994553amw // optional: [CSSRESET]
3db3f65c6274eb042354801a308c8e9bc4994553amw // },
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw dd:{
3db3f65c6274eb042354801a308c8e9bc4994553amw submodules: {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dd-ddm-base': {
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego requires: ['node', BASE]
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego },
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego 'dd-ddm':{
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego requires: ['dd-ddm-base']
f96bd5c800e73e351b0b6e4bd7f00b578dad29bbAlan Wright },
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego 'dd-ddm-drop':{
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego requires: ['dd-ddm']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dd-drag':{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw requires: ['dd-ddm-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dd-drop':{
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['dd-ddm-drop']
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego },
3db3f65c6274eb042354801a308c8e9bc4994553amw 'dd-proxy':{
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego requires: ['dd-drag']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego 'dd-constrain':{
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego requires: ['dd-drag', 'dd-proxy']
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego },
f96bd5c800e73e351b0b6e4bd7f00b578dad29bbAlan Wright 'dd-plugin':{
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego requires: ['dd-drag'],
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego optional: ['dd-constrain', 'dd-proxy']
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego },
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego 'dd-drop-plugin':{
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['dd-drop']
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw dump: { },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw event: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['oop']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw get: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['yui-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw io:{
3db3f65c6274eb042354801a308c8e9bc4994553amw submodules: {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-base': {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw requires: ['node']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-xdr': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['io-base']
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-form': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['io-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
12b65585e720714b31036daaa2b30eb76014048eGordon Ross
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-upload-iframe': {
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown requires: ['io-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'io-queue': {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw requires: ['io-base']
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
12b65585e720714b31036daaa2b30eb76014048eGordon Ross json: {
3db3f65c6274eb042354801a308c8e9bc4994553amw submodules: {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'json-parse': {
3db3f65c6274eb042354801a308c8e9bc4994553amw },
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown
3db3f65c6274eb042354801a308c8e9bc4994553amw 'json-stringify': {
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw loader: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['get']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'node-menunav': {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['node', 'classnamemanager'],
3db3f65c6274eb042354801a308c8e9bc4994553amw skinnable: true
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw oop: {
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai requires: ['yui-base']
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw overlay: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['widget', 'widget-position', 'widget-position-ext', 'widget-stack', 'widget-stdmod'],
3db3f65c6274eb042354801a308c8e9bc4994553amw skinnable: true
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw plugin: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['base']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw profiler: { },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw queue: {
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai requires: ['node']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw slider: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['widget', 'dd-constrain'],
3db3f65c6274eb042354801a308c8e9bc4994553amw skinnable: true
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw stylesheet: { },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw substitute: {
3db3f65c6274eb042354801a308c8e9bc4994553amw optional: ['dump']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw widget: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['base', 'node', 'classnamemanager'],
3db3f65c6274eb042354801a308c8e9bc4994553amw plugins: {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'widget-position': { },
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 'widget-position-ext': {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw requires: ['widget-position']
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw },
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 'widget-stack': {
3db3f65c6274eb042354801a308c8e9bc4994553amw skinnable: true
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw 'widget-stdmod': { }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw skinnable: true
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // Since YUI is required for everything else, it should not be specified as
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // a dependency.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross yui: {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw supersedes: ['yui-base', 'get', 'loader']
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw 'yui-base': { },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw test: {
3db3f65c6274eb042354801a308c8e9bc4994553amw requires: ['substitute', 'node', 'json']
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw};
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amwvar _path = function(dir, file, type) {
3db3f65c6274eb042354801a308c8e9bc4994553amw return dir + '/' + file + '-min.' + (type || CSS);
3db3f65c6274eb042354801a308c8e9bc4994553amw};
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amwvar _cssmeta = function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw var mods = META.modules;
3db3f65c6274eb042354801a308c8e9bc4994553amw // modify the meta info for YUI CSS
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for (var i=0; i<YUI_CSS.length; i=i+1) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross var bname = YUI_CSS[i],
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mname = CSS + bname;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw mods[mname] = {
3db3f65c6274eb042354801a308c8e9bc4994553amw type: CSS,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw path: _path(mname, bname)
3db3f65c6274eb042354801a308c8e9bc4994553amw };
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // define -context module
3db3f65c6274eb042354801a308c8e9bc4994553amw var contextname = mname + CONTEXT;
3db3f65c6274eb042354801a308c8e9bc4994553amw bname = bname + CONTEXT;
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mods[contextname] = {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw type: CSS,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw path: _path(mname, bname)
3db3f65c6274eb042354801a308c8e9bc4994553amw };
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (mname == CSSGRIDS) {
3db3f65c6274eb042354801a308c8e9bc4994553amw mods[mname].requires = [CSSFONTS];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mods[mname].optional = [CSSRESET];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mods[contextname].requires = [CSSFONTS + CONTEXT];
3db3f65c6274eb042354801a308c8e9bc4994553amw mods[contextname].optional = [CSSRESET + CONTEXT];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else if (mname == CSSBASE) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mods[mname].after = CSS_AFTER;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mods[contextname].after = CSS_AFTER;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw}();
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwY.Env.meta = META;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw var L=Y.Lang, env=Y.Env,
3db3f65c6274eb042354801a308c8e9bc4994553amw PROV = "_provides", SUPER = "_supersedes",
3db3f65c6274eb042354801a308c8e9bc4994553amw REQ = "expanded";
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw Y.Loader = function(o) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross /**
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 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this._internalCallback = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
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 */
3db3f65c6274eb042354801a308c8e9bc4994553amw this._useYahooListener = false;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * Callback that will be executed when the loader is finished
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * with an insert
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method onSuccess
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type function
3db3f65c6274eb042354801a308c8e9bc4994553amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.onSuccess = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * Callback that will be executed if there is a failure
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @method onFailure
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type function
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.onFailure = null;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * Callback executed each time a script or css file is loaded
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @method onProgress
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type function
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.onProgress = null;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Callback that will be executed if a timeout occurs
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method onTimeout
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type function
3db3f65c6274eb042354801a308c8e9bc4994553amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.onTimeout = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The execution context for all callbacks
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property context
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default {YUI} the YUI instance
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.context = Y;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * Data that is passed to all callbacks
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property data
3db3f65c6274eb042354801a308c8e9bc4994553amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.data = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * Node reference or id where new nodes should be inserted before
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property insertBefore
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type string|HTMLElement
3db3f65c6274eb042354801a308c8e9bc4994553amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.insertBefore = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The charset attribute for inserted nodes
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * @property charset
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type string
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default utf-8
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.charset = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * The base directory.
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property base
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type string
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default http://yui.yahooapis.com/[YUI VERSION]/build/
12b65585e720714b31036daaa2b30eb76014048eGordon Ross */
12b65585e720714b31036daaa2b30eb76014048eGordon Ross this.base = Y.Env.meta.base;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * Base path for the combo service
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property comboBase
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type string
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * @default http://yui.yahooapis.com/combo?
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.comboBase = Y.Env.meta.comboBase;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If configured, YUI JS resources will use the combo
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * handler
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property combine
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type boolean
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * @default true if a base dir isn't in the config
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.combine = (!(BASE in o));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
12b65585e720714b31036daaa2b30eb76014048eGordon Ross /**
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * Ignore modules registered on the YUI global
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property ignoreRegistered
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @default false
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.ignoreRegistered = false;
3db3f65c6274eb042354801a308c8e9bc4994553amw
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross /**
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Root path to prepend to module path for the combo
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * service
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * @property root
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type string
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default [YUI VERSION]/build/
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.root = Y.Env.meta.root;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
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 */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.timeout = 0;
3db3f65c6274eb042354801a308c8e9bc4994553amw
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego /**
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[]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.ignore = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
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 */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross this.force = null;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross /**
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Should we allow rollups
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property allowRollup
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type boolean
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * @default true
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.allowRollup = true;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
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:
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego * <dl>
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 * </dl>
3db3f65c6274eb042354801a308c8e9bc4994553amw * You can also define a custom filter, which must be an object literal
3db3f65c6274eb042354801a308c8e9bc4994553amw * containing a search expression and a replace string:
3db3f65c6274eb042354801a308c8e9bc4994553amw * <pre>
3db3f65c6274eb042354801a308c8e9bc4994553amw * myFilter: &#123;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 'searchExp': "-min\\.js",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 'replaceStr': "-debug.js"
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * &#125;
3db3f65c6274eb042354801a308c8e9bc4994553amw * </pre>
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property filter
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type string|{searchExp: string, replaceStr: string}
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.filter = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * The list of requested modules
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property required
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type {string: boolean}
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.required = {};
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The library metadata
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property moduleInfo
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw // this.moduleInfo = Y.merge(Y.Env.meta.moduleInfo);
3db3f65c6274eb042354801a308c8e9bc4994553amw this.moduleInfo = {};
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
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:
3db3f65c6274eb042354801a308c8e9bc4994553amw *
3db3f65c6274eb042354801a308c8e9bc4994553amw * <code>
3db3f65c6274eb042354801a308c8e9bc4994553amw * skin: {
3db3f65c6274eb042354801a308c8e9bc4994553amw *
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 *
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 *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * // The name of the rollup css file for the skin
3db3f65c6274eb042354801a308c8e9bc4994553amw * path: 'skin.css',
3db3f65c6274eb042354801a308c8e9bc4994553amw *
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 *
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 * }
3db3f65c6274eb042354801a308c8e9bc4994553amw * }
3db3f65c6274eb042354801a308c8e9bc4994553amw * </code>
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property skin
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.skin = Y.merge(Y.Env.meta.skin);
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var defaults = Y.Env.meta.modules;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw for (var i in defaults) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (defaults.hasOwnProperty(i)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw this._internal = true;
12b65585e720714b31036daaa2b30eb76014048eGordon Ross this.addModule(defaults[i], i);
12b65585e720714b31036daaa2b30eb76014048eGordon Ross this._internal = false;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * List of rollup files found in the library metadata
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property rollups
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.rollups = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * Whether or not to load optional dependencies for
3db3f65c6274eb042354801a308c8e9bc4994553amw * the requested modules
3db3f65c6274eb042354801a308c8e9bc4994553amw * @property loadOptional
3db3f65c6274eb042354801a308c8e9bc4994553amw * @type boolean
3db3f65c6274eb042354801a308c8e9bc4994553amw * @default false
3db3f65c6274eb042354801a308c8e9bc4994553amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.loadOptional = false;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
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[]
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.sorted = [];
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
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}
3db3f65c6274eb042354801a308c8e9bc4994553amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.loaded = {};
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
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 */
3db3f65c6274eb042354801a308c8e9bc4994553amw this.attaching = null;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
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 */
12b65585e720714b31036daaa2b30eb76014048eGordon Ross this.dirty = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * List of modules inserted by the utility
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @property inserted
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * @type {string: boolean}
3db3f65c6274eb042354801a308c8e9bc4994553amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.inserted = {};
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this.skipped = {};
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // Y.on('yui:load', this.loadNext, this);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this._config(o);
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw };
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw Y.Loader.prototype = {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw FILTERS: {
3db3f65c6274eb042354801a308c8e9bc4994553amw RAW: {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'searchExp': "-min\\.js",
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross 'replaceStr': ".js"
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw DEBUG: {
3db3f65c6274eb042354801a308c8e9bc4994553amw 'searchExp': "-min\\.js",
3db3f65c6274eb042354801a308c8e9bc4994553amw 'replaceStr': "-debug.js"
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw SKIN_PREFIX: "skin-",
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw _config: function(o) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // apply config values
3db3f65c6274eb042354801a308c8e9bc4994553amw if (o) {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (var i in o) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (o.hasOwnProperty(i)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var val = o[i];
3db3f65c6274eb042354801a308c8e9bc4994553amw if (i == 'require') {
3db3f65c6274eb042354801a308c8e9bc4994553amw this.require(val);
3db3f65c6274eb042354801a308c8e9bc4994553amw } else if (i == 'modules') {
3db3f65c6274eb042354801a308c8e9bc4994553amw
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross // add a hash of module definitions
3db3f65c6274eb042354801a308c8e9bc4994553amw for (var j in val) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (val.hasOwnProperty(j)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw this.addModule(val[j], j);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross } else {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross this[i] = val;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross }
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross }
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
3db3f65c6274eb042354801a308c8e9bc4994553amw // fix filter
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross var f = this.filter;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
3db3f65c6274eb042354801a308c8e9bc4994553amw if (L.isString(f)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw f = f.toUpperCase();
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross this.filterName = f;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross this.filter = this.FILTERS[f];
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross },
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /**
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 */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross formatSkin: function(skin, mod) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross var s = this.SKIN_PREFIX + skin;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (mod) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross s = s + "-" + mod;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return s;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross },
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /**
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 */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross parseSkin: function(mod) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (mod.indexOf(this.SKIN_PREFIX) === 0) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross var a = mod.split("-");
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return {skin: a[1], module: a[2]};
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return null;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross },
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /**
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 * @private
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross _addSkin: function(skin, mod, parent) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross var name = this.formatSkin(skin), info = this.moduleInfo,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross sinf = this.skin, ext = info[mod] && info[mod].ext;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /*
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 'ext': ext
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross });
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Add a module definition for the module-specific skin css
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (mod) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross name = this.formatSkin(skin, mod);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (!info[name]) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross var mdef = info[mod], pkg = mdef.pkg || mod;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross this.addModule({
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'name': name,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'type': 'css',
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'after': sinf.after,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'path': (parent || pkg) + '/' + sinf.base + skin + '/' + mod + '.css',
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross 'ext': ext
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross });
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return name;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross },
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /** Add a new module to the component metadata.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * <dl>
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 * </dl>
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 */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross addModule: function(o, name) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross name = name || o.name;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross o.name = name;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (!o || !o.name) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return false;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (!o.type) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross o.type = JS;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (!o.path && !o.fullpath) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // o.path = name + "/" + name + "-min." + o.type;
3db3f65c6274eb042354801a308c8e9bc4994553amw o.path = _path(name, name, o.type);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw o.ext = ('ext' in o) ? o.ext : (this._internal) ? false : true;
3db3f65c6274eb042354801a308c8e9bc4994553amw o.requires = o.requires || [];
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this.moduleInfo[name] = o;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // Handle submodule logic
3db3f65c6274eb042354801a308c8e9bc4994553amw var subs = o.submodules, i;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (subs) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var sup = [], l=0;
3db3f65c6274eb042354801a308c8e9bc4994553amw
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross for (i in subs) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (subs.hasOwnProperty(i)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var s = subs[i];
3db3f65c6274eb042354801a308c8e9bc4994553amw s.path = _path(name, i, o.type);
3db3f65c6274eb042354801a308c8e9bc4994553amw this.addModule(s, i);
3db3f65c6274eb042354801a308c8e9bc4994553amw sup.push(i);
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (o.skinnable) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var smod = this._addSkin(this.skin.defaultSkin, i, name);
3db3f65c6274eb042354801a308c8e9bc4994553amw sup.push(smod.name);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw l++;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw o.supersedes = sup;
3db3f65c6274eb042354801a308c8e9bc4994553amw o.rollup = Math.min(l-1, 4);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var plugins = o.plugins;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (plugins) {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in plugins) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (plugins.hasOwnProperty(i)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var plug = plugins[i];
3db3f65c6274eb042354801a308c8e9bc4994553amw plug.path = _path(name, i, o.type);
3db3f65c6274eb042354801a308c8e9bc4994553amw plug.requires = plug.requires || [];
3db3f65c6274eb042354801a308c8e9bc4994553amw plug.requires.push(name);
3db3f65c6274eb042354801a308c8e9bc4994553amw this.addModule(plug, i);
3db3f65c6274eb042354801a308c8e9bc4994553amw if (o.skinnable) {
3db3f65c6274eb042354801a308c8e9bc4994553amw this._addSkin(this.skin.defaultSkin, i, name);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this.dirty = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw return o;
3db3f65c6274eb042354801a308c8e9bc4994553amw },
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * Add a requirement for one or more module
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method require
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * @param what {string[] | string*} the modules to load
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross require: function(what) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross var a = (typeof what === "string") ? arguments : what;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.dirty = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw Y.mix(this.required, Y.Array.hash(a));
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
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
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw getRequires: function(mod) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!mod) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return [];
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!this.dirty && mod.expanded) {
3db3f65c6274eb042354801a308c8e9bc4994553amw return mod.expanded;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var i, d=[], r=mod.requires, o=mod.optional,
3db3f65c6274eb042354801a308c8e9bc4994553amw info=this.moduleInfo, m, j, add;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i=0; i<r.length; i=i+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw d.push(r[i]);
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(r[i]);
3db3f65c6274eb042354801a308c8e9bc4994553amw add = this.getRequires(m);
3db3f65c6274eb042354801a308c8e9bc4994553amw for (j=0;j<add.length;j=j+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw d.push(add[j]);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // get the requirements from superseded modules, if any
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw r=mod.supersedes;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (r) {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i=0; i<r.length; i=i+1) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw d.push(r[i]);
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(r[i]);
3db3f65c6274eb042354801a308c8e9bc4994553amw add = this.getRequires(m);
3db3f65c6274eb042354801a308c8e9bc4994553amw for (j=0;j<add.length;j=j+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw d.push(add[j]);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (o && this.loadOptional) {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i=0; i<o.length; i=i+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw d.push(o[i]);
3db3f65c6274eb042354801a308c8e9bc4994553amw add = this.getRequires(info[o[i]]);
3db3f65c6274eb042354801a308c8e9bc4994553amw for (j=0;j<add.length;j=j+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw d.push(add[j]);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mod.expanded = Y.Object.keys(Y.Array.hash(d));
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw return mod.expanded;
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
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 */
3db3f65c6274eb042354801a308c8e9bc4994553amw getProvides: function(name, notMe) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw var addMe = !(notMe), ckey = (addMe) ? PROV : SUPER,
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(name), o = {};
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (!m) {
3db3f65c6274eb042354801a308c8e9bc4994553amw return o;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (m[ckey]) {
3db3f65c6274eb042354801a308c8e9bc4994553amw return m[ckey];
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw var s = m.supersedes, done={}, me = this;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // use worker to break cycles
3db3f65c6274eb042354801a308c8e9bc4994553amw var add = function(mm) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!done[mm]) {
3db3f65c6274eb042354801a308c8e9bc4994553amw done[mm] = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw // we always want the return value normal behavior
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // (provides) for superseded modules.
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown Y.mix(o, me.getProvides(mm));
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // else {
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown // }
3db3f65c6274eb042354801a308c8e9bc4994553amw };
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // calculate superseded modules
3db3f65c6274eb042354801a308c8e9bc4994553amw if (s) {
12b65585e720714b31036daaa2b30eb76014048eGordon Ross for (var i=0; i<s.length; i=i+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw add(s[i]);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // supersedes cache
3db3f65c6274eb042354801a308c8e9bc4994553amw m[SUPER] = o;
3db3f65c6274eb042354801a308c8e9bc4994553amw // provides cache
3db3f65c6274eb042354801a308c8e9bc4994553amw m[PROV] = Y.merge(o);
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown m[PROV][name] = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw return m[ckey];
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * Calculates the dependency tree, the result is stored in the sorted
3db3f65c6274eb042354801a308c8e9bc4994553amw * property
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method calculate
3db3f65c6274eb042354801a308c8e9bc4994553amw * @param o optional options object
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw calculate: function(o) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (o || this.dirty) {
3db3f65c6274eb042354801a308c8e9bc4994553amw this._config(o);
3db3f65c6274eb042354801a308c8e9bc4994553amw this._setup();
3db3f65c6274eb042354801a308c8e9bc4994553amw this._explode();
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.allowRollup) {
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown this._rollup();
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw this._reduce();
3db3f65c6274eb042354801a308c8e9bc4994553amw this._sort();
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this.dirty = false;
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
12b65585e720714b31036daaa2b30eb76014048eGordon Ross
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
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
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * @private
3db3f65c6274eb042354801a308c8e9bc4994553amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw _setup: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var info = this.moduleInfo, name, i, j;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // Create skin modules
3db3f65c6274eb042354801a308c8e9bc4994553amw for (name in info) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (info.hasOwnProperty(name)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var m = info[name];
3db3f65c6274eb042354801a308c8e9bc4994553amw if (m && m.skinnable) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var o=this.skin.overrides, smod;
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown if (o && o[name]) {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i=0; i<o[name].length; i=i+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw smod = this._addSkin(o[name][i], name);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross smod = this._addSkin(this.skin.defaultSkin, name);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross }
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross m.requires.push(smod);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross }
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var l = Y.merge(this.inserted); // shallow clone
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // available modules
3db3f65c6274eb042354801a308c8e9bc4994553amw if (!this.ignoreRegistered) {
3db3f65c6274eb042354801a308c8e9bc4994553amw Y.mix(l, YUI.Env.mods);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // add the ignore list to the list of loaded packages
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.ignore) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // OU.appendArray(l, this.ignore);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross Y.mix(l, Y.Array.hash(this.ignore));
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // expand the list to include superseded modules
3db3f65c6274eb042354801a308c8e9bc4994553amw for (j in l) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (l.hasOwnProperty(j)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw Y.mix(l, this.getProvides(j));
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // remove modules on the force list from the loaded list
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.force) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for (i=0; i<this.force.length; i=i+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.force[i] in l) {
3db3f65c6274eb042354801a308c8e9bc4994553amw delete l[this.force[i]];
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this.loaded = l;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
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
3db3f65c6274eb042354801a308c8e9bc4994553amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw _explode: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var r=this.required, i, mod;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in r) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (r.hasOwnProperty(i)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw mod = this.getModule(i);
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var req = this.getRequires(mod);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (req) {
3db3f65c6274eb042354801a308c8e9bc4994553amw Y.mix(r, Y.Array.hash(req));
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw getModule: function(name) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var m = this.moduleInfo[name];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // create the default module
3db3f65c6274eb042354801a308c8e9bc4994553amw // if (!m) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // m = this.addModule({ext: false}, name);
3db3f65c6274eb042354801a308c8e9bc4994553amw // }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw return m;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
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
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
3db3f65c6274eb042354801a308c8e9bc4994553amw _rollup: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw var i, j, m, s, rollups={}, r=this.required, roll,
3db3f65c6274eb042354801a308c8e9bc4994553amw info = this.moduleInfo;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // find and cache rollup modules
3db3f65c6274eb042354801a308c8e9bc4994553amw if (this.dirty || !this.rollups) {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in info) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (info.hasOwnProperty(i)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(i);
3db3f65c6274eb042354801a308c8e9bc4994553amw // if (m && m.rollup && m.supersedes) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (m && m.rollup) {
3db3f65c6274eb042354801a308c8e9bc4994553amw rollups[i] = m;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this.rollups = rollups;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // make as many passes as needed to pick up rollup rollups
3db3f65c6274eb042354801a308c8e9bc4994553amw for (;;) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var rolled = false;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // go through the rollup candidates
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in rollups) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (rollups.hasOwnProperty(i)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // there can be only one
3db3f65c6274eb042354801a308c8e9bc4994553amw if (!r[i] && !this.loaded[i]) {
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(i);
3db3f65c6274eb042354801a308c8e9bc4994553amw s = m.supersedes || [];
3db3f65c6274eb042354801a308c8e9bc4994553amw roll = false;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // @TODO remove continue
3db3f65c6274eb042354801a308c8e9bc4994553amw if (!m.rollup) {
3db3f65c6274eb042354801a308c8e9bc4994553amw continue;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var c=0;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // check the threshold
3db3f65c6274eb042354801a308c8e9bc4994553amw for (j=0;j<s.length;j=j+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
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 roll = false;
3db3f65c6274eb042354801a308c8e9bc4994553amw break;
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 c++;
3db3f65c6274eb042354801a308c8e9bc4994553amw roll = (c >= m.rollup);
3db3f65c6274eb042354801a308c8e9bc4994553amw if (roll) {
3db3f65c6274eb042354801a308c8e9bc4994553amw break;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (roll) {
3db3f65c6274eb042354801a308c8e9bc4994553amw // add the rollup
3db3f65c6274eb042354801a308c8e9bc4994553amw r[i] = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw rolled = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // expand the rollup's dependencies
3db3f65c6274eb042354801a308c8e9bc4994553amw this.getRequires(m);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // if we made it here w/o rolling up something, we are done
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!rolled) {
3db3f65c6274eb042354801a308c8e9bc4994553amw break;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
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 */
3db3f65c6274eb042354801a308c8e9bc4994553amw _reduce: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var i, j, s, m, r=this.required;
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i in r) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (r.hasOwnProperty(i)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // remove if already loaded
3db3f65c6274eb042354801a308c8e9bc4994553amw if (i in this.loaded) {
3db3f65c6274eb042354801a308c8e9bc4994553amw delete r[i];
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // remove anything this module supersedes
3db3f65c6274eb042354801a308c8e9bc4994553amw } else {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw m = this.getModule(i);
3db3f65c6274eb042354801a308c8e9bc4994553amw s = m && m.supersedes;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (s) {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (j=0; j<s.length; j=j+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (s[j] in r) {
3db3f65c6274eb042354801a308c8e9bc4994553amw delete r[s[j]];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw _attach: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw
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 Y._attach(this.attaching);
3db3f65c6274eb042354801a308c8e9bc4994553amw } else {
3db3f65c6274eb042354801a308c8e9bc4994553amw Y._attach(this.sorted);
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this._pushEvents();
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw _onSuccess: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this._attach();
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var skipped = this.skipped;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw for (var i in skipped) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (skipped.hasOwnProperty(i)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw delete this.inserted[i];
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this.skipped = {};
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // this.fire('success', {
3db3f65c6274eb042354801a308c8e9bc4994553amw // data: this.data
3db3f65c6274eb042354801a308c8e9bc4994553amw // });
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var f = this.onSuccess;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (f) {
3db3f65c6274eb042354801a308c8e9bc4994553amw f.call(this.context, {
3db3f65c6274eb042354801a308c8e9bc4994553amw msg: 'success',
3db3f65c6274eb042354801a308c8e9bc4994553amw data: this.data,
3db3f65c6274eb042354801a308c8e9bc4994553amw success: true
3db3f65c6274eb042354801a308c8e9bc4994553amw });
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown },
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown
3db3f65c6274eb042354801a308c8e9bc4994553amw _onFailure: function(msg) {
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown this._attach();
3db3f65c6274eb042354801a308c8e9bc4994553amw // this.fire('failure', {
3db3f65c6274eb042354801a308c8e9bc4994553amw // msg: 'operation failed: ' + msg,
3db3f65c6274eb042354801a308c8e9bc4994553amw // data: this.data
3db3f65c6274eb042354801a308c8e9bc4994553amw // });
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw var f = this.onFailure;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (f) {
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States f.call(this.context, {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw msg: 'failure: ' + msg,
3db3f65c6274eb042354801a308c8e9bc4994553amw data: this.data,
3db3f65c6274eb042354801a308c8e9bc4994553amw success: false
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw });
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw _onTimeout: function() {
3db3f65c6274eb042354801a308c8e9bc4994553amw this._attach();
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // this.fire('timeout', {
3db3f65c6274eb042354801a308c8e9bc4994553amw // data: this.data
3db3f65c6274eb042354801a308c8e9bc4994553amw // });
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw var f = this.onTimeout;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (f) {
3db3f65c6274eb042354801a308c8e9bc4994553amw f.call(this.context, {
3db3f65c6274eb042354801a308c8e9bc4994553amw msg: 'timeout',
3db3f65c6274eb042354801a308c8e9bc4994553amw data: this.data,
3db3f65c6274eb042354801a308c8e9bc4994553amw success: false
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States });
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw },
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw /**
3db3f65c6274eb042354801a308c8e9bc4994553amw * Sorts the dependency tree. The last step of calculate()
3db3f65c6274eb042354801a308c8e9bc4994553amw * @method _sort
3db3f65c6274eb042354801a308c8e9bc4994553amw * @private
3db3f65c6274eb042354801a308c8e9bc4994553amw */
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 me = this;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // returns true if b is not loaded, and is required
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown // directly or by means of modules it supersedes.
3db3f65c6274eb042354801a308c8e9bc4994553amw var requires = function(aa, bb) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var mm=info[aa];
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (loaded[bb] || !mm) {
3db3f65c6274eb042354801a308c8e9bc4994553amw return false;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var ii, rr = mm.expanded,
3db3f65c6274eb042354801a308c8e9bc4994553amw after = mm.after, other=info[bb];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
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 }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // check if this module should be sorted after the other
3db3f65c6274eb042354801a308c8e9bc4994553amw if (after && Y.Array.indexOf(after, bb) > -1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw return true;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // check if this module requires one the other supersedes
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw var ss=info[bb] && info[bb].supersedes;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (ss) {
3db3f65c6274eb042354801a308c8e9bc4994553amw for (ii=0; ii<ss.length; ii=ii+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (requires(aa, ss[ii])) {
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown return true;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
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;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return false;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw };
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // pointer to the first unsorted item
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw var p=0;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
3db3f65c6274eb042354801a308c8e9bc4994553amw // keep going until we make a pass without moving anything
3db3f65c6274eb042354801a308c8e9bc4994553amw for (;;) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw var l=s.length, a, b, j, k, moved=false;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // start the loop after items that are already sorted
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for (j=p; j<l; j=j+1) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // check the next module on the list to see if its
3db3f65c6274eb042354801a308c8e9bc4994553amw // dependencies have been met
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw a = s[j];
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // check everything below current item and move if we
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // find a requirement for the current item
3db3f65c6274eb042354801a308c8e9bc4994553amw for (k=j+1; k<l; k=k+1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if (requires(a, s[k])) {
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // extract the dependency so we can move it up
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw b = s.splice(k, 1);
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // insert the dependency above the item that
3db3f65c6274eb042354801a308c8e9bc4994553amw // requires it
3db3f65c6274eb042354801a308c8e9bc4994553amw s.splice(j, 0, b[0]);
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw moved = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw break;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // jump out of loop if we moved something
3db3f65c6274eb042354801a308c8e9bc4994553amw if (moved) {
3db3f65c6274eb042354801a308c8e9bc4994553amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // this item is sorted, move our pointer and keep going
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
3db3f65c6274eb042354801a308c8e9bc4994553amw p = p + 1;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // when we make it here and moved is false, we are
3db3f65c6274eb042354801a308c8e9bc4994553amw // finished sorting
3db3f65c6274eb042354801a308c8e9bc4994553amw if (!moved) {
3db3f65c6274eb042354801a308c8e9bc4994553amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw this.sorted = s;
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
7b6a044acdb057a3bcb993c4abd028d0f35595bbjose borrego /**
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 */
3db3f65c6274eb042354801a308c8e9bc4994553amw insert: function(o, type) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // build the dependency list
3db3f65c6274eb042354801a308c8e9bc4994553amw this.calculate(o);
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (!type) {
3db3f65c6274eb042354801a308c8e9bc4994553amw var self = this;
3db3f65c6274eb042354801a308c8e9bc4994553amw this._internalCallback = function() {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw self._internalCallback = null;
3db3f65c6274eb042354801a308c8e9bc4994553amw self.insert(null, JS);
3db3f65c6274eb042354801a308c8e9bc4994553amw };
3db3f65c6274eb042354801a308c8e9bc4994553amw this.insert(null, CSS);
3db3f65c6274eb042354801a308c8e9bc4994553amw return;
3db3f65c6274eb042354801a308c8e9bc4994553amw }
3db3f65c6274eb042354801a308c8e9bc4994553amw
7b6a044acdb057a3bcb993c4abd028d0f35595bbjose borrego // set a flag to indicate the load has started
7b6a044acdb057a3bcb993c4abd028d0f35595bbjose borrego this._loading = true;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // flag to indicate we are done with the combo service
3db3f65c6274eb042354801a308c8e9bc4994553amw // and any additional files will need to be loaded
3db3f65c6274eb042354801a308c8e9bc4994553amw // individually
3db3f65c6274eb042354801a308c8e9bc4994553amw this._combineComplete = {};
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // keep the loadType (js, css or undefined) cached
7b6a044acdb057a3bcb993c4abd028d0f35595bbjose borrego this.loadType = type;
3db3f65c6274eb042354801a308c8e9bc4994553amw
3db3f65c6274eb042354801a308c8e9bc4994553amw // start the load
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw this.loadNext();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw },
3db3f65c6274eb042354801a308c8e9bc4994553amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /**
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 * one)
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai */
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai loadNext: function(mname) {
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai
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 if (!this._loading) {
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai return;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai }
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai var s, len, i, m, url, self=this, type=this.loadType, fn;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai
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
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai this._combining = [];
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai s=this.sorted;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai len=s.length;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai url=this.comboBase;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai for (i=0; i<len; i=i+1) {
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai m = this.getModule(s[i]);
// @TODO we can't combine CSS yet until we deliver files with absolute paths to the assets
// Do not try to combine non-yui JS
if (m && m.type === this.loadType && !m.ext) {
url += this.root + m.path;
if (i < len-1) {
url += '&';
}
this._combining.push(s[i]);
}
}
if (this._combining.length) {
var callback=function(o) {
this._combineComplete[type] = true;
var c=this._combining, len=c.length, i, m;
for (i=0; i<len; i=i+1) {
this.inserted[c[i]] = true;
}
this.loadNext(o.data);
};
fn =(type === CSS) ? Y.Get.css : Y.Get.script;
// @TODO get rid of the redundant Get code
fn(this._filter(url), {
data: this._loading,
onSuccess: callback,
onFailure: this._onFailure,
onTimeout: this._onTimeout,
insertBefore: this.insertBefore,
charset: this.charset,
timeout: this.timeout,
context: self
});
return;
} else {
this._combineComplete[type] = true;
}
}
if (mname) {
// if the module that was just loaded isn't what we were expecting,
// continue to wait
if (mname !== this._loading) {
return;
}
// 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
this.inserted[mname] = true;
// this.fire('progress', {
// name: mname,
// data: this.data
// });
if (this.onProgress) {
this.onProgress.call(this.context, {
name: mname,
data: this.data
});
}
}
s=this.sorted;
len=s.length;
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.
if (s[i] in this.inserted) {
continue;
}
// 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
if (s[i] === this._loading) {
return;
}
// log("inserting " + s[i]);
m = this.getModule(s[i]);
if (!m) {
var msg = "Undefined module " + s[i] + " skipped";
this.inserted[s[i]] = true;
this.skipped[s[i]] = true;
continue;
// this.fire('failure', {
// msg: msg,
// data: this.data
// });
}
// The load type is stored to offer the possibility to load
// the css separately from the script.
if (!type || type === m.type) {
this._loading = s[i];
fn = (m.type === CSS) ? Y.Get.css : Y.Get.script;
var onsuccess=function(o) {
self.loadNext(o.data);
};
url = (m.fullpath) ? this._filter(m.fullpath) : this._url(m.path, s[i]);
fn(url, {
data: s[i],
onSuccess: onsuccess,
insertBefore: this.insertBefore,
charset: this.charset,
onFailure: this._onFailure,
onTimeout: this._onTimeout,
timeout: this.timeout,
context: self
});
return;
}
}
// we are finished
this._loading = null;
fn = this._internalCallback;
// internal callback for loading css first
if (fn) {
this._internalCallback = null;
fn.call(this);
// } else if (this.onSuccess) {
} else {
// call Y.use passing this instance. Y will use the sorted
// dependency list.
this._onSuccess();
}
},
/**
* In IE, the onAvailable/onDOMReady events need help when Event is
* loaded dynamically
* @method _pushEvents
* @param {Function} optional function reference
* @private
*/
_pushEvents: function() {
if (Y.Event) {
Y.Event._load();
}
},
/**
* Apply filter defined for this instance to a url/path
* method _filter
* @param u {string} the string to filter
* @return {string} the filtered string
* @private
*/
_filter: function(u) {
var f = this.filter;
if (u && f) {
var useFilter = true;
if (this.filterName == "DEBUG") {
var exc = this.logExclude,
inc = this.logInclude;
if (inc && !(name in inc)) {
useFilter = false;
} else if (exc && (name in exc)) {
useFilter = false;
}
}
if (useFilter) {
u = u.replace(new RegExp(f.searchExp, 'g'), f.replaceStr);
}
}
return u;
},
/**
* Generates the full url for a module
* method _url
* @param path {string} the path fragment
* @return {string} the full url
* @private
*/
_url: function(path, name) {
return this._filter((this.base || "") + path);
}
};
// Y.augment(Y.Loader, Y.Event.Target);
}, '@VERSION@' );