yui.js revision 736ba5f7cc5cf8d479f8fc621ff3c0777e434c8a
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 el.addEventListener(type, fn, (!!capture));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // YUI.log('could not attach DOM event listener: ' + type + ' to ' + el);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich remove = function (el, type, fn, capture) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich el.removeEventListener(type, fn, !!capture);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich// @TODO: this needs to be created at build time from module metadata
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// reduce to one or the other
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 * @constructor
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 /*global YUI*/
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich /*global YUI_config*/
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // @TODO Advice was to make a function, disallow direct instantiation.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var Y = this, a = arguments, i, l = a.length,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich globalConfig = (typeof YUI_config !== 'undefined') && YUI_config;
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Allow instantiation without the new operator
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (!(Y instanceof YUI)) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // set up the core environment
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i=0; i<l; i++) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // bind the specified additional modules for this instance
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 Rabinovich _config: function(o) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i in o) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (j in m) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else if (i == 'win') {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich c[i] = o[i].contentWindow || o[i];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Initialize this YUI instance
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // find targeted window/frame
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // @TODO create facades
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // @todo expand the new module metadata
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich cdn: 'http://yui.yahooapis.com/' + v + '/build/',
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.Env._guidp = ('yui_' + v + '-' + Y.Env._yidx + '-' + _startTime).replace(/\./g, '_');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // configuration defaults
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // base: (Y === YUI) ? Y.Env.cdn : function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich base: (YUI.config && YUI.config.base) || function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // get from querystring
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich nodes = (doc && doc.getElementsByTagName('script')) || [];
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 match = src.match(/^(.*)yui\/yui([\.\-].*)js(\?.*)?$/);
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// 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 // use CDN default
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loaderPath: (YUI.config && YUI.config.loaderPath) || 'loader/loader' + (filter || '-min.') + 'js'
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 _setup: function(o) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var Y = this,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich extras = Y.config.core || ['get', 'loader', 'yui-log', 'yui-later'];
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log(Y.id + ' initialized', 'info', 'yui');
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 this.log(method + ': applyTo not allowed', 'warn', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this.log('applyTo not found: ' + method, 'warn', 'yui');
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 * omit - features that should not be loaded if this module is present
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @return {YUI} the YUI instance
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 return this; // chain support
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // console.log(name + '::' + m);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // if (!m) { }
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // console.log(req);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // console.log(use);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // this.log('attaching ' + name, 'info', 'yui');
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 * 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 * 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 * @return {YUI} the YUI instance
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich use: function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this._useQueue = this._useQueue || new this.Queue();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich this._useQueue.add(SLICE.call(arguments, 0));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich var Y = this,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich k, i, l, missing = [],
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich f = function(name) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // only attach a module once
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log(name + ' already used', 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('USING ' + name, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // CSS files don't register themselves, see if it has been loaded
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('module not found: ' + name, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // probably css
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('module not found BUT HAS BEEN LOADED: ' + name, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // make sure requirements are attached
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('using module\'s requirements: ' + name, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // add this module to full list of things to attach
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('adding to requires list: ' + name);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log(Y.id + ': use called: ' + a + ' :: ' + callback);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // The last argument supplied to use can be a load complete callback
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('Use complete');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // process queued use requests as long until done
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // or dynamic load happens again.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (Y._useQueue && Y._useQueue.size() && !Y._loading) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // YUI().use('*'); // bind everything available
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('loader before: ' + a.join(','));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // use loader to expand dependencies and sort the
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // requirements if it is available.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // loader.calculate(null, (css && css == 'force') ? null : 'js');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // loader.calculate();
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich loader.calculate(null, (css) ? null : 'js');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // Y.log('loader after: ' + a.join(','));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // process each requirement and any additional requirements
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // the module metadata specifies
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Module requirements: ' + a, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich missing = Y.Object.keys(Y.Array.hash(missing));
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Modules missing: ' + missing, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // dynamic load
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Using loader to fetch missing dependencies.', 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // loader.require(missing);
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich } else if (boot && l && Y.Get && !Y.Env.bootstrapped) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich onEnd = function() {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Waiting for loader: ' + Y.id, 'info', 'yui');
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 Y.message('Unable or not configured to fetch missing modules: ' + missing, 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich Y.log('Attaching available dependencies.', 'info', 'yui');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich return Y; // chain support var yui = YUI().use('dragdrop');
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Returns the namespace specified and creates it if it doesn't exist
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI.namespace("property.package");
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * YUI.namespace("YAHOO.property.package");
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 * 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 * YUI.namespace("really.long.nested.namespace");
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * This fails because "long" is a future reserved word in ECMAScript
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 var a=arguments, o=null, i, j, d;
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 // this is replaced if the log module is included
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich log: function() {
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 this.message(msg, "error"); // don't scrub this one
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 var id = this.Env._guidp + (++this.Env._uidx);
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 var uid = (typeof o === 'string') ? o : o._yuid;
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 // inheritance utilities are not available yet
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich for (i in p) {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich if (1) { // intenionally ignoring hasOwnProperty check
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich // set up the environment
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 * 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 * @class config
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Allows the YUI seed file to fetch the loader component and library
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * metadata to dynamically load additional dependencies.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property bootstrap
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type boolean
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default true
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Log to the browser console if debug is on and the browser has a
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * supported console.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property useBrowserConsole
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type boolean
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default true
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A hash of log sources that should be logged. If specified, only log messages from these sources will be logged.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property logInclude
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type object
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 * @property logExclude
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type object
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 * @property injected
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type object
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * If throwFail is set, Y.fail will generate or re-throw a JS Error. Otherwise the failure is logged.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property throwFail
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type boolean
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default true
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The window/frame that this instance should operate in.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property win
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type Window
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default the window hosting YUI
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The document associated with the 'win' configuration.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property doc
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type Document
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default the document hosting YUI
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A list of modules that defines the YUI core (overrides the default).
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property core
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string[]
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The default date format
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property dateFormat
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The default locale
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property locale
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The default interval when polling in milliseconds.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property pollInterval
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default 20
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 * @property purgethreshold
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default 20
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The default interval when polling in milliseconds.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property windowResizeDelay
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default 40
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Base directory for dynamic loading
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property base
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The secure base dir (not implemented)
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property secureBase
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property comboBase
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * The root path to prepend to module names for the combo service. Ex: 3.0.0b1/build/
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property root
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
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 * <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 * 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 * myFilter: {
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * 'searchExp': "-min\\.js",
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * 'replaceStr': "-debug.js"
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property filter
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string|object
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Hash of per-component filter specification. If specified for a given component,
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * this overrides the filter config
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property filters
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type object
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * Use the YUI combo service to reduce the number of http connections
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * required to load your dependencies.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * For dynamic loading.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property combine
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type boolean
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @default true if 'base' is not supplied, false if it is.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A list of modules that should never be dynamically loaded
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property ignore
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string[]
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * A list of modules that should always be loaded when required, even if already
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * present on the page.
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @property force
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string[]
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 * @property insertBefore
fc85028e135879c5ba1824dde83c71c11e372711Allen Rabinovich * @type string
* @default loader/loader-min.js