yui-core-debug.js revision 72c672b04102e2744ccbc6652c9d726308c55685
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The YUI module contains the components required for building the YUI seed
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * file. This includes the script loading mechanism, a simple queue, and
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the core utilities for the library.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @module yui
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @submodule yui-base
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan GroveThe YUI global namespace object. If YUI is already defined, the
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Groveexisting YUI object will not be overwritten so that defined
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grovenamespaces are preserved. It is the constructor for the object
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grovethe end user interacts with. As indicated below, each instance
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grovehas full custom event support, but only if the event system
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Groveis available. This is a self-instantiable factory function. You
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grovecan invoke it directly like this:
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove YUI().use('*', function(Y) {
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan GroveBut it also works like this:
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove var Y = YUI();
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav GlassConfiguring the YUI object:
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass debug: true,
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass combine: false
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass }).use('node', function(Y) {
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass //Node is ready to use
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav GlassSee the API docs for the <a href="config.html">Config</a> class
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glassfor the complete list of supported configuration properties accepted
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glassby the YUI constuctor.
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove@uses EventTarget
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith@param o* {Object} 0..n optional configuration objects. these values
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Groveare store in Y.config. See <a href="config.html">Config</a> for the list of supported
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass /*global YUI*/
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass /*global YUI_config*/
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var YUI = function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return (o && o.hasOwnProperty && (o instanceof type));
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass gconf = (typeof YUI_config !== 'undefined') && YUI_config;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // set up the core environment
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove YUI.GlobalConfig is a master configuration that might span
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove multiple contexts in a non-browser environment. It is applied
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove first to all instances in all contexts.
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith @property GlobalConfig
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove @type {Object}
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove YUI.GlobalConfig = {
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove filter: 'debug'
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove YUI().use('node', function(Y) {
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove //debug files used here
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove filter: 'min'
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove }).use('node', function(Y) {
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove //min files used here
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove YUI_config is a page-level config. It is applied to all
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove instances created on the page. This is applied after
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove YUI.GlobalConfig, and before the instance level configuration
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove @property YUI_config
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove @type {Object}
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove //Single global var to include before YUI seed file
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove YUI_config = {
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove filter: 'debug'
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove YUI().use('node', function(Y) {
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove //debug files used here
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove filter: 'min'
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove }).use('node', function(Y) {
71651656e38f39cf8f088e75166fb0bf51c52eb1Ryan Grove //min files used here
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // bind the specified additional modules for this instance
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Each instance can accept one or more configuration objects.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // These are applied after YUI.GlobalConfig and YUI_Config,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // overriding values set in those config files if there is a '
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // matching property.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (; i < l; i++) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass(function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass NOOP = function() {},
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass APPLY_TO_AUTH = { 'io.xdrReady': 1, // the functions applyTo
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // this can throw an uncaught exception in FF
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } catch (ex) {}
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass handleLoad = function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass getLoader = function(Y, o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass //loader._config(Y.config);
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass YUI.Env.core = Y.Array.dedupe([].concat(YUI.Env.core, [ 'loader-base', 'loader-rollup', 'loader-yui3' ]));
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass clobber = function(r, s) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (var i in s) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass r[i] = s[i];
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// Stamp the documentElement (HTML) with a class of "yui-loaded" to
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// enable styles that need to key off of JS being enabled.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Applies a new configuration object to the YUI instance config.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * This will merge new group/module definitions, and will also
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * update the loader cache if necessary. Updating Y.config directly
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * will not update the cache.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method applyConfig
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith * @param {Object} o the configuration object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.2.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass applyConfig: function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (name in o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // preserve the guid
fcdb79161199cde3840a5b9779ece302b3b4c9ffDav Glass * Old way to apply a config to the instance (calls `applyConfig` under the hood)
fcdb79161199cde3840a5b9779ece302b3b4c9ffDav Glass * @method _config
fcdb79161199cde3840a5b9779ece302b3b4c9ffDav Glass * @param {Object} o The config to apply
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass _config: function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Initialize this YUI instance
fcdb79161199cde3840a5b9779ece302b3b4c9ffDav Glass * @method _init
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass _init: function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The version number of the YUI instance.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property version
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // bootstrapped: false,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // serviced: {},
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Regex in English:
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // I'll start at the \b(simpleyui).
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // 1. Look in the test string for "simpleyui" or "yui" or
bc1109485d3d133cb6432ab3116e13496ef0bf47Dav Glass // "yui-base" or "yui-davglass" or "yui-foobar" that comes after a word break. That is, it
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // can't match "foyui" or "i_heart_simpleyui". This can be anywhere in the string.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // 2. After #1 must come a forward slash followed by the string matched in #1, so
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // "yui-base/yui-base" or "simpleyui/simpleyui" or "yui-pants/yui-pants".
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // 3. The second occurence of the #1 token can optionally be followed by "-debug" or "-min",
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // so "yui/yui-min", "yui/yui-debug", "yui-base/yui-base-debug". NOT "yui/yui-tshirt".
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // 4. This is followed by ".js", so "yui/yui.js", "simpleyui/simpleyui-min.js"
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // 0. Going back to the beginning, now. If all that stuff in 1-4 comes after a "?" in the string,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // then capture the junk between the LAST "&" and the string in 1-4. So
bc1109485d3d133cb6432ab3116e13496ef0bf47Dav Glass // "blah?foo/yui/yui.js" will capture "foo/" and "blah?some/thing.js&3.3.0/build/yui-davglass/yui-davglass.js"
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // will capture "3.3.0/build/"
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Regex Exploded:
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // (?:\? Find a ?
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // (?:[^&]*&) followed by 0..n characters followed by an &
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // * in fact, find as many sets of characters followed by a & as you can
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // ([^&]*) capture the stuff after the last & in \1
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // )? but it's ok if all this ?junk&more_junk stuff isn't even there
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // \b(simpleyui| after a word break find either the string "simpleyui" or
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // yui(?:-\w+)? the string "yui" optionally followed by a -, then more characters
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // ) and store the simpleyui or yui-* string in \2
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // \/\2 then comes a / followed by the simpleyui or yui-* string in \2
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // (?:-(min|debug))? optionally followed by "-min" or "-debug"
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // .js and ending in ".js"
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass _BASE_RE: /(?:\?(?:[^&]*&)*([^&]*))?\b(simpleyui|yui(?:-\w+)?)\/\2(?:-(min|debug))?\.js/,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass path = RegExp.leftContext || src.slice(0, src.indexOf(match[0]));
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // this is to set up the path to the loader. The file
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // filter for loader should match the yui include.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // extract correct path for mixed combo urls
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // http://yuilibrary.com/projects/yui3/ticket/2528423
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var nodes = (doc && doc.getElementsByTagName('script')) || [],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // use CDN default
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // configuration defaults
72c672b04102e2744ccbc6652c9d726308c55685Dav Glass //Register the CSS stamp element
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.config.base = YUI.config.base || Y.Env.getBase(Y.Env._BASE_RE);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.config.loaderPath = YUI.config.loaderPath || 'loader/loader' + filter + '.js';
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Finishes the instance setup. Attaches whatever modules were defined
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * when the yui modules was registered.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method _setup
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass _setup: function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var i, Y = this,
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass //extras = Y.config.core || ['get','intl-base'];
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass extras = Y.config.core || [].concat(YUI.Env.core); //Clone it..
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Y.log(Y.id + ' initialized', 'info', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Executes a method on a YUI instance with
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the specified id if the specified method is whitelisted.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method applyTo
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param id {String} the YUI instance id.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param method {String} the name of the method to exectute.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Ex: 'Object.keys'.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param args {Array} the arguments to apply to the method.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @return {Object} the return value from the applied method or null.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass this.log(method + ': applyTo not allowed', 'warn', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return null;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass this.log('applyTo not found: ' + method, 'warn', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return null;
b06f0506728aa781ea59ef35737b6e965463c7afDav GlassRegisters a module with the YUI global. The easiest way to create a
b06f0506728aa781ea59ef35737b6e965463c7afDav Glassfirst-class YUI module is to use the YUI component build tool.
b06f0506728aa781ea59ef35737b6e965463c7afDav GlassThe build system will produce the `YUI.add` wrapper for you module, along
b06f0506728aa781ea59ef35737b6e965463c7afDav Glasswith any configuration info required for the module.
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@param name {String} module name.
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@param fn {Function} entry point into the module that is used to bind module to the YUI instance.
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@param {YUI} fn.Y The YUI instance this module is executed in.
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@param {String} fn.name The name of the module
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@param version {String} version string.
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@param details {Object} optional config data:
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@param details.requires {Array} features that must be present before this module can be attached.
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@param details.optional {Array} optional features that should be present if loadOptional
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass is defined. Note: modules are not often loaded this way in YUI 3,
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass but this field is still useful to inform the user that certain
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass features in the component will require additional dependencies.
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@param details.use {Array} features that are included within this module which need to
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass be attached automatically when this module is attached. This
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass supports the YUI 3 rollup system -- a module with submodules
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass defined will need to have the submodules listed in the 'use'
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass config. The YUI component build tool does this for you.
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass@return {YUI} the YUI instance.
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass YUI.add('davglass', function(Y, name) {
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass Y.davglass = function() {
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass alert('Dav was here!');
b06f0506728aa781ea59ef35737b6e965463c7afDav Glass }, '3.4.0', { requires: ['yui-base', 'harley-davidson', 'mt-dew'] });
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return this;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Executes the function associated with each required
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * module, binding the module to the YUI instance.
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass * @param {Array} r The array of modules to attach
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass * @param {Boolean} [moot=false] Don't throw a warning if the module is not attached
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method _attach
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y = this, j,
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass //Check for conditional modules (in a second+ instance) and add their requirements
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass //TODO I hate this entire method, it needs to be fixed ASAP (3.5.0) ^davglass
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass Y.Object.each(loader.conditions[name], function(def) {
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass var go = def && ((def.ua && Y.UA[def.ua]) || (def.test && def.test(Y)));
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (!done[r[i]]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Y.log('no js def for: ' + name, 'info', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass //if (!loader || !loader.moduleInfo[name]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass //if ((!loader || !loader.moduleInfo[name]) && !moot) {
b0ab788daf32aca249320825ecbdcef36aa0c052Dav Glass if ((name.indexOf('skin-') === -1) && (name.indexOf('css') === -1)) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass //Don't like this, but in case a mod was asked for once, then we fetch it
847ed3bff546872247639b703baa857dc3ea4f36Dav Glass //We need to remove it from the missed list ^davglass
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.message('Found: ' + name + ' (was reported as missing earlier)', 'warn', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return false;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return false;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } catch (e) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return false;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return false;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return true;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Attaches one or more modules to the YUI instance. When this
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * is executed, the requirements are analyzed, and one of
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * several things can happen:
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * * All requirements are available on the page -- The modules
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * are attached to the instance. If supplied, the use callback
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * is executed synchronously.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * * Modules are missing, the Get utility is not available OR
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the 'bootstrap' config is false -- A warning is issued about
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the missing modules and all available modules are attached.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * * Modules are missing, the Loader is not available but the Get
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * utility is and boostrap is not false -- The loader is bootstrapped
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * before doing the following....
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * * Modules are missing and the Loader is available -- The loader
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * expands the dependency tree and fetches missing modules. When
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the loader is finshed the callback supplied to use is executed
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * asynchronously.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @method use
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param modules* {String} 1-n modules to bind (uses arguments array).
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param *callback {Function} callback function executed when
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the instance has the required functionality. If included, it
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * must be the last parameter.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // loads and attaches dd and its dependencies
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * YUI().use('dd', function(Y) {});
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // loads and attaches dd and node as well as all of their dependencies (since 3.4.0)
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * YUI().use(['dd', 'node'], function(Y) {});
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // attaches all modules that are available on the page
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * YUI().use('*', function(Y) {});
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // intrinsic YUI gallery support (since 3.1.0)
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * YUI().use('gallery-yql', function(Y) {});
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // intrinsic YUI 2in3 support (since 3.1.0)
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * YUI().use('yui2-datatable', function(Y) {});
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {YUI} the YUI instance.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass use: function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // The last argument supplied to use can be a load complete callback
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.log('already provisioned: ' + args, 'info', 'yui');
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * Notify handler from Loader for attachment/load errors
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @method _notify
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param callback {Function} The callback to pass to the `Y.config.loadErrorFn`
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param response {Object} The response returned from Loader
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param args {Array} The aruments passed from Loader
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (!response.success && this.config.loadErrorFn) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass this.config.loadErrorFn.call(this, this, callback, response, args);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } else if (callback) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } catch (e) {
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * This private method is called from the `use` method queue. To ensure that only one set of loading
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * logic is performed at a time.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @method _use
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param args* {String} 1-n modules to bind (uses arguments array).
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param *callback {Function} callback function executed when
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * the instance has the required functionality. If included, it
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * must be the last parameter.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (!this.Array) {
cf7632d230c20fcded115f244fe6bdefd90b024fDav Glass var i = 0, a = [];
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // add this module to full list of things to attach
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // only attach a module once
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // CSS files don't register themselves, see if it has
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // been loaded
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // make sure requirements are attached
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // make sure we grab the submodule dependencies too
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.log('Nested use callback: ' + data, 'info', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Y.log('attaching from loader: ' + data, 'info', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (Y._useQueue && Y._useQueue.size() && !Y._loading) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// Y.log(Y.id + ': use called: ' + a + ' :: ' + callback, 'info', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // YUI().use('*'); // bind everything available
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Y.log('before loader requirements: ' + args, 'info', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // use loader to expand dependencies and sort the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // requirements if it is available.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // process each requirement and any additional requirements
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // the module metadata specifies
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassY.log('Modules missing: ' + missing + ', ' + missing.length, 'info', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // dynamic load
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// Y.log('Using loader to fetch missing deps: ' + missing, 'info', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // loader.partial(missing, (fetchCSS) ? null : 'js');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } else if (boot && len && Y.Get && !Env.bootstrapped) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass handleBoot = function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassY.log('Fetching loader: ' + config.base + config.loaderPath, 'info', 'yui');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.log('Attaching available dependencies: ' + args, 'info', 'yui');
2f78fd70583b1cebc3226803c36d82456d8a4319Luke Smith Adds a namespace object onto the YUI global if called statically.
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith // creates YUI.your.namespace.here as nested objects
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith YUI.namespace("your.namespace.here");
2f78fd70583b1cebc3226803c36d82456d8a4319Luke Smith If called as a method on a YUI <em>instance</em>, it creates the
2f78fd70583b1cebc3226803c36d82456d8a4319Luke Smith namespace on the instance.
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith // creates Y.property.package
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith Y.namespace("property.package");
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith Dots in the input string cause `namespace` to create nested objects for
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith each token. If any part of the requested namespace already exists, the
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith current object will be left in place. This allows multiple calls to
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith `namespace` to preserve existing namespaced properties.
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith If the first token in the namespace string is "YAHOO", the token is
2f78fd70583b1cebc3226803c36d82456d8a4319Luke Smith Be careful with namespace tokens. Reserved words may work in some browsers
2f78fd70583b1cebc3226803c36d82456d8a4319Luke Smith and not others. For instance, the following will fail in some browsers
2f78fd70583b1cebc3226803c36d82456d8a4319Luke Smith because the supported version of JavaScript reserves the word "long":
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith Y.namespace("really.long.nested.namespace");
fd6e0c106ef55f46bcc11b2161d7c6fa24110fdaDav Glass <em>Note: If you pass multiple arguments to create multiple namespaces, only
fd6e0c106ef55f46bcc11b2161d7c6fa24110fdaDav Glass the last one created is returned from this function.</em>
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith @method namespace
2f78fd70583b1cebc3226803c36d82456d8a4319Luke Smith @param {String} namespace* namespaces to create.
cac1e07e6c1588f45e78548aef28059dbf56d6c9Luke Smith @return {Object} A reference to the last namespace object created.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass namespace: function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (; i < a.length; i++) {
fd6e0c106ef55f46bcc11b2161d7c6fa24110fdaDav Glass o = this; //Reset base object per argument or it will get reused from the last
fd6e0c106ef55f46bcc11b2161d7c6fa24110fdaDav Glass if (arg.indexOf(PERIOD) > -1) { //Skip this if no "." is present
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (j = (d[0] == 'YAHOO') ? 1 : 0; j < d.length; j++) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass o[d[j]] = o[d[j]] || {};
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass o = o[d[j]];
fd6e0c106ef55f46bcc11b2161d7c6fa24110fdaDav Glass o = o[arg]; //Reset base object to the new object so it's returned
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // this is replaced if the log module is included
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // this is replaced if the dump module is included
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Report an error. The reporting mechanism is controled by
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * the `throwFail` configuration attribute. If throwFail is
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * not specified, the message is written to the Logger, otherwise
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * a JS error is thrown
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method error
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param msg {String} the error message.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param e {Error|String} Optional JS error that was caught, or an error string.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param data Optional additional info
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * and `throwFail` is specified, this error will be re-thrown.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {YUI} this YUI instance.
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass //TODO Add check for window.onerror here
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var Y = this, ret;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Generate an id that is unique among all YUI instances
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method guid
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param pre {String} optional guid prefix.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @return {String} the guid.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var id = this.Env._guidp + '_' + (++this.Env._uidx);
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * Returns a `guid` associated with an object. If the object
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * does not have one, a new one is created unless `readOnly`
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * is specified.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method stamp
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param o {Object} The object to stamp.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @param readOnly {Boolean} if `true`, a valid guid will only
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * be returned if the object has one assigned to it.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @return {String} The object's guid or null.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // IE generates its own unique ID for dom nodes
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // The uniqueID property of a document node returns a new ID
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (o.uniqueID && o.nodeType && o.nodeType !== 9) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } catch (e) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Destroys the YUI instance
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method destroy
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.3.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass destroy: function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var Y = this;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * instanceof check for objects that works around
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * memory leak in IE when the item tested is
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method instanceOf
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.3.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // inheritance utilities are not available yet
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav GlassStatic method on the Global YUI object to apply a config to all YUI instances.
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav GlassIt's main use case is "mashups" where several third party scripts are trying to write to
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glassa global YUI config at the same time. This way they can all call `YUI.applyConfig({})` instead of
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glassoverwriting other scripts configs.
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass@method applyConfig
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass@param {Object} o the configuration object.
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass YUI.applyConfig({
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass fullpath: './davglass.js'
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass YUI.applyConfig({
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass fullpath: './foo.js'
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass YUI().use('davglass', function(Y) {
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass //Module davglass will be available here..
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass //If there is a GlobalConfig, apply it first to set the defaults
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass this.prototype.applyConfig.call(this, YUI.GlobalConfig);
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass //Apply this config to it
a2e8d3ada9281ad6d3c49b9318315d37452ffc39Dav Glass //Reset GlobalConfig to the combined config
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // set up the environment
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // add a window load event at load time so we can capture
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // the case where it fires before dynamic loading is
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // complete.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass /*global exports*/
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Support the CommonJS method for exporting our single global
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The config object contains all of the configuration options for
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * the `YUI` instance. This object is supplied by the implementer
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * when instantiating a `YUI` instance. Some properties have default
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * values if they are not supplied by the implementer. This should
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * not be updated directly because some values are cached. Use
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * `applyConfig()` to update the config object on a YUI instance that
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * has already been configured.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @class config
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Allows the YUI seed file to fetch the loader component and library
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * metadata to dynamically load additional dependencies.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property bootstrap
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type boolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default true
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass * Turns on writing Ylog messages to the browser console.
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass * @property debug
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass * @type boolean
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass * @default true
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Log to the browser console if debug is on and the browser has a
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * supported console.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property useBrowserConsole
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type boolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default true
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A hash of log sources that should be logged. If specified, only
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * log messages from these sources will be logged.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property logInclude
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type object
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A hash of log sources that should be not be logged. If specified,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * all sources are logged if not on this list.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property logExclude
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type object
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Set to true if the yui seed file was dynamically loaded in
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * order to bootstrap components relying on the window load event
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * and the `domready` custom event.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property injected
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type boolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default false
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * If `throwFail` is set, `Y.error` will generate or re-throw a JS Error.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Otherwise the failure is logged.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property throwFail
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type boolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default true
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The window/frame that this instance should operate in.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property win
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type Window
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default the window hosting YUI
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The document associated with the 'win' configuration.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property doc
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type Document
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default the document hosting YUI
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass * A list of modules that defines the YUI core (overrides the default list).
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property core
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass * @type Array
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass * @default [ get,features,intl-base,yui-log,yui-later,loader-base, loader-rollup, loader-yui3 ]
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A list of languages in order of preference. This list is matched against
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the list of available languages in modules that the YUI instance uses to
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * determine the best possible localization of language sensitive modules.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Languages are represented using BCP 47 language tags, such as "en-GB" for
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * English as used in the United Kingdom, or "zh-Hans-CN" for simplified
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Chinese as used in China. The list can be provided as a comma-separated
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * list or as an array.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property lang
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string|string[]
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The default date format
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property dateFormat
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @deprecated use configuration in `DataType.Date.format()` instead.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The default locale
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property locale
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @deprecated use `config.lang` instead.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The default interval when polling in milliseconds.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property pollInterval
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default 20
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The number of dynamic nodes to insert by default before
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * automatically removing them. This applies to script nodes
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * because removing the node will not make the evaluated script
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * unavailable. Dynamic CSS is not auto purged, because removing
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * a linked style sheet will also remove the style definitions.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property purgethreshold
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default 20
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The default interval when polling in milliseconds.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property windowResizeDelay
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default 40
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Base directory for dynamic loading
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property base
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The secure base dir (not implemented)
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * For dynamic loading.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property secureBase
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * The YUI combo service base dir. Ex: `http://yui.yahooapis.com/combo?`
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * For dynamic loading.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property comboBase
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The root path to prepend to module path for the combo service.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Ex: 3.0.0b1/build/
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * For dynamic loading.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property root
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A filter to apply to result urls. This filter will modify the default
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * path for all modules. The default path for the YUI library is the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * minified version of the files (e.g., event-min.js). The filter property
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * can be a predefined filter or a custom filter. The valid predefined
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * filters are:
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * <dt>DEBUG</dt>
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * <dd>Selects the debug versions of the library (e.g., event-debug.js).
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * This option will automatically include the Logger widget</dd>
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * <dt>RAW</dt>
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * You can also define a custom filter, which must be an object literal
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * containing a search expression and a replace string:
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * myFilter: {
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * 'searchExp': "-min\\.js",
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * 'replaceStr': "-debug.js"
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * For dynamic loading.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property filter
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string|object
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * The `skin` config let's you configure application level skin
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * customizations. It contains the following attributes which
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * can be specified to override the defaults:
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // The default skin, which is automatically applied if not
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // overriden by a component-specific skin definition.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // Change this in to apply a different skin globally
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * defaultSkin: 'sam',
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // This is combined with the loader base property to get
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // the default root directory for a skin.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // Any component-specific overrides can be specified here,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // making it possible to load different skins for different
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // components. It is possible to load more than one skin
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // for a given component as well.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * overrides: {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * slider: ['capsule', 'round']
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * For dynamic loading.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property skin
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Hash of per-component filter specification. If specified for a given
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * component, this overrides the filter config.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * For dynamic loading.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property filters
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Use the YUI combo service to reduce the number of http connections
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * required to load your dependencies. Turning this off will
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * disable combo handling for YUI and all module groups configured
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * with a combo service.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * For dynamic loading.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property combine
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type boolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default true if 'base' is not supplied, false if it is.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A list of modules that should never be dynamically loaded
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property ignore
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string[]
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A list of modules that should always be loaded when required, even if already
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * present on the page.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property force
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string[]
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Node or id for a node that should be used as the insertion point for new
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * nodes. For dynamic loading.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property insertBefore
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Object literal containing attributes to add to dynamically loaded script
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property jsAttributes
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Object literal containing attributes to add to dynamically loaded link
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property cssAttributes
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Number of milliseconds before a timeout occurs when dynamically
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * loading nodes. If not set, there is no timeout.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property timeout
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Callback for the 'CSSComplete' event. When dynamically loading YUI
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * components with CSS, this property fires when the CSS is finished
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * loading but script loading is still ongoing. This provides an
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * opportunity to enhance the presentation of a loading page a little
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * bit before the entire loading process is done.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property onCSS
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type function
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A hash of module definitions to add to the list of YUI components.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * These components can then be dynamically loaded side by side with
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * YUI via the `use()` method. This is a hash, the key is the module
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * name, and the value is an object literal specifying the metdata
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * for the module. See `Loader.addModule` for the supported module
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * metadata fields. Also see groups, which provides a way to
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * configure the base and combo spec for a set of modules.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * modules: {
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * requires: ['node'],
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * fullpath: 'http://myserver.mydomain.com/mymod1/mymod1.js'
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * requires: ['mymod1'],
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * fullpath: 'http://myserver.mydomain.com/mymod2/mymod2.js'
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property modules
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type object
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A hash of module group definitions. It for each group you
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * can specify a list of modules and the base path and
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * combo spec to use when dynamically loading the modules.
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // specify whether or not this group has a combo service
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * combine: true,
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // the base path for non-combo paths
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * base: 'http://yui.yahooapis.com/2.8.0r4/build/',
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // the path to the combo service
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // a fragment to prepend to the path attribute when
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // when building combo urls
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * root: '2.8.0r4/build/',
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * // the module definitions
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * modules: {
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * yui2_yde: {
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * yui2_anim: {
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * requires: ['yui2_yde']
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * @property groups
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type object
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The loader 'path' attribute to the loader itself. This is combined
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * with the 'base' attribute to dynamically load the loader component
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * when boostrapping with the get utility alone.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property loaderPath
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Specifies whether or not YUI().use(...) will attempt to load CSS
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * resources at all. Any truthy value will cause CSS dependencies
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * to load when fetching script. The special value 'force' will
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * cause CSS dependencies to be loaded even if no script is needed.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property fetchCSS
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type boolean|string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default true
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The default gallery version to build gallery module urls
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property gallery
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.1.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The default YUI 2 version to build yui2 module urls. This is for
b43ba5ec2311e6f856ff2434c79b5b43f226dd73Dav Glass * intrinsic YUI 2 support via the 2in3 project. Also see the '2in3'
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * config for pulling different revisions of the wrapped YUI 2
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.1.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property yui2
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass * @default 2.9.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The 2in3 project is a deployment of the various versions of YUI 2
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * deployed as first-class YUI 3 modules. Eventually, the wrapper
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * for the modules will change (but the underlying YUI 2 code will
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * be the same), and you can select a particular version of
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the wrapper modules via this config.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.1.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property 2in3
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
8c3dc62e775bd2e2d8a0d8ea5a1d34cb7fe8bfc3Dav Glass * @default 4
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Alternative console log function for use in environments without
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * a supported native console. The function is executed in the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * YUI instance context.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.1.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property logFn
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type Function
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A callback to execute when Y.error is called. It receives the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * error message and an javascript error object if Y.error was
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * executed because a javascript error was caught. The function
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * is executed in the YUI instance context.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.2.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property errorFn
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type Function
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A callback to execute when the loader fails to load one or
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * more resource. This could be because of a script load
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * failure. It can also fail if a javascript module fails
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * to register itself, but only when the 'requireRegistration'
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * is true. If this function is defined, the use() callback will
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * only be called when the loader succeeds, otherwise it always
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * executes unless there was a javascript error when attaching
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.3.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property loadErrorFn
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type Function
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * When set to true, the YUI loader will expect that all modules
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * it is responsible for loading will be first-class YUI modules
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * that register themselves with the YUI global. If this is
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * set to true, loader will fail if the module registration fails
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * to happen after the script is loaded.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.3.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property requireRegistration
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type boolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default false
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Cache serviced use() requests.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.3.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property cacheUse
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type boolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default true
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @deprecated no longer used
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @module yui
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @submodule yui-base
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The YUI module contains the components required for building the YUI
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * seed file. This includes the script loading mechanism, a simple queue,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * and the core utilities for the library.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @module yui
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @submodule yui-base
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Provides core language utilites and extensions used throughout YUI.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @class Lang
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassSUBREGEX = /\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassTRIMREGEX = /^\s+|\s+$/g,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// If either MooTools or Prototype is on the page, then there's a chance that we
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// can't trust "native" language features to actually be native. When this is
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// the case, we take the safe route and fall back to our own non-native
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// implementation.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassunsafeNatives = win && !!(win.MooTools || win.Prototype);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Determines whether or not the provided item is an array.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns `false` for array-like collections such as the function `arguments`
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * collection or `HTMLElement` collections. Use `Y.Array.test()` if you want to
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * test for an array-like collection.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isArray
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if o is an array.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.isArray = (!unsafeNatives && Array.isArray) || function (o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Determines whether or not the provided item is a boolean.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isBoolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if o is a boolean.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.isBoolean = function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return typeof o === 'boolean';
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Determines whether or not the provided item is a function.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Note: Internet Explorer thinks certain functions are objects:
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * var obj = document.createElement("object");
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Y.Lang.isFunction(obj.getAttribute) // reports false in IE
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * var input = document.createElement("input"); // append to body
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Y.Lang.isFunction(input.focus) // reports false in IE
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * You will have to implement additional tests if these functions
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * matter to you.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isFunction
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if o is a function.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.isFunction = function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Determines whether or not the supplied item is a date instance.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isDate
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if o is a date.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.isDate = function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return L.type(o) === 'date' && o.toString() !== 'Invalid Date' && !isNaN(o);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Determines whether or not the provided item is null.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isNull
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if o is null.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.isNull = function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return o === null;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Determines whether or not the provided item is a legal number.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isNumber
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if o is a number.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.isNumber = function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Determines whether or not the provided item is of type object
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * or function. Note that arrays are also objects, so
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * <code>Y.Lang.isObject([]) === true</code>.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isObject
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param failfn {boolean} fail if the input is a function.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if o is an object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @see isPlainObject
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var t = typeof o;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return (o && (t === 'object' ||
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass (!failfn && (t === 'function' || L.isFunction(o))))) || false;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Determines whether or not the provided item is a string.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isString
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if o is a string.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.isString = function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return typeof o === 'string';
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Determines whether or not the provided item is undefined.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isUndefined
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if o is undefined.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.isUndefined = function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return typeof o === 'undefined';
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns a string without any leading or trailing whitespace. If
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the input is not a string, the input will be returned untouched.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method trim
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param s {string} the string to trim.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {string} the trimmed string.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass} : function (s) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } catch (e) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns a string without any leading whitespace.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method trimLeft
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param s {string} the string to trim.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {string} the trimmed string.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.trimLeft = STRING_PROTO.trimLeft ? function (s) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass} : function (s) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns a string without any trailing whitespace.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method trimRight
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param s {string} the string to trim.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {string} the trimmed string.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.trimRight = STRING_PROTO.trimRight ? function (s) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass} : function (s) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A convenience method for detecting a legitimate non-null value.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns false for null/undefined/NaN, true for other values,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * including 0/false/''
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isValue
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The item to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {boolean} true if it is not null/undefined/NaN || false.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.isValue = function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var t = L.type(o);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass switch (t) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass case 'number':
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass case 'undefined':
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return false;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns a string representing the type of the item passed in.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Known issues:
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * <code>typeof HTMLElementCollection</code> returns function in Safari, but
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * <code>Y.type()</code> reports object, which could be a good thing --
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * but it actually caused the logic in <code>Y.Lang.isObject</code> to fail.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method type
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o the item to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {string} the detected type.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.type = function(o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? 'object' : 'null');
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Lightweight version of <code>Y.substitute</code>. Uses the same template
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * structure as <code>Y.substitute</code>, but doesn't support recursion,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * auto-object coersion, or formats.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method sub
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {string} s String to be modified.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {object} o Object containing replacement values.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {string} the substitute result.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.2.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassL.sub = function(s, o) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return s.replace ? s.replace(SUBREGEX, function (match, key) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns the current time in milliseconds.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method now
c1463e30f48fb36d028c3ca3d1e7c9b96848a9c1Ryan Grove * @return {Number} Current time in milliseconds.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.3.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return new Date().getTime();
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove@submodule yui-base
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveProvides utility methods for working with arrays. Additional array helpers can
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grovebe found in the `collection` and `array-extras` modules.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove`Y.Array(thing)` returns a native array created from _thing_. Depending on
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove_thing_'s type, one of the following will happen:
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove * Arrays are returned unmodified unless a non-zero _startIndex_ is
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove * Array-like collections (see `Array.test()`) are converted to arrays.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove * For everything else, a new array is created with _thing_ as the sole
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveNote: elements that are also collections, such as `<form>` and `<select>`
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Groveelements, are not automatically converted to arrays. To force a conversion,
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grovepass `true` as the value of the _force_ parameter.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Any} thing The thing to arrayify.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Number} [startIndex=0] If non-zero and _thing_ is an array or array-like
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove collection, a subset of items starting at the specified index will be
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Boolean} [force=false] If `true`, _thing_ will be treated as an
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove array-like collection no matter what.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@return {Array} A native array created from _thing_, according to the rules
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove described above.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // IE throws when trying to slice HTMLElement collections.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } catch (ex) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (len = thing.length; startIndex < len; ++startIndex) {
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveDedupes an array of strings, returning an array that's guaranteed to contain
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Groveonly one copy of a given string.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveThis method differs from `Array.unique()` in that it's optimized for use only
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grovewith strings, whereas `unique` may be used with other types (but is slower).
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveUsing `dedupe()` with non-string values may result in unexpected behavior.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@method dedupe
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {String[]} array Array of strings to dedupe.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@return {Array} Deduped copy of _array_.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveExecutes the supplied function on each item in the array. This method wraps
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grovethe native ES5 `Array.forEach()` method if available.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Array} array Array to iterate.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Function} fn Function to execute on each item in the array. The function
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove will receive the following arguments:
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove @param {Any} fn.item Current array item.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove @param {Number} fn.index Current array index.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove @param {Array} fn.array Array being iterated.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Object} [thisObj] `this` object to use when calling _fn_.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@return {YUI} The YUI instance.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassYArray.each = YArray.forEach = Native.forEach ? function (array, fn, thisObj) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Native.forEach.call(array || [], fn, thisObj || Y);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (var i = 0, len = (array && array.length) || 0; i < len; ++i) {
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveAlias for `each()`.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@method forEach
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveReturns an object using the first array as keys and the second as values. If
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grovethe second array is not provided, or if it doesn't contain the same number of
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grovevalues as the first array, then `true` will be used in place of the missing
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove Y.Array.hash(['a', 'b', 'c'], ['foo', 'bar']);
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove // => {a: 'foo', b: 'bar', c: true}
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {String[]} keys Array of strings to use as keys.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Array} [values] Array to use as values.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@return {Object} Hash using the first array as keys and the second as values.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass hash[keys[i]] = vlen > i && i in values ? values[i] : true;
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveReturns the index of the first item in the array that's equal (using a strict
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Groveequality check) to the specified _value_, or `-1` if the value isn't found.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveThis method wraps the native ES5 `Array.indexOf()` method if available.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@method indexOf
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Array} array Array to search.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Any} value Value to search for.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@return {Number} Index of the item strictly equal to _value_, or `-1` if not
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassYArray.indexOf = Native.indexOf ? function (array, value) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // TODO: support fromIndex
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (var i = 0, len = array.length; i < len; ++i) {
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveNumeric sort convenience function.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveThe native `Array.prototype.sort()` function converts values to strings and
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grovesorts them in lexicographic order, which is unsuitable for sorting numeric
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grovevalues. Provide `Array.numericSort` as a custom sort function when you want
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Groveto sort values in numeric order.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove [42, 23, 8, 16, 4, 15].sort(Y.Array.numericSort);
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove // => [4, 8, 15, 16, 23, 42]
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@method numericSort
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Number} a First value to compare.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Number} b Second value to compare.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@return {Number} Difference between _a_ and _b_.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return a - b;
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan GroveExecutes the supplied function on each item in the array. Returning a truthy
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grovevalue from the function will stop the processing of remaining items.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Array} array Array to iterate over.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Function} fn Function to execute on each item. The function will receive
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove the following arguments:
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove @param {Any} fn.value Current array item.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove @param {Number} fn.index Current array index.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove @param {Array} fn.array Array being iterated over.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@param {Object} [thisObj] `this` object to use when calling _fn_.
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove@return {Boolean} `true` if the function returns a truthy value on any of the
a7bf61fe73568ec8f3615c238acbe69d5986e21dRyan Grove items in the array; `false` otherwise.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassYArray.some = Native.some ? function (array, fn, thisObj) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (var i = 0, len = array.length; i < len; ++i) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (i in array && fn.call(thisObj, array[i], i, array)) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return true;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return false;
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan GroveEvaluates _obj_ to determine if it's an array, an array-like collection, or
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grovesomething else. This is useful when working with the function `arguments`
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grovecollection and `HTMLElement` collections.
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan GroveNote: This implementation doesn't consider elements that are also
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grovecollections, such as `<form>` and `<select>`, to be array-like.
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove@param {Object} obj Object to test.
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove@return {Number} A number indicating the results of the test:
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove * 0: Neither an array nor an array-like collection.
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove * 1: Real array.
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove * 2: Array-like collection.
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove // indexed, but no tagName (element) or alert (window),
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove // or functions without apply/call (Safari
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove // HTMLElementCollection bug).
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove if ('length' in obj && !obj.tagName && !obj.alert && !obj.apply) {
ca485dc641537729d8e1b87e5b982e6a6b35b49aRyan Grove } catch (ex) {}
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The YUI module contains the components required for building the YUI
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * seed file. This includes the script loading mechanism, a simple queue,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * and the core utilities for the library.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @module yui
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @submodule yui-base
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * A simple FIFO queue. Items are added to the Queue with add(1..n items) and
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * removed using next().
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @class Queue
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @constructor
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {MIXED} item* 0..n items to seed the queue.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Initialize the queue
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method _init
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @protected
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass _init: function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The collection of enqueued items
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property _q
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type Array
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @protected
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Get the next item in the queue. FIFO support
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method next
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {MIXED} the next item in the queue.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass next: function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Get the last in the queue. LIFO support.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method last
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {MIXED} the last item in the queue.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass last: function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Add 0..n items to the end of the queue.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method add
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {MIXED} item* 0..n items.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {object} this queue.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass add: function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return this;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns the current number of queued items.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method size
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Number} The size.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass size: function() {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassYUI.Env._loaderQueue = YUI.Env._loaderQueue || new Queue();
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassThe YUI module contains the components required for building the YUI seed file.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassThis includes the script loading mechanism, a simple queue, and the core
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glassutilities for the library.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@submodule yui-base
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassReturns a wrapper for a function which caches the return value of that function,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glasskeyed off of the combined string representation of the argument values provided
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glasswhen the wrapper is called.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassCalling this function again with the same arguments will return the cached value
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glassrather than executing the wrapped function.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassNote that since the cache is keyed off of the string representation of arguments
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glasspassed to the wrapper function, arguments that aren't strings and don't provide
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glassa meaningful `toString()` method may result in unexpected caching behavior. For
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glassexample, the objects `{}` and `{foo: 'bar'}` would both be converted to the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glassstring `[object Object]` when used as a cache key.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@method cached
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@param {Function} source The function to memoize.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@param {Object} [cache={}] Object in which to store cached values. You may seed
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass this object with pre-existing cached values if desired.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@param {any} [refetch] If supplied, this value is compared with the cached value
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass using a `==` comparison. If the values are equal, the wrapped function is
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass executed again even though a cached value exists.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@return {Function} Wrapped function.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return function (arg) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Array.prototype.join.call(arguments, CACHED_DELIMITER) :
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (!(key in cache) || (refetch && cache[key] == refetch)) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassReturns a new object containing all of the properties of all the supplied
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glassobjects. The properties from later objects will overwrite those in earlier
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassPassing in a single object will create a shallow copy of it. For a deep copy,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glassuse `clone()`.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@method merge
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@param {Object} objects* One or more objects to merge.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@return {Object} A new merged object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassY.merge = function () {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (; i < len; ++i) {
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan GroveMixes _supplier_'s properties into _receiver_.
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan GroveProperties on _receiver_ or _receiver_'s prototype will not be overwritten or
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Groveshadowed unless the _overwrite_ parameter is `true`, and will not be merged
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Groveunless the _merge_ parameter is `true`.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassIn the default mode (0), only properties the supplier owns are copied (prototype
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glassproperties are not copied). The following copying modes are available:
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * `0`: _Default_. Object to object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * `1`: Prototype to prototype.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * `2`: Prototype to prototype and object to object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * `3`: Prototype to object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * `4`: Object to prototype.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@param {Function|Object} receiver The object or function to receive the mixed
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@param {Function|Object} supplier The object or function supplying the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass properties to be mixed.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@param {Boolean} [overwrite=false] If `true`, properties that already exist
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass on the receiver will be overwritten with properties from the supplier.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@param {String[]} [whitelist] An array of property names to copy. If
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass specified, only the whitelisted properties will be copied, and all others
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass will be ignored.
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Grove@param {Number} [mode=0] Mix mode to use. See above for available modes.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@param {Boolean} [merge=false] If `true`, objects and arrays that already
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass exist on the receiver will have the corresponding object/array from the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass supplier merged into them, rather than being skipped or overwritten. When
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass both _overwrite_ and _merge_ are `true`, _merge_ takes precedence.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass@return {Function|Object|YUI} The receiver, or the YUI instance if the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass specified receiver is falsy.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassY.mix = function(receiver, supplier, overwrite, whitelist, mode, merge) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var alwaysOverwrite, exists, from, i, key, len, to;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // If no supplier is given, we return the receiver. If no receiver is given,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // we return Y. Returning Y doesn't make much sense to me, but it's
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // grandfathered in for backcompat reasons.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // In mode 2 (prototype to prototype and object to object), we recurse
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // once to do the proto to proto mix. The object to object mix will be
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // handled later on.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.mix(receiver.prototype, supplier.prototype, overwrite,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Depending on which mode is specified, we may be copying from or to
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // the prototypes of the supplier and receiver.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass from = mode === 1 || mode === 3 ? supplier.prototype : supplier;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass to = mode === 1 || mode === 4 ? receiver.prototype : receiver;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // If either the supplier or receiver doesn't actually have a
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // prototype property, then we could end up with an undefined `from`
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // or `to`. If that happens, we abort and return the receiver.
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Grove // If `overwrite` is truthy and `merge` is falsy, then we can skip a
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Grove // property existence check on each iteration and save some time.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (i = 0, len = whitelist.length; i < len; ++i) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // We call `Object.prototype.hasOwnProperty` instead of calling
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // `hasOwnProperty` on the object itself, since the object's
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // `hasOwnProperty` method may have been overridden or removed.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Also, some native objects don't implement a `hasOwnProperty`
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Grove // The `key in to` check here is (sadly) intentional for backwards
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Grove // compatibility reasons. It prevents undesired shadowing of
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Grove // prototype members on `to`.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // If we're in merge mode, and the key is present on both
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // objects, and the value on both objects is either an object or
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // an array (but not a function), then we recurse to merge the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // `from` value into the `to` value instead of overwriting it.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Note: It's intentional that the whitelist isn't passed to the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // recursive call here. This is legacy behavior that lots of
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // code still depends on.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.mix(to[key], from[key], overwrite, null, 0, merge);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // We're not in merge mode, so we'll only copy the `from` value
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // to the `to` value if we're in overwrite mode or if the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // current key doesn't exist on the `to` object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // The code duplication here is for runtime performance reasons.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Combining whitelist and non-whitelist operations into a single
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // loop or breaking the shared logic out into a function both result
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // in worse performance, and Y.mix is critical enough that the byte
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // tradeoff is worth it.
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Grove // The `key in to` check here is (sadly) intentional for backwards
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Grove // compatibility reasons. It prevents undesired shadowing of
0e0b1aea8a2b10793017ac8c04119623792bd96fRyan Grove // prototype members on `to`.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.mix(to[key], from[key], overwrite, null, 0, merge);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // If this is an IE browser with the JScript enumeration bug, force
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // enumeration of the buggy properties by making a recursive call with
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // the buggy properties as the whitelist.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (Y.Object._hasEnumBug) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass Y.mix(to, from, overwrite, Y.Object._forceEnum, mode, merge);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The YUI module contains the components required for building the YUI
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * seed file. This includes the script loading mechanism, a simple queue,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * and the core utilities for the library.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @module yui
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @submodule yui-base
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Adds utilities to the YUI instance for working with objects.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @class Object
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// If either MooTools or Prototype is on the page, then there's a chance that we
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// can't trust "native" language features to actually be native. When this is
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// the case, we take the safe route and fall back to our own non-native
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// implementations.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassunsafeNatives = win && !!(win.MooTools || win.Prototype),
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassUNDEFINED, // <-- Note the comma. We're still declaring vars.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns a new object that uses _obj_ as its prototype. This method wraps the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * native ES5 `Object.create()` method if available, but doesn't currently
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * pass through `Object.create()`'s second argument (properties) in order to
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * ensure compatibility with older browsers.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method ()
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj Prototype object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Object} New object using _obj_ as its prototype.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassO = Y.Object = (!unsafeNatives && Object.create) ? function (obj) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // We currently wrap the native Object.create instead of simply aliasing it
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // to ensure consistency with our fallback shim, which currently doesn't
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // support Object.create()'s second argument (properties). Once we have a
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // safe fallback for the properties arg, we can stop wrapping
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Object.create().
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass} : (function () {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Reusable constructor function for the Object.create() shim.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass function F() {}
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // The actual shim.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return function (obj) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return new F();
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Property names that IE doesn't enumerate in for..in loops, even when they
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * should be enumerable. When `_hasEnumBug` is `true`, it's necessary to
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * manually enumerate these properties.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property _forceEnum
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type String[]
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @protected
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass 'hasOwnProperty',
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass 'isPrototypeOf',
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass 'propertyIsEnumerable',
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass 'toLocaleString',
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * `true` if this browser has the JScript enumeration bug that prevents
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * enumeration of the properties named in the `_forceEnum` array, `false`
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * otherwise.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * - <https://developer.mozilla.org/en/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug>
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * - <http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation>
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property _hasEnumBug
10bc435f4f69ce3ae4b6b3a55d032e158f7ee04fRyan Grove * @type Boolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @protected
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlasshasEnumBug = O._hasEnumBug = !{valueOf: 0}.propertyIsEnumerable('valueOf'),
10bc435f4f69ce3ae4b6b3a55d032e158f7ee04fRyan Grove * `true` if this browser incorrectly considers the `prototype` property of
10bc435f4f69ce3ae4b6b3a55d032e158f7ee04fRyan Grove * functions to be enumerable. Currently known to affect Opera 11.50.
10bc435f4f69ce3ae4b6b3a55d032e158f7ee04fRyan Grove * @property _hasProtoEnumBug
10bc435f4f69ce3ae4b6b3a55d032e158f7ee04fRyan Grove * @type Boolean
10bc435f4f69ce3ae4b6b3a55d032e158f7ee04fRyan Grove * @protected
10bc435f4f69ce3ae4b6b3a55d032e158f7ee04fRyan GrovehasProtoEnumBug = O._hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns `true` if _key_ exists on _obj_, `false` if _key_ doesn't exist or
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * exists only on _obj_'s prototype. This is essentially a safer version of
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * `obj.hasOwnProperty()`.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method owns
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj Object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {String} key Property name to look for.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass}; // <-- End of var declarations.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Alias for `owns()`.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method hasKey
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj Object to test.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {String} key Property name to look for.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns an array containing the object's enumerable keys. Does not include
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * prototype keys or non-enumerable keys.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Note that keys are returned in enumeration order (that is, in the same order
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * that they would be enumerated by a `for-in` loop), which may not be the same
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * as the order in which they were defined.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * This method is an alias for the native ES5 `Object.keys()` method if
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * available.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Y.Object.keys({a: 'foo', b: 'bar', c: 'baz'});
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // => ['a', 'b', 'c']
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method keys
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj An object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {String[]} Array of keys.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav GlassO.keys = (!unsafeNatives && Object.keys) || function (obj) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass throw new TypeError('Object.keys called on a non-object');
10bc435f4f69ce3ae4b6b3a55d032e158f7ee04fRyan Grove if (hasProtoEnumBug && typeof obj === 'function') {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (i = 0, len = forceEnum.length; i < len; ++i) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns an array containing the values of the object's enumerable keys.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Note that values are returned in enumeration order (that is, in the same
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * order that they would be enumerated by a `for-in` loop), which may not be the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * same as the order in which they were defined.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Y.Object.values({a: 'foo', b: 'bar', c: 'baz'});
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * // => ['foo', 'bar', 'baz']
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method values
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj An object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Array} Array of values.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (; i < len; ++i) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns the number of enumerable keys owned by an object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method size
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj An object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Number} The object's size.
aa3eb862908fbaa7fe237987a5937e6f93351dceRyan Grove } catch (ex) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns `true` if the object owns an enumerable property with the specified
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method hasValue
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj An object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {any} value The value to search for.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Boolean} `true` if _obj_ contains _value_, `false` otherwise.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return Y.Array.indexOf(O.values(obj), value) > -1;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Executes a function on each enumerable property in _obj_. The function
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * receives the value, the key, and the object itself as parameters (in that
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * By default, only properties owned by _obj_ are enumerated. To include
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * prototype properties, set the _proto_ parameter to `true`.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method each
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj Object to enumerate.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Function} fn Function to execute on each enumerable property.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {mixed} fn.value Value of the current property.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {String} fn.key Key of the current property.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} fn.obj Object being enumerated.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} [thisObj] `this` object to use when calling _fn_.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Boolean} [proto=false] Include prototype properties.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {YUI} the YUI instance.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @chainable
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Executes a function on each enumerable property in _obj_, but halts if the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * function returns a truthy value. The function receives the value, the key,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * and the object itself as paramters (in that order).
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * By default, only properties owned by _obj_ are enumerated. To include
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * prototype properties, set the _proto_ parameter to `true`.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method some
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj Object to enumerate.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Function} fn Function to execute on each enumerable property.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {mixed} fn.value Value of the current property.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {String} fn.key Key of the current property.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} fn.obj Object being enumerated.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} [thisObj] `this` object to use when calling _fn_.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Boolean} [proto=false] Include prototype properties.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Boolean} `true` if any execution of _fn_ returns a truthy value,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * `false` otherwise.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return true;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass return false;
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Retrieves the sub value at the provided path,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * from the value object provided.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method getValue
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object from which to extract the property value.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param path {Array} A path array, specifying the object traversal path
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * from which to obtain the sub value.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Any} The value stored in the path, undefined if not found,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * undefined if the source is not an object. Returns the source object
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * if an empty path is provided.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass p = Y.Array(path),
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass o = o[p[i]];
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Sets the sub-attribute value at the provided path on the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * value object. Returns the modified value object, or
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * undefined if the path is invalid.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method setValue
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param o The object on which to set the sub value.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param path {Array} A path array, specifying the object traversal path
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * at which to set the sub value.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param val {Any} The new value for the sub-attribute.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Object} The modified object, with the new sub value set, or
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * undefined, if the path was invalid.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass p = Y.Array(path),
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass for (i = 0; ref !== UNDEFINED && i < leafIdx; i++) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Returns `true` if the object has no enumerable properties of its own.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @method isEmpty
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @param {Object} obj An object.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @return {Boolean} `true` if the object is empty.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @since 3.2.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The YUI module contains the components required for building the YUI seed
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * file. This includes the script loading mechanism, a simple queue, and the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * core utilities for the library.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @module yui
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @submodule yui-base
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * YUI user agent detection.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Do not fork for a browser if it can be avoided. Use feature detection when
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * you can. Use the user agent as a last resort. For all fields listed
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * as @type float, UA stores a version number for the browser engine,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * 0 otherwise. This value may or may not map to the version number of
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * the browser using the engine. The value is presented as a float so
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * that it can easily be used for boolean evaluation as well as for
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * looking for a particular range of versions. Because of this,
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * some of the granularity of the version info may be lost. The fields that
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * are @type string default to null. The API docs list the values that
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * these fields can have.
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith* Static method on `YUI.Env` for parsing a UA string. Called at instantiation
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith* to populate `Y.UA`.
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith* @method parseUA
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith* @param {String} [subUA=navigator.userAgent] UA string to parse
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass* @returns {Object} The Y.UA object
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass var numberify = function(s) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Internet Explorer version number or 0. Example: 6
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property ie
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Opera version number or 0. Example: 9.2
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property opera
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Gecko engine revision number. Will evaluate to 1 if Gecko
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * is detected but the revision could not be found. Other browsers
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * will be 0. Example: 1.8
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Firefox 1.5.0.9: 1.8.0.9 <-- 1.8
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Firefox 2.0.0.3: 1.8.1.3 <-- 1.81
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Firefox 3.0 <-- 1.9
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Firefox 3.5 <-- 1.91
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property gecko
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * AppleWebKit version. KHTML browsers that are not WebKit browsers
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * will evaluate to 1, other browsers 0. Example: 418.9
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * latest available for Mac OSX 10.3.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Safari 2.0.2: 416 <-- hasOwnProperty introduced
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Safari 2.0.4: 418 <-- preventDefault fixed
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * different versions of webkit
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * updated, but not updated
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * to the latest patch.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * SVG and many major issues fixed).
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Safari 3.0.4 (523.12) 523.12 <-- First Tiger release - automatic
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * update from 2.x via the 10.4.11 OS patch.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * yahoo.com user agent hack removed.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * http://en.wikipedia.org/wiki/Safari_version_history
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property webkit
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Safari will be detected as webkit, but this property will also
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * be populated with the Safari version number
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property safari
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Chrome will be detected as webkit, but this property will also
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * be populated with the Chrome version number
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property chrome
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The mobile property will be set to a string containing any relevant
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * user agent information when a modern mobile browser is detected.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * devices with the WebKit-based browser, and Opera Mini.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property mobile
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default null
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Adobe AIR version number or 0. Only populated if webkit is detected.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Example: 1.0
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property air
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Detects Apple iPad's OS version
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property ipad
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Detects Apple iPhone's OS version
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property iphone
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Detects Apples iPod's OS version
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property ipod
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * General truthy check for iPad, iPhone or iPod
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property ios
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default null
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Detects Googles Android OS version
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property android
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Detects Palms WebOS version
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property webos
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Google Caja version number or 0.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property caja
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type float
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * Set to true if the page appears to be in SSL
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property secure
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type boolean
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * The operating system. Currently only detecting windows or macintosh
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @property os
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @type string
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass * @default null
2b7903ae0f8e77339133aac32cf37c4ced6b195dDav Glass * The Nodejs Version
2b7903ae0f8e77339133aac32cf37c4ced6b195dDav Glass * @property nodejs
2b7903ae0f8e77339133aac32cf37c4ced6b195dDav Glass * @type float
2b7903ae0f8e77339133aac32cf37c4ced6b195dDav Glass * @default 0
31ec578faf84a19206019b9e99a5ba8a71df16a5Dav Glass * The User Agent string that was parsed
31ec578faf84a19206019b9e99a5ba8a71df16a5Dav Glass * @property userAgent
31ec578faf84a19206019b9e99a5ba8a71df16a5Dav Glass * @type String
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass o.secure = href && (href.toLowerCase().indexOf('https') === 0);
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Modern KHTML browsers should qualify as Safari X-Grade
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Modern WebKit browsers are at least X-Grade
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[1]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Mobile browser check
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[1]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[0]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass // Nokia N-series, webOS, ex: NokiaN95
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[1]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[1]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[1]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass// @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[1]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[1]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } else { // not opera or webkit
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[1]) {
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass } else { // not opera, webkit, or ie
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass if (m && m[1]) {
d70d9a880191e4db866518d070be4d6a3cab676aDav Glass //It was a parsed UA, do not assign the global value.
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "anim": ["anim-base","anim-color","anim-curve","anim-easing","anim-node-plugin","anim-scroll","anim-xy"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "attribute": ["attribute-base","attribute-complex"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "autocomplete": ["autocomplete-base","autocomplete-sources","autocomplete-list","autocomplete-plugin"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "base": ["base-base","base-pluginhost","base-build"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "cache": ["cache-base","cache-offline","cache-plugin"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "collection": ["array-extras","arraylist","arraylist-add","arraylist-filter","array-invoke"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "dataschema": ["dataschema-base","dataschema-json","dataschema-xml","dataschema-array","dataschema-text"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "datasource": ["datasource-local","datasource-io","datasource-get","datasource-function","datasource-cache","datasource-jsonschema","datasource-xmlschema","datasource-arrayschema","datasource-textschema","datasource-polling"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "datatable": ["datatable-base","datatable-datasource","datatable-sort","datatable-scroll"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "datatype": ["datatype-number","datatype-date","datatype-xml"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "datatype-date": ["datatype-date-parse","datatype-date-format"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "datatype-number": ["datatype-number-parse","datatype-number-format"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "datatype-xml": ["datatype-xml-parse","datatype-xml-format"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "dd": ["dd-ddm-base","dd-ddm","dd-ddm-drop","dd-drag","dd-proxy","dd-constrain","dd-drop","dd-scroll","dd-delegate"],
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney "dom": ["dom-base","dom-screen","dom-style","selector-native","selector"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "editor": ["frame","selection","exec-command","editor-base","editor-para","editor-br","editor-bidi","editor-tab","createlink-base"],
cae6c3e5f419ce0ccc48676357b4fb70b31f1642Luke Smith "event": ["event-base","event-delegate","event-synthetic","event-mousewheel","event-mouseenter","event-key","event-focus","event-resize","event-hover","event-outside","event-touch","event-move","event-flick","event-valuechange"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "event-custom": ["event-custom-base","event-custom-complex"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "highlight": ["highlight-base","highlight-accentfold"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "history": ["history-base","history-hash","history-hash-ie","history-html5"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "io": ["io-base","io-xdr","io-form","io-upload-iframe","io-queue"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "loader": ["loader-base","loader-rollup","loader-yui3"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "node": ["node-base","node-event-delegate","node-pluginhost","node-screen","node-style"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "pluginhost": ["pluginhost-base","pluginhost-config"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "querystring": ["querystring-parse","querystring-stringify"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "recordset": ["recordset-base","recordset-sort","recordset-filter","recordset-indexer"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "resize": ["resize-base","resize-proxy","resize-constrain"],
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass "slider": ["slider-base","slider-value-range","clickable-rail","range-slider"],
9fe828490d8f0a4ebaa725655a93f54040acc332Dav Glass "widget": ["widget-base","widget-htmlparser","widget-uievents","widget-skin"]
cfb5c556e841b63b73ea6328df5fd730963e0c44Dav Glass}, '@VERSION@' );