yui.js revision 736ba5f7cc5cf8d479f8fc621ff3c0777e434c8a
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The YUI module contains the components required for building the YUI seed file.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * This includes the script loading mechanism, a simple queue, and the core utilities for the library.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @module yui
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @submodule yui-base
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich(function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var doc = document,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich docEl = doc && doc.documentElement,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich docElClass = docEl && docEl.className,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich DOCUMENT_CLASS = 'yui-js-enabled',
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _instances = {},
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _startTime = new Date().getTime(),
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich p,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich i,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich add = function(el, type, fn, capture) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (el && el.addEventListener) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich el.addEventListener(type, fn, (!!capture));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else if (el && el.attachEvent) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich el.attachEvent("on" + type, fn);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // YUI.log('could not attach DOM event listener: ' + type + ' to ' + el);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich remove = function (el, type, fn, capture) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (el && el.removeEventListener) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich el.removeEventListener(type, fn, !!capture);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else if (el && el.detachEvent) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich el.detachEvent("on" + type, fn);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich globalListener = function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI.Env.windowLoaded = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI.Env.DOMReady = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich remove(window, 'load', globalListener);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// @TODO: this needs to be created at build time from module metadata
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _APPLY_TO_WHITE_LIST = {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich 'io.xdrReady': 1,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich 'io.xdrResponse':1,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich 'SWF.eventHandler':1
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich SLICE = Array.prototype.slice;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// Stamp the documentElement (HTML) with a class of "yui-loaded" to
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// enable styles that need to key off of JS being enabled.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovichif (docEl && docElClass.indexOf(DOCUMENT_CLASS) == -1) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (docElClass) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich docElClass += ' ';
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich docElClass += DOCUMENT_CLASS;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich docEl.className = docElClass;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich}
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// reduce to one or the other
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovichif (typeof YUI === 'undefined' || !YUI) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The YUI global namespace object. If YUI is already defined, the
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * existing YUI object will not be overwritten so that defined
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * namespaces are preserved.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @class YUI
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @constructor
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @global
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @uses EventTarget
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param o* Up to five optional configuration objects. This object is stored
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * in YUI.config. See config for the list of supported properties.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /*global YUI*/
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /*global YUI_config*/
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // @TODO Advice was to make a function, disallow direct instantiation.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI = function(o1, o2, o3, o4, o5) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var Y = this, a = arguments, i, l = a.length,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich globalConfig = (typeof YUI_config !== 'undefined') && YUI_config;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Allow instantiation without the new operator
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (!(Y instanceof YUI)) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return new YUI(o1, o2, o3, o4, o5);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // set up the core environment
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._init();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (globalConfig) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._config(globalConfig);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i=0; i<l; i++) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._config(a[i]);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // bind the specified additional modules for this instance
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._setup();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return Y;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich };
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich}
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// The prototype contains the functions that are required to allow the external
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// modules to be registered and for the instance to be initialized.
fc85028e135879c5ba1824dde83c71c11e372711Allen RabinovichYUI.prototype = {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _config: function(o) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich o = o || {};
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var c = this.config, i, j, m, mods;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich mods = c.modules;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i in o) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (mods && i == 'modules') {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich m = o[i];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (j in m) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (m.hasOwnProperty(j)) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich mods[j] = m[j];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else if (i == 'win') {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich c[i] = o[i].contentWindow || o[i];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich c.doc = c[i].document;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich c[i] = o[i];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Initialize this YUI instance
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @private
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _init: function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // find targeted window/frame
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // @TODO create facades
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var v = '@VERSION@', Y = this, filter;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (v.indexOf('@') > -1) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich v = 'test';
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.version = v;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.Env = Y.Env || {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // @todo expand the new module metadata
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich mods: {},
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich cdn: 'http://yui.yahooapis.com/' + v + '/build/',
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich bootstrapped: false,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _idx: 0,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _used: {},
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _attached: {},
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _yidx: 0,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _uidx: 0,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _loaded: {}
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich };
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.Env._loaded[v] = {};
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (YUI.Env && Y !== YUI) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.Env._yidx = (++YUI.Env._yidx);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.Env._guidp = ('yui_' + v + '-' + Y.Env._yidx + '-' + _startTime).replace(/\./g, '_');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _instances[Y.id] = Y;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.id = Y.stamp(Y);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.constructor = YUI;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // configuration defaults
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.config = Y.config || {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich win: window || {},
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich doc: doc,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich debug: true,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich useBrowserConsole: true,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich throwFail: true,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich bootstrap: true,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich fetchCSS: true,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // base: (Y === YUI) ? Y.Env.cdn : function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich base: (YUI.config && YUI.config.base) || function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var b, nodes, i, src, match;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // get from querystring
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich nodes = (doc && doc.getElementsByTagName('script')) || [];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i=0; i<nodes.length; i=i+1) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich src = nodes[i].src;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (src) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// DEBUG
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich//src = "http://yui.yahooapis.com/combo?2.8.0r4/build/yuiloader-dom-event/yuiloader-dom-event.js&3.0.0/build/yui/yui-min.js";
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich//console.log('src) ' + src);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// DEBUG
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich match = src.match(/^(.*)yui\/yui([\.\-].*)js(\?.*)?$/);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich b = match && match[1];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (b) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // this is to set up the path to the loader. The file filter for loader should match
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // the yui include.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich filter = match[2];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// extract correct path for mixed combo urls
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// http://yuilibrary.com/projects/yui3/ticket/2528423
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// http://yui.yahooapis.com/combo?2.8.0r4/build/yuiloader-dom-event/yuiloader-dom-event.js&3.0.0/build/yui/yui-min.js
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich match = src.match(/^(.*\?)(.*\&)(.*)yui\/yui[\.\-].*js(\?.*)?$/);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (match && match[3]) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich b = match[1] + match[3];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich break;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // use CDN default
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return b || Y.Env.cdn;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }(),
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loaderPath: (YUI.config && YUI.config.loaderPath) || 'loader/loader' + (filter || '-min.') + 'js'
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich };
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Finishes the instance setup. Attaches whatever modules were defined
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * when the yui modules was registered.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @method _setup
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @private
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _setup: function(o) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var Y = this,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich core = [],
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich mods = YUI.Env.mods,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich extras = Y.config.core || ['get', 'loader', 'yui-log', 'yui-later'];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i=0; i<extras.length; i++) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (mods[extras[i]]) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich core.push(extras[i]);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.use('yui-base');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.use.apply(Y, core);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log(Y.id + ' initialized', 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Executes a method on a YUI instance with
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * the specified id if the specified method is whitelisted.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @method applyTo
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param id {string} the YUI instance id
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param method {string} the name of the method to exectute.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Ex: 'Object.keys'
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param args {Array} the arguments to apply to the method
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @return {object} the return value from the applied method or null
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich applyTo: function(id, method, args) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (!(method in _APPLY_TO_WHITE_LIST)) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this.log(method + ': applyTo not allowed', 'warn', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return null;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var instance = _instances[id], nest, m, i;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (instance) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich nest = method.split('.');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich m = instance;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i=0; i<nest.length; i=i+1) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich m = m[nest[i]];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (!m) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this.log('applyTo not found: ' + method, 'warn', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return m.apply(instance, args);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return null;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Register a module
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @method add
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param name {string} module name
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param fn {Function} entry point into the module that
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * is used to bind module to the YUI instance
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param version {string} version string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param details optional config data:
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * requires - features that should be present before loading
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * optional - optional features that should be present if load optional defined
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * use - features that should be attached automatically
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * skinnable -
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * rollup
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * omit - features that should not be loaded if this module is present
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @return {YUI} the YUI instance
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich add: function(name, fn, version, details) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // this.log('Adding a new component ' + name);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // @todo expand this to include version mapping
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // @todo may want to restore the build property
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // @todo fire moduleAvailable event
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI.Env.mods[name] = {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich name: name,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich fn: fn,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich version: version,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich details: details || {}
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich };
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return this; // chain support
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich _attach: function(r, fromLoader) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var mods = YUI.Env.mods,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich attached = this.Env._attached,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich i, l = r.length, name, m, d, req, use;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i=0; i<l; i=i+1) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich name = r[i];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich m = mods[name];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // console.log(name + '::' + m);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // if (!m) { }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (!attached[name] && m) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich attached[name] = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich d = m.details;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich req = d.requires;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich use = d.use;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // console.log(req);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // console.log(use);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (req) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this._attach(this.Array(req));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // this.log('attaching ' + name, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (m.fn) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich m.fn(this);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (use) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this._attach(this.Array(use));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Bind a module to a YUI instance
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param modules* {string} 1-n modules to bind (uses arguments array)
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param *callback {function} callback function executed when
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * the instance has the required functionality. If included, it
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * must be the last parameter.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @TODO
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Implement versioning? loader can load different versions?
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Should sub-modules/plugins be normal modules, or do
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * we add syntax for specifying these?
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI().use('dragdrop')
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI().use('dragdrop:2.4.0'); // specific version
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI().use('dragdrop:2.4.0-'); // at least this version
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI().use('dragdrop:2.4.0-2.9999.9999'); // version range
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI().use('*'); // use all available modules
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI().use('lang+dump+substitute'); // use lang and some plugins
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI().use('lang+*'); // use lang and all known plugins
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @return {YUI} the YUI instance
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich use: function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (this._loading) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this._useQueue = this._useQueue || new this.Queue();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this._useQueue.add(SLICE.call(arguments, 0));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return this;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var Y = this,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich a=SLICE.call(arguments, 0),
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich mods = YUI.Env.mods,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich used = Y.Env._used,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich onEnd,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich firstArg = a[0],
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich dynamic = false,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich callback = a[a.length-1],
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich boot = Y.config.bootstrap,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich k, i, l, missing = [],
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich r = [],
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich css = Y.config.fetchCSS,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich f = function(name) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // only attach a module once
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (used[name]) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log(name + ' already used', 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var m = mods[name], j, req, use;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (m) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('USING ' + name, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich used[name] = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich req = m.details.requires;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich use = m.details.use;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // CSS files don't register themselves, see if it has been loaded
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (!YUI.Env._loaded[Y.version][name]) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('module not found: ' + name, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich missing.push(name);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // probably css
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('module not found BUT HAS BEEN LOADED: ' + name, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich used[name] = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // make sure requirements are attached
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (req) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (Y.Lang.isString(req)) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich f(req);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (j = 0; j < req.length; j = j + 1) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('using module\'s requirements: ' + name, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich f(req[j]);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // add this module to full list of things to attach
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('adding to requires list: ' + name);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich r.push(name);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich onComplete;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log(Y.id + ': use called: ' + a + ' :: ' + callback);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // The last argument supplied to use can be a load complete callback
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (typeof callback === 'function') {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich a.pop();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich callback = null;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich onComplete = function(fromLoader) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('Use complete');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich fromLoader = fromLoader || {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich success: true,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich msg: 'not dynamic'
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich };
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (callback) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich callback(Y, fromLoader);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (Y.fire) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.fire('yui:load', Y, fromLoader);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // process queued use requests as long until done
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // or dynamic load happens again.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._loading = false;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (Y._useQueue && Y._useQueue.size() && !Y._loading) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.use.apply(Y, Y._useQueue.next());
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich };
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // YUI().use('*'); // bind everything available
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (firstArg === "*") {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich a = [];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (k in mods) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (mods.hasOwnProperty(k)) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich a.push(k);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (callback) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich a.push(callback);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return Y.use.apply(Y, a);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('loader before: ' + a.join(','));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // use loader to expand dependencies and sort the
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // requirements if it is available.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (Y.Loader) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich dynamic = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader = new Y.Loader(Y.config);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.require(a);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.ignoreRegistered = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.allowRollup = false;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // loader.calculate(null, (css && css == 'force') ? null : 'js');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // loader.calculate();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.calculate(null, (css) ? null : 'js');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich a = loader.sorted;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('loader after: ' + a.join(','));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich l = a.length;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // process each requirement and any additional requirements
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // the module metadata specifies
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i=0; i<l; i=i+1) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich f(a[i]);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich l = missing.length;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Module requirements: ' + a, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (l) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich missing = Y.Object.keys(Y.Array.hash(missing));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Modules missing: ' + missing, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // dynamic load
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (boot && l && Y.Loader) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Using loader to fetch missing dependencies.', 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._loading = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader = new Y.Loader(Y.config);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.onSuccess = onComplete;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.onFailure = onComplete;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.onTimeout = onComplete;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.context = Y;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.attaching = a;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // loader.require(missing);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.require((css) ? missing : a);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.insert(null, (css) ? null : 'js');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else if (boot && l && Y.Get && !Y.Env.bootstrapped) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._loading = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich a = Y.Array(arguments, 0, true);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich onEnd = function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._loading = false;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.Env.bootstrapped = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._attach(['loader']);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.use.apply(Y, a);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich };
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (YUI.Env._bootstrapping) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Waiting for loader: ' + Y.id, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI.Env._loaderQueue.add(onEnd);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI.Env._bootstrapping = true;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Fetching loader: ' + Y.id + ", " + Y.config.base + Y.config.loaderPath, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.Get.script(Y.config.base + Y.config.loaderPath, {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich onEnd: onEnd
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich });
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return Y;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (l) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.message('Unable or not configured to fetch missing modules: ' + missing, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Attaching available dependencies.', 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y._attach(r);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich onComplete();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return Y; // chain support var yui = YUI().use('dragdrop');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Returns the namespace specified and creates it if it doesn't exist
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * <pre>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI.namespace("property.package");
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI.namespace("YAHOO.property.package");
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * </pre>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Either of the above would create YUI.property, then
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI.property.package (YAHOO is scrubbed out, this is
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * to remain compatible with YUI2)
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Be careful when naming packages. Reserved words may work in some browsers
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * and not others. For instance, the following will fail in Safari:
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * <pre>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI.namespace("really.long.nested.namespace");
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * </pre>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * This fails because "long" is a future reserved word in ECMAScript
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @method namespace
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param {string*} arguments 1-n namespaces to create
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @return {object} A reference to the last namespace object created
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich namespace: function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var a=arguments, o=null, i, j, d;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i=0; i<a.length; i=i+1) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich d = ("" + a[i]).split(".");
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich o = this;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; j=j+1) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich o[d[j]] = o[d[j]] || {};
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich o = o[d[j]];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return o;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // this is replaced if the log module is included
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich log: function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Report an error. The reporting mechanism is controled by
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * the 'throwFail' configuration attribute. If throwFail is
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * not specified, the message is written to the Logger, otherwise
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * a JS error is thrown
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @method error
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param msg {string} the error message
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param e {Error} Optional JS error that was caught. If supplied
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * and throwFail is specified, this error will be re-thrown.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @return {YUI} this YUI instance
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich error: function(msg, e) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (this.config.throwFail) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich throw (e || new Error(msg));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this.message(msg, "error"); // don't scrub this one
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return this;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Generate an id that is unique among all YUI instances
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @method guid
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param pre {string} optional guid prefix
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @return {string} the guid
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich guid: function(pre) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var id = this.Env._guidp + (++this.Env._uidx);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return (pre) ? (pre + id) : id;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich },
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Returns a guid associated with an object. If the object
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * does not have one, a new one is created unless readOnly
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * is specified.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @method stamp
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param o The object to stamp
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @param readOnly {boolean} if true, a valid guid will only
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * be returned if the object has one assigned to it.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @return {string} The object's guid or null
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich stamp: function(o, readOnly) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (!o) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return o;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var uid = (typeof o === 'string') ? o : o._yuid;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (!uid) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich uid = this.guid();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (!readOnly) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich try {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich o._yuid = uid;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } catch(e) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich uid = null;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return uid;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich};
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// Give the YUI global the same properties as an instance.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// This makes it so that the YUI global can be used like the YAHOO
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// global was used prior to 3.x. More importantly, the YUI global
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// provides global metadata, so env needs to be configured.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// @TODO review
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich p = YUI.prototype;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // inheritance utilities are not available yet
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i in p) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (1) { // intenionally ignoring hasOwnProperty check
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI[i] = p[i];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // set up the environment
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI._init();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI._attach(['yui-base']);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // add a window load event at load time so we can capture
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // the case where it fires before dynamic loading is
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // complete.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich add(window, 'load', globalListener);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI.Env.add = add;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich YUI.Env.remove = remove;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich})();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The config object contains all of the configuration options for
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * the YUI instance. This object is supplied by the implementer
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * when instantiating a YUI instance. Some properties have default
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * values if they are not supplied by the implementer.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @class config
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @static
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Allows the YUI seed file to fetch the loader component and library
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * metadata to dynamically load additional dependencies.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property bootstrap
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type boolean
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default true
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Log to the browser console if debug is on and the browser has a
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * supported console.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property useBrowserConsole
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type boolean
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default true
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A hash of log sources that should be logged. If specified, only log messages from these sources will be logged.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property logInclude
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type object
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A hash of log sources that should be not be logged. If specified, all sources are logged if not on this list.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property logExclude
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type object
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Set to true if the yui seed file was dynamically loaded in
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * order to bootstrap components relying on the window load event
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * and the 'domready' custom event.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property injected
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type object
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * If throwFail is set, Y.fail will generate or re-throw a JS Error. Otherwise the failure is logged.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property throwFail
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type boolean
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default true
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The window/frame that this instance should operate in.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property win
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type Window
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default the window hosting YUI
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The document associated with the 'win' configuration.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property doc
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type Document
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default the document hosting YUI
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A list of modules that defines the YUI core (overrides the default).
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property core
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string[]
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The default date format
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property dateFormat
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The default locale
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property locale
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The default interval when polling in milliseconds.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property pollInterval
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type int
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default 20
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The number of dynamic nodes to insert by default before
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * automatically removing them. This applies to script nodes
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * because remove the node will not make the evaluated script
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * unavailable. Dynamic CSS is not auto purged, because removing
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * a linked style sheet will also remove the style definitions.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property purgethreshold
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type int
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default 20
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The default interval when polling in milliseconds.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property windowResizeDelay
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type int
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default 40
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Base directory for dynamic loading
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property base
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The secure base dir (not implemented)
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property secureBase
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property comboBase
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The root path to prepend to module names for the combo service. Ex: 3.0.0b1/build/
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property root
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A filter to apply to result urls. This filter will modify the default
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * path for all modules. The default path for the YUI library is the
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * minified version of the files (e.g., event-min.js). The filter property
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * can be a predefined filter or a custom filter. The valid predefined
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * filters are:
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * <dl>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * <dt>DEBUG</dt>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * <dd>Selects the debug versions of the library (e.g., event-debug.js).
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * This option will automatically include the Logger widget</dd>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * <dt>RAW</dt>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * </dl>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * You can also define a custom filter, which must be an object literal
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * containing a search expression and a replace string:
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * <pre>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * myFilter: &#123;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * 'searchExp': "-min\\.js",
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * 'replaceStr': "-debug.js"
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * &#125;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * </pre>
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property filter
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string|object
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Hash of per-component filter specification. If specified for a given component,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * this overrides the filter config
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property filters
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type object
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Use the YUI combo service to reduce the number of http connections
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * required to load your dependencies.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property combine
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type boolean
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default true if 'base' is not supplied, false if it is.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A list of modules that should never be dynamically loaded
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property ignore
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string[]
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A list of modules that should always be loaded when required, even if already
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * present on the page.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property force
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string[]
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich/**
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Node or id for a node that should be used as the insertion point for new nodes
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich *
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property insertBefore
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich */
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich
/**
* charset for dynamic nodes
*
* @property charset
* @type string
* @deprecated use jsAttributes cssAttributes
*/
/**
* Object literal containing attributes to add to dynamically loaded script nodes.
*
* @property jsAttributes
* @type string
*/
/**
* Object literal containing attributes to add to dynamically loaded link nodes.
*
* @property cssAttributes
* @type string
*/
/**
* Number of milliseconds before a timeout occurs when dynamically
* loading nodes. If not set, there is no timeout.
*
* @property timeout
* @type int
*/
/**
* Callback for the 'CSSComplete' event. When dynamically loading YUI
* components with CSS, this property fires when the CSS is finished
* loading but script loading is still ongoing. This provides an
* opportunity to enhance the presentation of a loading page a little
* bit before the entire loading process is done.
*
* @property onCSS
* @type function
*/
/**
* A list of module definitions to add to the list of YUI components.
* These components can then be dynamically loaded side by side with
* YUI via the use() method.See Loader.addModule for the supported
* module metadata.
*
* @property modules
* @type function
*/
/**
* The loader 'path' attribute to the loader itself. This is combined
* with the 'base' attribute to dynamically load the loader component
* when boostrapping with the get utility alone.
*
* @property loaderPath
* @default loader/loader-min.js
*/
/*
*
* Specifies whether or not YUI().use(...) will attempt to load CSS
* resources at all. Any truthy value will cause CSS dependencies
* to load when fetching script. The special value 'force' will
* cause CSS dependencies to be loaded even if no script is needed.
*
* @property fetchCSS
* @default true
*/