yui-base.js revision eb86457f85638a9eb7c4d5f84eb367d24061abfb
0fdefaa9ca017edfb76b736c825b34186f33045aTripp * @module yui
0fdefaa9ca017edfb76b736c825b34186f33045aTripp(function() {
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp var _instances = {}, _startTime = new Date().getTime(), Y, p, i,
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp// @TODO: this needs to be created at build time from module metadata
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp// reduce to one or the other
a89ad754cce3cfc8aee71760e10217b54020360dTripp * The YUI global namespace object. If YUI is already defined, the
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * existing YUI object will not be overwritten so that defined
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * namespaces are preserved.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @class YUI
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @constructor
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @uses Event.Target
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param o Optional configuration object. Options:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <li>------------------------------------------------------------------------</li>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <li>Global:</li>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <li>------------------------------------------------------------------------</li>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <li>debug:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Turn debug statements on or off</li>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <li>useBrowserConsole:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Log to the browser console if debug is on and the console is available</li>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <li>logInclude:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * A hash of log sources that should be logged. If specified, only log messages from these sources will be logged.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <li>logExclude:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * A hash of log sources that should be not be logged. If specified, all sources are logged if not on this list.</li>
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * <li>throwFail:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * If throwFail is set, Y.fail will generate or re-throw a JS error. Otherwise the failure is logged.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * The target window/frame</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>core:
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * A list of modules that defines the YUI core (overrides the default)</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>------------------------------------------------------------------------</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>For event and get:</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>------------------------------------------------------------------------</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>pollInterval:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * The default poll interval</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>-------------------------------------------------------------------------</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>For loader:</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>-------------------------------------------------------------------------</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>base:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * The base dir</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>secureBase:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * The secure base dir (not implemented)</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>comboBase:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>root:
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>filter:
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * A filter to apply to result urls. This filter will modify the default
a89ad754cce3cfc8aee71760e10217b54020360dTripp * path for all modules. The default path for the YUI library is the
a89ad754cce3cfc8aee71760e10217b54020360dTripp * minified version of the files (e.g., event-min.js). The filter property
a89ad754cce3cfc8aee71760e10217b54020360dTripp * can be a predefined filter or a custom filter. The valid predefined
a89ad754cce3cfc8aee71760e10217b54020360dTripp * filters are:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <dt>DEBUG</dt>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <dd>Selects the debug versions of the library (e.g., event-debug.js).
a89ad754cce3cfc8aee71760e10217b54020360dTripp * This option will automatically include the Logger widget</dd>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <dt>RAW</dt>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * You can also define a custom filter, which must be an object literal
a89ad754cce3cfc8aee71760e10217b54020360dTripp * containing a search expression and a replace string:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * myFilter: {
a89ad754cce3cfc8aee71760e10217b54020360dTripp * 'searchExp': "-min\\.js",
a89ad754cce3cfc8aee71760e10217b54020360dTripp * 'replaceStr': "-debug.js"
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>combine:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * <li>ignore:
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * A list of modules that should never be dynamically loaded</li>
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * <li>force:
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * A list of modules that should always be loaded when required, even if already present on the page</li>
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * <li>insertBefore:
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * Node or id for a node that should be used as the insertion point for new nodes</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>charset:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * charset for dynamic nodes</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>timeout:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>context:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * execution context for all callbacks</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>onSuccess:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * callback for the 'success' event</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>onFailure:
a89ad754cce3cfc8aee71760e10217b54020360dTripp * callback for the 'failure' event</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp * <li>onTimeout:
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * callback for the 'timeout' event</li>
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * <li>onProgress:
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * callback executed each time a script or css file is loaded</li>
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * <li>modules:
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * A list of module definitions. See Loader.addModule for the supported module metadata</li>
a89ad754cce3cfc8aee71760e10217b54020360dTripp /*global YUI*/
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // Make a function, disallow direct instantiation
a89ad754cce3cfc8aee71760e10217b54020360dTripp YUI = function(o) {
a89ad754cce3cfc8aee71760e10217b54020360dTripp var Y = this;
a89ad754cce3cfc8aee71760e10217b54020360dTripp // Allow instantiation without the new operator
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if (!(Y instanceof YUI)) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return new YUI(o);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // set up the core environment
c093c1aed867e18aa4778708592e1ceb45d18cffTripp // bind the specified additional modules for this instance
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp// The prototype contains the functions that are required to allow the external
bf801d6851ecf7ed14742ef3639a077daecb5cf8Tripp// modules to be registered and for the instance to be initialized.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Initialize this YUI instance
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param o config options
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp _init: function(o) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp o = o || {};
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // find targeted window
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // @TODO create facades
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // @TODO resolve windowless environments
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var w = (o.win) ? (o.win.contentWindow) : o.win || window,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp v = '@VERSION@';
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp o.useBrowserConsole = ('useBrowserConsole' in o) ? o.useBrowserConsole : true;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp o.throwFail = ('throwFail' in o) ? o.throwFail : true;
c093c1aed867e18aa4778708592e1ceb45d18cffTripp // add a reference to o for anything that needs it
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // before _setup is called.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // @todo expand the new module metadata
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp v = 'test';
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Finishes the instance setup. Attaches whatever modules were defined
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * when the yui modules was registered.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method _setup
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp _setup: function(o) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // @TODO eval the need to copy the config
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // this.config = this.merge(this.config);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Executes a method on a YUI instance with
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * the specified id if the specified method is whitelisted.
c093c1aed867e18aa4778708592e1ceb45d18cffTripp * @method applyTo
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param id {string} the YUI instance id
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param method {string} the name of the method to exectute.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Ex: 'Object.keys'
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param args {Array} the arguments to apply to the method
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @return {object} the return value from the applied method or null
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return null;
cec703a844d9691646231634fe709f4ea41d278aTripp return null;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Register a module
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method add
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param name {string} module name
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param fn {Function} entry point into the module that
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * is used to bind module to the YUI instance
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param version {string} version string
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param details optional config data:
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * requires - features that should be present before loading
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * optional - optional features that should be present if load optional defined
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * use - features that should be attached automatically
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * skinnable -
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * omit - features that should not be loaded if this module is present
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @return {YUI} the YUI instance
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // this.log('Adding a new component ' + name);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // @todo expand this to include version mapping
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // @todo allow requires/supersedes
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // @todo may want to restore the build property
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // @todo fire moduleAvailable event
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return this; // chain support
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Bind a module to a YUI instance
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param modules* {string} 1-n modules to bind (uses arguments array)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param *callback {function} callback function executed when
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * the instance has the required functionality. If included, it
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * must be the last parameter.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Implement versioning? loader can load different versions?
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * Should sub-modules/plugins be normal modules, or do
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * we add syntax for specifying these?
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * YUI().use('dragdrop')
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * YUI().use('dragdrop:2.4.0'); // specific version
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * YUI().use('dragdrop:2.4.0-'); // at least this version
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * YUI().use('dragdrop:2.4.0-2.9999.9999'); // version range
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * YUI().use('*'); // use all available modules
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * YUI().use('lang+dump+substitute'); // use lang and some plugins
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * YUI().use('lang+*'); // use lang and all known plugins
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @return {YUI} the YUI instance
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp use: function() {
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp var Y = this,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp k, i, l, missing = [], r = [],
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp f = function(name) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // only attach a module once
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // make sure requirements are attached
a89ad754cce3cfc8aee71760e10217b54020360dTripp // add this module to full list of things to attach
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // The last argument supplied to use can be a load complete callback
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // YUI().use('*'); // bind everything available
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp for (k in mods) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // use loader to expand dependencies and sort the
e188eaea1f0e60d808be8a4f6ccdbbd3c9b5039bTripp // requirements if it is available.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // process each requirement and any additional requirements
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // the module metadata specifies
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // dynamic load
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return Y; // chain support var yui = YUI().use('dragdrop');
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Returns the namespace specified and creates it if it doesn't exist
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * YUI.namespace("property.package");
a89ad754cce3cfc8aee71760e10217b54020360dTripp * YUI.namespace("YAHOO.property.package");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Either of the above would create YUI.property, then
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * YUI.property.package (YAHOO is scrubbed out, this is
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * to remain compatible with YUI2)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Be careful when naming packages. Reserved words may work in some browsers
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * and not others. For instance, the following will fail in Safari:
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * YUI.namespace("really.long.nested.namespace");
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * This fails because "long" is a future reserved word in ECMAScript
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method namespace
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param {string*} arguments 1-n namespaces to create
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return {object} A reference to the last namespace object created
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp namespace: function() {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp var a=arguments, o=null, i, j, d;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; j=j+1) {
b79c07ef87dd1a48a03fc33a91c37d04f3addae2Tripp o[d[j]] = o[d[j]] || {};
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp o = o[d[j]];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // this is replaced if the log module is included
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp log: function() {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Report an error. The reporting mechanism is controled by
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * the 'throwFail' configuration attribute. If throwFail is
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * not specified, the message is written to the Logger, otherwise
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * a JS error is thrown
b79c07ef87dd1a48a03fc33a91c37d04f3addae2Tripp * @method error
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param msg {string} the error message
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @param e {Error} Optional JS error that was caught. If supplied
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * and throwFail is specified, this error will be re-thrown.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return {YUI} this YUI instance
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return this;
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * Generate an id that is unique among all YUI instances
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @method guid
cec703a844d9691646231634fe709f4ea41d278aTripp * @param pre {string} optional guid prefix
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @return {string} the guid
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp return p + '-' +
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * Returns a guid associated with an object. If the object
6c4ec9d420df654d019b936fd06bef6f769db4cbTripp * does not have one, a new one is created unless readOnly
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * is specified.
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @method stamp
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @param o The object to stamp
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @param readOnly {boolean} if true, a valid guid will only
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * be returned if the object has one assigned to it.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @return {string} The object's guid or null
9eaaa502227248d304ac9170902697d02158c1d9Tripp } catch(e) {
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp// Give the YUI global the same properties as an instance.
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp// This makes it so that the YUI global can be used like the YAHOO
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp// global was used prior to 3.x. More importantly, the YUI global
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp// provides global metadata, so env needs to be configured.
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp// @TODO review
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // inheritance utilities are not available yet
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp for (i in p) {
b79c07ef87dd1a48a03fc33a91c37d04f3addae2Tripp if (true) {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp Y[i] = p[i];
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp // set up the environment
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @module yui
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @submodule yui-base
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp(function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * If the 'debug' config is true, a 'yui:log' event will be
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * dispatched, which the Logger widget and anything else
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * can consume. If the 'useBrowserConsole' config is true, it will
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * write to the browser console if available. YUI-specific log
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * messages will only be present in the -debug versions of the
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * JS files.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method log
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {String} msg The message to log.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {String} cat The log category for the message. Default
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * categories are "info", "warn", "error", time".
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Custom categories can be used as well. (opt)
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @param {String} src The source of the the message (opt)
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @param {boolean} silent If true, the log event won't fire
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp * @return {YUI} YUI instance
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var Y = instance, c = Y.config, bail = false, exc, inc, m, f;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // suppress log message if the config is off or the event stack
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // or the event call stack contains a consumer of the yui:log event
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // apply source filters
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp // console.log('checking src filter: ' + src + ', inc: ' + inc + ', exc: ' + exc);
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp // console.log('bail: inc list found, but src is not in list: ' + src);
b57ff76ab2ce5f3017d61855f13ed04ab46a965cTripp // console.log('bail: exc list found, and src is in it: ' + src);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Write a system message. This message will be preserved in the
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * minified and raw versions of the YUI files.
7947db4b7d8682ea81598e3a4283e659a8103be6Tripp * @method log
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @param {String} msg The message to log.
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @param {String} cat The log category for the message. Default
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * categories are "info", "warn", "error", time".
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Custom categories can be used as well. (opt)
var L = Y.Lang,
TYPES = {
L.isArray = function(o) {
L.isBoolean = function(o) {
return typeof o === BOOLEAN;
L.isFunction = function(o) {
L.isDate = function(o) {
L.isNull = function(o) {
L.isNumber = function(o) {
L.isString = function(o) {
return typeof o === STRING;
L.isUndefined = function(o) {
return typeof o === UNDEFINED;
L.trim = function(s){
L.isValue = function(o) {
var t = L.type(o);
return (t && t !== UNDEFINED) || false;
L.type = function (o) {
A = function(o, i, al) {
A.test = function(o) {
if (L.isObject(o, true)) {
if (L.isArray(o)) {
} catch(ex) {}
var l = a.length, i;
f.call(o || Y, a[i], i, a);
A.hash = function(k, v) {
function(a, val) {
function(a, val) {
if (a[i] === val) {
A.numericSort = function(a, b) {
var L = Y.Lang,
var i, a = IEF, n, f;
Y.merge = function() {
Y.mix(o, a[i], true);
* @param merge {boolean} merge objects instead of overwriting/ignoring
for (i in fs) {
if (!w || iwl || (i in w)) {
} else if (arr) {
switch (mode) {
f(r, sp, true);
f(rp, s);
F.prototype = o;
if (count) {
out++;
if (o.hasOwnProperty(i)) {
return out;
O.keys = function(o) {
return _extract(o);
O.values = function(o) {
O.size = function(o) {
O.hasKey = function(o, k) {
O.hasValue = function(o, v) {
f.call(s, o[i], i, o);
return undefined;
Y.UA = function() {
* http://en.wikipedia.org/wiki/Safari_(web_browser)#Version_history
mobile: null
var L = Y.Lang,
m = o[fn];
if (!L.isArray(d)) {
d = [data];
m.apply(o, d);
cancel: function() {
if (this.interval) {
clearInterval(r);
clearTimeout(r);
// var min = ['yui-base', 'log', 'lang', 'array', 'core'], core, C = Y.config;
if (C.core) {