yui.js revision 597ef788454679ec0e3e83990b8548dff7073ac7
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The YUI module contains the components required for building the YUI seed
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * file. This includes the script loading mechanism, a simple queue, and
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * the core utilities for the library.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @module yui
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @submodule yui-base
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * The YUI global namespace object. If YUI is already defined, the
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * existing YUI object will not be overwritten so that defined
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * namespaces are preserved. It is the constructor for the object
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * the end user interacts with. As indicated below, each instance
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * has full custom event support, but only if the event system
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * is available. This is a self-instantiable factory function. You
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * can invoke it directly like this:
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * YUI().use('*', function(Y) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * But it also works like this:
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * var Y = YUI();
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @constructor
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @uses EventTarget
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param o* {object} 0..n optional configuration objects. these values
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * are store in Y.config. See config for the list of supported
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * properties.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich /*global YUI*/
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich /*global YUI_config*/
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich var YUI = function() {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich return (o && o.hasOwnProperty && (o instanceof type));
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich gconf = (typeof YUI_config !== 'undefined') && YUI_config;
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // set up the core environment
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // YUI.GlobalConfig is a master configuration that might span
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // multiple contexts in a non-browser environment. It is applied
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // first to all instances in all contexts.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // YUI_Config is a page-level config. It is applied to all
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // instances created on the page. This is applied after
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // YUI.GlobalConfig, and before the instance level configuration
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // bind the specified additional modules for this instance
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // Each instance can accept one or more configuration objects.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // These are applied after YUI.GlobalConfig and YUI_Config,
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // overriding values set in those config files if there is a '
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // matching property.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich for (; i < l; i++) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich NOOP = function() {},
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich APPLY_TO_AUTH = { 'io.xdrReady': 1, // the functions applyTo
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich 'io.xdrResponse': 1, // can call. this should
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich 'SWF.eventHandler': 1 }, // be done at build time
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // this can throw an uncaught exception in FF
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich getLoader = function(Y, o) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich clobber = function(r, s) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich for (var i in s) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich// Stamp the documentElement (HTML) with a class of "yui-loaded" to
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich// enable styles that need to key off of JS being enabled.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovichif (docEl && docClass.indexOf(DOC_LABEL) == -1) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich VERSION = '3.2.0'; // dev time hack for cdn test
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * Applies a new configuration object to the YUI instance config.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * This will merge new group/module definitions, and will also
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * update the loader cache if necessary. Updating Y.config directly
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * will not update the cache.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @method applyConfig
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param {object} the configuration object.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @since 3.2.0
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // preserve the guid
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich _config: function(o) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * Initialize this YUI instance
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * The version number of the YUI instance.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @property version
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @type string
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // bootstrapped: false,
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // get from querystring
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich nodes = (doc && doc.getElementsByTagName('script')) || [];
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // this is to set up the path to the loader. The file
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // filter for loader should match the yui include.
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich // extract correct path for mixed combo urls
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich // http://yuilibrary.com/projects/yui3/ticket/2528423
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // use CDN default
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich Env._yidx + '_' + time).replace(/\./g, '_');
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich // configuration defaults
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich Y.Env.getBase(/^(.*)yui\/yui([\.\-].*)js(\?.*)?$/,
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich /^(.*\?)(.*\&)(.*)yui\/yui[\.\-].*js(\?.*)?$/);
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich if (!filter || (!('-min.-debug.').indexOf(filter))) {
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich Y.config.loaderPath = YUI.config.loaderPath ||
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich 'loader/loader' + (filter || '-min.') + 'js';
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * Finishes the instance setup. Attaches whatever modules were defined
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich * when the yui modules was registered.
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich * @method _setup
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich _setup: function(o) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich var i, Y = this,
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich 'yui-throttle'];
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * Executes a method on a YUI instance with
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * the specified id if the specified method is whitelisted.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @method applyTo
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param id {string} the YUI instance id.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param method {string} the name of the method to exectute.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * Ex: 'Object.keys'.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param args {Array} the arguments to apply to the method.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @return {object} the return value from the applied method or null.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich this.log(method + ': applyTo not allowed', 'warn', 'yui');
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich this.log('applyTo not found: ' + method, 'warn', 'yui');
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * Registers a module with the YUI global. The easiest way to create a
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * first-class YUI module is to use the YUI component build tool.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * The build system will produce the YUI.add wrapper for you module, along
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * with any configuration info required for the module.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method add
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param name {string} module name.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param fn {Function} entry point into the module that
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * is used to bind module to the YUI instance.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param version {string} version string.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param details {object} optional config data:
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * requires: features that must be present before this module can be
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * optional: optional features that should be present if loadOptional
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * is defined. Note: modules are not often loaded this way in YUI 3,
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * but this field is still useful to inform the user that certain
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * features in the component will require additional dependencies.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * use: features that are included within this module which need to
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * be attached automatically when this module is attached. This
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * supports the YUI 3 rollup system -- a module with submodules
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * defined will need to have the submodules listed in the 'use'
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * config. The YUI component build tool does this for you.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @return {YUI} the YUI instance.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich add: function(name, fn, version, details) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich versions[version] = versions[version] || {};
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * Executes the function associated with each required
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * module, binding the module to the YUI instance.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @method _attach
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich var i, name, mod, details, req, use, after,
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich if (!done[r[i]]) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich Y.message('NOT loaded: ' + name, 'warn', 'yui');
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich return false;
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich return false;
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich return false;
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich } catch (e) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich return false;
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * Attaches one or more modules to the YUI instance. When this
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * is executed, the requirements are analyzed, and one of
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * several things can happen:
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * - All requirements are available on the page -- The modules
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * are attached to the instance. If supplied, the use callback
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * is executed synchronously.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * - Modules are missing, the Get utility is not available OR
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * the 'bootstrap' config is false -- A warning is issued about
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * the missing modules and all available modules are attached.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * - Modules are missing, the Loader is not available but the Get
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * utility is and boostrap is not false -- The loader is bootstrapped
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * before doing the following....
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * - Modules are missing and the Loader is available -- The loader
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * expands the dependency tree and fetches missing modules. When
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * the loader is finshed the callback supplied to use is executed
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * asynchronously.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param modules* {string} 1-n modules to bind (uses arguments array).
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param *callback {function} callback function executed when
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * the instance has the required functionality. If included, it
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * must be the last parameter.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * // loads and attaches drag and drop and its dependencies
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * YUI().use('dd', function(Y) {});
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * // attaches all modules that are available on the page
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * YUI().use('*', function(Y) {});
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * // intrinsic YUI gallery support (since 3.1.0)
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich * YUI().use('gallery-yql', function(Y) {});
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * // intrinsic YUI 2in3 support (since 3.1.0)
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * YUI().use('yui2-datatable', function(Y) {});.
9b1ad7c4722db362bee7d39c851c94ba95f118b8Allen Rabinovich * @return {YUI} the YUI instance.
9b1ad7c4722db362bee7d39c851c94ba95f118b8Allen Rabinovich use: function() {
9b1ad7c4722db362bee7d39c851c94ba95f118b8Allen Rabinovich // The last argument supplied to use can be a load complete callback
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich Y._useQueue = Y._useQueue || new Y.Queue();
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich if (Y.config.cacheUse && Y.Env.serviced[key]) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich _notify: function(callback, response, args) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich if (!response.success && this.config.loadErrorFn) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.config.loadErrorFn.call(this, this, callback, response, args);
af9c7c430857db6fe42af7f92c9222eec361b86fAllen Rabinovich } catch (e) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich if (!this.Array) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // add this module to full list of things to attach
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich // only attach a module once
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // CSS files don't register themselves, see if it has
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // been loaded
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // make sure requirements are attached
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // make sure we grab the submodule dependencies too
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich if (Y._useQueue && Y._useQueue.size() && !Y._loading) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // YUI().use('*'); // bind everything available
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // use loader to expand dependencies and sort the
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // requirements if it is available.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich loader.calculate(null, (fetchCSS) ? null : 'js');
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // process each requirement and any additional requirements
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // the module metadata specifies
9b1ad7c4722db362bee7d39c851c94ba95f118b8Allen Rabinovich missing = Y.Object.keys(YArray.hash(missing));
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // dynamic load
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich loader.insert(null, (fetchCSS) ? null : 'js');
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // loader.partial(missing, (fetchCSS) ? null : 'js');
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // server side loader service
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich onEnd: function(o) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich } else if (boot && len && Y.Get && !Env.bootstrapped) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich Y.Get.script(config.base + config.loaderPath, {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Returns the namespace specified and creates it if it doesn't exist
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * YUI.namespace("property.package");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * YUI.namespace("YAHOO.property.package");
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich * Either of the above would create YUI.property, then
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * YUI.property.package (YAHOO is scrubbed out, this is
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * to remain compatible with YUI2)
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * Be careful when naming packages. Reserved words may work in some browsers
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * and not others. For instance, the following will fail in Safari:
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * YUI.namespace("really.long.nested.namespace");
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * This fails because "long" is a future reserved word in ECMAScript
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @method namespace
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param {string*} arguments 1-n namespaces to create.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @return {object} A reference to the last namespace object created.
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen Rabinovich var a = arguments, o = this, i = 0, j, d, arg;
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich for (; i < a.length; i++) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // d = ('' + a[i]).split('.');
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich for (j = (d[0] == 'YAHOO') ? 1 : 0; j < d.length; j++) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich o[d[j]] = o[d[j]] || {};
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // this is replaced if the log module is included
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * Report an error. The reporting mechanism is controled by
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * the 'throwFail' configuration attribute. If throwFail is
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * not specified, the message is written to the Logger, otherwise
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * a JS error is thrown
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @method error
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param msg {string} the error message.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param e {Error|string} Optional JS error that was caught, or an error string.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param data Optional additional info
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * and throwFail is specified, this error will be re-thrown.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @return {YUI} this YUI instance.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var Y = this, ret;
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich ret = Y.config.errorFn.apply(Y, arguments);
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich Y.message(msg, 'error'); // don't scrub this one
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * Generate an id that is unique among all YUI instances
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @method guid
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param pre {string} optional guid prefix.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @return {string} the guid.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich var id = this.Env._guidp + (++this.Env._uidx);
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * Returns a guid associated with an object. If the object
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * does not have one, a new one is created unless readOnly
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * is specified.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @method stamp
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param o The object to stamp.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich * @param readOnly {boolean} if true, a valid guid will only
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * be returned if the object has one assigned to it.
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * @return {string} The object's guid or null.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // IE generates its own unique ID for dom nodes
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich // The uniqueID property of a document node returns a new ID
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich if (o.uniqueID && o.nodeType && o.nodeType !== 9) {
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich uid = (typeof o === 'string') ? o : o._yuid;
uid = null;
return uid;
destroy: function() {
if (Y.Event) {
delete Y.Env;
delete Y.config;
if (hasWin) {
handleLoad();
* The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?
* minified version of the files (e.g., event-min.js). The filter property
* <dd>Selects the debug versions of the library (e.g., event-debug.js).
* <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
* 'replaceStr': "-debug.js"
* fullpath: 'http://myserver.mydomain.com/mymod1/mymod1.js'
* fullpath: 'http://myserver.mydomain.com/mymod2/mymod2.js'
* base: 'http://yui.yahooapis.com/2.8.0r4/build/',
* comboBase: 'http://yui.yahooapis.com/combo?',
* path: "yahoo-dom-event/yahoo-dom-event.js"
* path: "animation/animation.js",
* @default loader/loader-min.js
var L = Y.Lang,
TYPES = {
TRIMREGEX = /^\s+|\s+$/g,
SUBREGEX = /\{\s*([^\|\}]+?)\s*(?:\|([^\}]*))?\s*\}/g;
L.isArray = function(o) {
L.isBoolean = function(o) {
return typeof o === BOOLEAN;
L.isFunction = function(o) {
L.isDate = function(o) {
L.isNull = function(o) {
L.isNumber = function(o) {
return (o && (t === OBJECT ||
L.isString = function(o) {
return typeof o === STRING;
L.isUndefined = function(o) {
return typeof o === UNDEFINED;
return s.trimLeft();
return s.trimRight();
L.isValue = function(o) {
var t = L.type(o);
case NUMBER:
return isFinite(o);
case NULL:
case UNDEFINED:
L.type = function(o) {
L.sub = function(s, o) {
return new Date().getTime();
l = o.length;
Y.Array = YArray;
f.call(o || Y, a[i], i, a);
function(a, val) {
function(a, val) {
if (a[i] === val) {
var l = a.length, i;
if (f.call(o, a[i], i, a)) {
function Queue() {
this._init();
_init: function() {
this._q = [];
next: function() {
last: function() {
add: function() {
size: function() {
_iefix = function(r, s) {
Y.merge = function() {
Y.mix(o, a[i], true);
* @param merge {boolean/int} merge objects instead of overwriting/ignoring.
if (mode) {
switch (mode) {
var i, l, p, type;
p = wl[i];
if (s.hasOwnProperty(p)) {
Y.mix(r[p], s[p]);
} else if (ov || !(p in r)) {
if (s.hasOwnProperty(i)) {
} else if (ov || !(i in r)) {
_iefix(r, s);
return function(arg1) {
return cache[k];
F.prototype = o;
owns = function(o, k) {
if (owns(o, i)) {
if (count) {
out++;
return out;
O.keys = function(o) {
return _extract(o);
O.values = function(o) {
O.hasValue = function(o, v) {
f.call(s, o[i], i, o);
if (f.call(s, o[i], i, o)) {
return UNDEF;
p = Y.Array(path),
l = p.length;
p = Y.Array(path),
ref = o;
return UNDEF;
O.isEmpty = function(o) {
if (owns(o, i)) {
var numberify = function(s) {
mobile: null,
ios: null,
secure: false,
os: null
if (ua) {
o.ios = m;
L = Y.Lang,
Y.Get = function() {
queues = {},
d = w.document,
for (i in attr) {
if (attributes) {
if (attributes) {
purge: function() {
if (q && q.onEnd) {
if (q.timer) {
if (q.onFailure) {
if (q.timer) {
q.finished = true;
if (q.aborted) {
if (q.onSuccess) {
if (q.onTimeout) {
if (q.timer) {
if (q.aborted) {
if (loaded) {
if (q.varName) {
if (q.varName) {
w = q.win;
d = w.document;
if (!url) {
if (q.timeout) {
}, q.timeout);
if (insertBefore) {
h.appendChild(n);
_autoPurge = function() {
if (purging) {
purging = true;
for (i in queues) {
q = queues[i];
delete queues[i];
purging = false;
_autoPurge();
finished: false,
nodes: []
n.onreadystatechange = function() {
n.onreadystatechange = null;
n.onload = function() {
n.onerror = function(e) {
n = q.nodes;
l = n.length;
if (insertBefore) {
h = s.parentNode;
node = n[i];
q.nodes = [];
setTimeout(function() {
abort: function(o) {
q.aborted = true;
* Y.Get.css("http://localhost/css/menu.css");
* ["http://localhost/css/menu.css",
var feature_tests = {};
if (cat_o) {
return result;
if (!feature) {
if (ua) {
return result;
/* This file is auto-generated by src/loader/meta_join.py */
ret = false;
test: function() {
test: function() {
return ret;
v: Y.version,
url;
return url;
var SPLIT_REGEX = /[, ]/;
return availableLanguages[i];
if (result) {
return result;
var INSTANCE = Y,
Y = INSTANCE,
c = Y.config,
if (c.debug) {
if (src) {
if (!bail) {
if (c.useBrowserConsole) {
console[f](m);
* Provides a setTimeout/setInterval wrapper
m = o[fn];
m.call(o);
cancel: function() {
if (this.interval) {
/*! Based on work by Simon Willison: http://gist.github.com/292562 */
* Can set globally with Y.config.throttleTime or by call. Passing a -1 will