yui-base.js revision a73fb7e86d966d3c6f187d2da6d1e0fa9ec3d7e9
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx(function() {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx// @TODO: this needs to be created at build time from module metadata
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * The YUI global namespace object. If YUI is already defined, the
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * existing YUI object will not be overwritten so that defined
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * namespaces are preserved.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @class YUI
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @constructor
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @uses Event.Target
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o Optional configuration object. Options:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>------------------------------------------------------------------------</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>Global:</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>------------------------------------------------------------------------</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>debug:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Turn debug statements on or off</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>useConsole:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Log to the browser console if debug is on and the console is available</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>logInclude:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * A hash of log sources that should be logged. If specified, only log messages from these sources will be logged.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>logExclude:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * A hash of log sources that should be not be logged. If specified, all sources are logged if not on this list.</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>throwFail:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * If throwFail is set, Y.fail will generate or re-throw a JS error. Otherwise the failure is logged.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>win:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * The target window/frame</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>core:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * A list of modules that defines the YUI core (overrides the default)</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>------------------------------------------------------------------------</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>For event and get:</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>------------------------------------------------------------------------</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>pollInterval:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * The default poll interval</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>-------------------------------------------------------------------------</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>For loader:</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>-------------------------------------------------------------------------</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>base:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * The base dir</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>secureBase:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * The secure base dir (not implemented)</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>comboBase:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>root:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>filter:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * A filter to apply to result urls. This filter will modify the default
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * path for all modules. The default path for the YUI library is the
19b23afcc35b3926d062efc1930e65c5fed1084dhx * minified version of the files (e.g., event-min.js). The filter property
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * can be a predefined filter or a custom filter. The valid predefined
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * filters are:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <dt>DEBUG</dt>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <dd>Selects the debug versions of the library (e.g., event-debug.js).
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * This option will automatically include the logger widget</dd>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <dt>RAW</dt>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * You can also define a custom filter, which must be an object literal
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * containing a search expression and a replace string:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * myFilter: {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * 'searchExp': "-min\\.js",
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * 'replaceStr': "-debug.js"
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>combine:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>ignore:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * A list of modules that should never be dynamically loaded</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>force:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * A list of modules that should always be loaded when required, even if already present on the page</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>insertBefore:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Node or id for a node that should be used as the insertion point for new nodes</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>charset:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * charset for dynamic nodes</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>timeout:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>context:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * execution context for all callbacks</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>onSuccess:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * callback for the 'success' event</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>onFailure:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * callback for the 'failure' event</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>onTimeout:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * callback for the 'timeout' event</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>onProgress:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * callback executed each time a script or css file is loaded</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * <li>modules:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * A list of module definitions. See Loader.addModule for the supported module metadata</li>
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx /*global YUI*/
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx YUI = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var Y = this;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // Allow var yui = YUI() instead of var yui = new YUI()
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (Y == window) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return new YUI(o);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // set up the core environment
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // bind the specified additional modules for this instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx// The prototype contains the functions that are required to allow the external
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx// modules to be registered and for the instance to be initialized.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Initialize this YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o config options
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @private
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx _init: function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx o = o || {};
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // find targeted window and @TODO create facades
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var w = (o.win) ? (o.win.contentWindow) : o.win || window;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @TODO default throwFail to true in PR2
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // o.throwFail = ('throwFail' in o) ? o.debug : true;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // add a reference to o for anything that needs it
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // before _setup is called.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @todo expand the new module metadata
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Finishes the instance setup. Attaches whatever modules were defined
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * when the yui modules was registered.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method _setup
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @private
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx _setup: function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @TODO eval the need to copy the config
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Executes a method on a YUI instance with
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * the specified id if the specified method is whitelisted.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method applyTo
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param id {string} the YUI instance id
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param method {string} the name of the method to exectute.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Ex: 'Object.keys'
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param args {Array} the arguments to apply to the method
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {object} the return value from the applied method or null
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return null;
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf m = m[nest[i]];
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return null;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Register a module
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method add
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param name {string} module name
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param namespace {string} name space for the module
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param fn {Function} entry point into the module that
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * is used to bind module to the YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param version {string} version string
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {YUI} the YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * requires - features that should be present before loading
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * optional - optional features that should be present if load optional defined
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * use - features that should be attached automatically
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * skinnable -
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * omit - features that should not be loaded if this module is present
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @todo expand this to include version mapping
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @todo allow requires/supersedes
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @todo may want to restore the build property
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @todo fire moduleAvailable event
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan return this; // chain support
6f12def440a1ce798ab128210a43414d173669f0pengcheng chen - Sun Microsystems - Beijing China var name = r[i], m = mods[name], mm;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Bind a module to a YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param modules* {string} 1-n modules to bind (uses arguments array)
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param *callback {function} callback function executed when
faceed938d6ba7344a332694084d213905e93375fei feng - Sun Microsystems - Beijing China * the instance has the required functionality. If included, it
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * must be the last parameter.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Implement versioning? loader can load different versions?
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Should sub-modules/plugins be normal modules, or do
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * we add syntax for specifying these?
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI().use('dragdrop')
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI().use('dragdrop:2.4.0'); // specific version
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI().use('dragdrop:2.4.0-'); // at least this version
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI().use('dragdrop:2.4.0-2.9999.9999'); // version range
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI().use('*'); // use all available modules
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI().use('lang+dump+substitute'); // use lang and some plugins
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI().use('lang+*'); // use lang and all known plugins
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {YUI} the YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx use: function() {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var Y = this,
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // The last argument supplied to use can be a load complete callback
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // YUI().use('*'); // bind everything available
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx for (var k in mods) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // use loader to optimize and sort the requirements if it
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // is available.
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan // only attach a module once
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // make sure requirements are attached
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // add this module to full list of things to attach
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // process each requirement and any additional requirements
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // the module metadata specifies
09539a3c2da6fef054f5306232ef0480de261eabpengcheng chen - Sun Microsystems - Beijing China msg: 'not dynamic'
09539a3c2da6fef054f5306232ef0480de261eabpengcheng chen - Sun Microsystems - Beijing China if (Y.Env._callback) {
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China var cb = Y.Env._callback;
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China Y.Env._callback = null;
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China cb(Y, fromLoader);
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China Y.fire('yui:load', Y, fromLoader);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // dynamic load
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return Y; // chain support var yui = YUI().use('dragdrop');
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Returns the namespace specified and creates it if it doesn't exist
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI.namespace("property.package");
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI.namespace("YUI.property.package");
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Either of the above would create YUI.property, then
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI.property.package
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Be careful when naming packages. Reserved words may work in some browsers
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * and not others. For instance, the following will fail in Safari:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI.namespace("really.long.nested.namespace");
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * This fails because "long" is a future reserved word in ECMAScript
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method namespace
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param {string*} arguments 1-n namespaces to create
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {object} A reference to the last namespace object created
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx namespace: function() {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var a=arguments, o=null, i, j, d;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx o[d[j]] = o[d[j]] || {};
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx o = o[d[j]];
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // this is replaced if the log module is included
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx log: function() {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Report an error. The reporting mechanism is controled by
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * the 'throwFail' configuration attribute. If throwFail is
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * not specified, the message is written to the logger, otherwise
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * a JS error is thrown
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method fail
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param msg {string} the failure message
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param e {Error} Optional JS error that was caught. If supplied
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * and throwFail is specified, this error will be re-thrown.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {YUI} this YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var instance = this;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return this;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Generate an id that is unique among all YUI instances
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method guid
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param pre {string} optional guid prefix
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {string} the guid
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * Stamps an object with a guid. If the object already
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * has one, a new one is not created
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method stamp
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o The object to stamp
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {string} The object's guid
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx stamp: function(o) {
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf// Give the YUI global the same properties as an instance.
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf// This makes it so that the YUI global can be used like the YAHOO
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf// global was used prior to 3.x. More importantly, the YUI global
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf// provides global metadata, so env needs to be configured.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx// @TODO review
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // inheritance utilities are not available yet
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx for (i in p) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (true) { // hasOwnProperty not available yet and not needed
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx Y[i] = p[i];
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China // set up the environment
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI stub
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @submodule yui-base
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf// This is just a stub to for dependency processing
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI console logger
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @submodule log
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf * If the 'debug' config is true, a 'yui:log' event will be
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * dispatched, which the logger widget and anything else
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * can consume. If the 'useConsole' config is true, it will
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * write to the browser console if available.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method log
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @for YUI
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param {String} msg The message to log.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param {String} cat The log category for the message. Default
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * categories are "info", "warn", "error", time".
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Custom categories can be used as well. (opt)
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param {String} src The source of the the message (opt)
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {YUI} YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // suppress log message if the config is off or the event stack
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // or the event call stack contains a consumer of the yui:log event
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // apply source filters
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // console.log('checking src filter: ' + src + ', inc: ' + inc + ', exc: ' + exc);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // console.log('bail: inc list found, but src is not in list: ' + src);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // console.log('bail: exc list found, and src is in it: ' + src);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx}, "@VERSION@");
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI lang utils
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @submodule lang
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Provides the language utilites and extensions used by the library
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @class Lang
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Determines whether or not the provided object is an array.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Testing typeof/instanceof/constructor of arrays across frame
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * boundaries isn't possible in Safari unless you have a reference
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * to the other frame to test against its Array prototype. To
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * handle this case, we test well-known array properties instead.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * properties.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @TODO can we kill this cross frame hack?
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method isArray
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o The object to test
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {boolean} true if o is an array
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx L.isArray = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx //return L.isNumber(o.length) && L.isFunction(o.splice);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return false;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Determines whether or not the provided object is a boolean
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method isBoolean
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o The object to test
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {boolean} true if o is a boolean
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx L.isBoolean = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return typeof o === 'boolean';
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Determines whether or not the provided object is a function
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method isFunction
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o The object to test
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {boolean} true if o is a function
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx L.isFunction = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return typeof o === 'function';
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Determines whether or not the supplied object is a date instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method isDate
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o The object to test
19b23afcc35b3926d062efc1930e65c5fed1084dhx * @return {boolean} true if o is a date
19b23afcc35b3926d062efc1930e65c5fed1084dhx L.isDate = function(o) {
19b23afcc35b3926d062efc1930e65c5fed1084dhx return o instanceof Date;
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China * Determines whether or not the provided object is null
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China * @method isNull
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China * @param o The object to test
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China * @return {boolean} true if o is null
19b23afcc35b3926d062efc1930e65c5fed1084dhx L.isNull = function(o) {
19b23afcc35b3926d062efc1930e65c5fed1084dhx return o === null;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Determines whether or not the provided object is a legal number
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method isNumber
42516a0c6ebf6e259c2abcd1ca315fec43268f39xinghua wen - Sun Microsystems - Beijing China * @param o The object to test
42516a0c6ebf6e259c2abcd1ca315fec43268f39xinghua wen - Sun Microsystems - Beijing China * @return {boolean} true if o is a number
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx L.isNumber = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Determines whether or not the provided object is of type object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * or function
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method isObject
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o The object to test
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param failfn {boolean} fail if the input is a function
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {boolean} true if o is an object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hxreturn (o && (typeof o === 'object' || (!failfn && L.isFunction(o)))) || false;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Determines whether or not the provided object is a string
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method isString
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o The object to test
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {boolean} true if o is a string
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx L.isString = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return typeof o === 'string';
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Determines whether or not the provided object is undefined
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method isUndefined
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o The object to test
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {boolean} true if o is undefined
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx L.isUndefined = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return typeof o === 'undefined';
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Returns a string without any leading or trailing whitespace. If
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * the input is not a string, the input will be returned untouched.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method trim
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param s {string} the string to trim
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {string} the trimmed string
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx L.trim = function(s){
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx } catch(e) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * A convenience method for detecting a legitimate non-null value.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Returns false for null/undefined/NaN, true for other values,
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * including 0/false/''
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method isValue
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o The item to test
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {boolean} true if it is not null/undefined/NaN || false
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx L.isValue = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx// return (o || o === false || o === 0 || o === ''); // Infinity fails
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hxreturn (L.isObject(o) || L.isString(o) || L.isNumber(o) || L.isBoolean(o));
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx}, "@VERSION@");
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Array utilities
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @submodule array
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI core
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Adds the following array utilities to the YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @class YUI~array
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Y.Array(o) returns an array:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * - Arrays are return unmodified unless the start position is specified.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * - "Array-like" collections (@see Array.test) are converted to arrays
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * - For everything else, a new array is created with the input as the sole item
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * - The start position is used if the input is or is like an array to return
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * a subset of the collection.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @TODO this will not automatically convert elements that are also collections
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * such as forms and selects. Passing true as the third param will
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * force a conversion.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method Array
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o the item to arrayify
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param i {int} if an array or array-like, this is the start index
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param al {boolean} if true, it forces the array-like fork. This
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * can be used to avoid multiple array.test calls.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {Array} the resulting array
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx Y.Array = function(o, i, al) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx switch (t) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return (i) ? o.slice(o, i) : o;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return [o];
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var A = Y.Array;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Evaluates the input to determine if it is an array, array-like, or
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * something else. This is used to handle the arguments collection
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * available within functions, and HTMLElement collections
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method Array.test
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @todo current implementation (intenionally) will not implicitly
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * handle html elements that are array-like (forms, selects, etc).
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {int} a number indicating the results:
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * 0: Not an array or an array-like collection
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * 1: A real array.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * 2: array-like collection.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx A.test = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var r = 0;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (L.isObject(o, true)) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (L.isArray(o)) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // indexed, but no tagName (element) or alert (window)
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if ("length" in o && !("tagName" in o) && !("alert" in o)) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx } catch(ex) {}
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Executes the supplied function on each item in the array.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method Array.each
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {YUI} the YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx function (a, f, o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx function (a, f, o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var l = a.length, i;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx f.call(o || Y, a[i], i, a);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Returns an object using the first array as keys, and
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * the second as values. If the second array is not
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * provided the value is set to true for each.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method Array.hash
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param k {Array} keyset
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param v {Array} optional valueset
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {object} the hash
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx A.hash = function(k, v) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Returns the index of the first item in the array
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * that contains the specified value, -1 if the
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * value isn't found.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @TODO use native method if avail
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method Array.indexOf
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param a {Array} the array to search
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param val the value to search for
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {int} the index of the item that contains the value or -1
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (a[i] === val) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return -1;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx}, "@VERSION@");
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI core utilities
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @submodule core
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx// requires lang
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var L = Y.Lang,
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx A = Y.Array,
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * IE will not enumerate native functions in a derived object even if the
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * function was overridden. This is a workaround for specific functions
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * we care about on the Object prototype.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @property _iefix
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param {Function} r the object to receive the augmentation
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param {Function} s the object that supplies the properties to augment
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param w a whitelist object (the keys are the valid items to reference)
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @private
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @for YUI
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx function(r, s, w) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var n = a[i], f = s[n];
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (!w || (n in w)) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx } : function() {};
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Returns a new object containing all of the properties of
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * all the supplied objects. The properties from later objects
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * will overwrite those in earlier objects. Passing in a
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * single object will create a shallow copy of it. For a deep
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * copy, use clone.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method merge
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param arguments {Object*} the objects to merge
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {object} the new merged object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx Y.merge = function() {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // var o={}, a=arguments;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // for (var i=0, l=a.length; i<l; i=i+1) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx //var a=arguments, o=Y.Object(a[0]);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var a=arguments, o={};
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx Y.mix(o, a[i], true);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Applies the supplier's properties to the receiver. By default
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * all prototype and static propertes on the supplier are applied
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * to the corresponding spot on the receiver. By default all
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * properties are applied, and a property that is already on the
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * reciever will not be overwritten. The default behavior can
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * be modified by supplying the appropriate parameters.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @TODO add constants for the modes
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method mix
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param {Function} r the object to receive the augmentation
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param {Function} s the object that supplies the properties to augment
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param ov {boolean} if true, properties already on the receiver
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * will be overwritten if found on the supplier.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param wl {string[]} a whitelist. If supplied, only properties in
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * this list will be applied to the receiver.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param {int} mode what should be copies, and to where
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * default(0): object to object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * 1: prototype to prototype (old augment)
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * 2: prototype to prototype and object props (new augment)
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * 3: prototype to object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * 4: object to prototype
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param merge {boolean} merge objects instead of overwriting/ignoring
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Used by Y.aggregate
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {object} the augmented object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @TODO review for PR2
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (!s||!r) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var w = (wl && wl.length) ? A.hash(wl) : null, m = merge,
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx for (var i in fs) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // We never want to overwrite the prototype
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // if (PROTO === i) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @TODO deal with the hasownprop issue
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // check white list if it was supplied
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (!w || iwl || (i in w)) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // if the receiver has this property, it is an object,
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // and merge is specified, merge the two objects.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // console.log('aggregate RECURSE: ' + i);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @TODO recursive or no?
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // Y.mix(fr[i], fs[i]); // not recursive
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // otherwise apply the property only if overwrite
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // is specified or the receiver doesn't have one.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @TODO make sure the 'arr' check isn't desructive
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // console.log('hash: ' + i);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // if merge is specified and the receiver is an array,
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // append the array item
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx } else if (arr) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // console.log('array: ' + i);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // @TODO probably will need to remove dups
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx switch (mode) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx f(r, sp, true);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx default: // object to object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx}, "@VERSION@");
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI object utilities
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @submodule object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Adds the following Object utilities to the YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @class YUI~object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Y.Object(o) returns a new object based upon the supplied object.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method Object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o the supplier object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {object} the new object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx Y.Object = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var F = function() {};
faceed938d6ba7344a332694084d213905e93375fei feng - Sun Microsystems - Beijing China F.prototype = o;
faceed938d6ba7344a332694084d213905e93375fei feng - Sun Microsystems - Beijing China var O = Y.Object, L = Y.Lang;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Determines whether or not the property was added
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * to the object instance. Returns false if the property is not present
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * in the object, or was inherited from the prototype.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @deprecated Safari 1.x support has been removed, so this is simply a
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * wrapper for the native implementation. Use the native implementation
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * directly instead.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @TODO Remove in PR2
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method Object.owns
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o {any} The object being testing
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param p {string} the property to look for
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {boolean} true if the object has the property on the instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx O.owns = function(o, p) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx return (o && o.hasOwnProperty) ? o.hasOwnProperty(p) : false;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Returns an array containing the object's keys
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method Object.keys
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o an object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {string[]} the keys
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx O.keys = function(o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var a=[], i;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx for (i in o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Executes a function on each item. The function
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * receives the value, the key, and the object
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * as paramters (in that order).
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method Object.each
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o the object to iterate
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param f {function} the function to execute
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param c the execution context
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param proto {boolean} include proto
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {YUI} the YUI instance
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var s = c || Y;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx for (var i in o) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx f.call(s, o[i], i, o);
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx}, "@VERSION@");
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI user agent detection
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @submodule ua
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @class UA
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx Y.UA = function() {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Internet Explorer version number or 0. Example: 6
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @property ie
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @type float
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Opera version number or 0. Example: 9.2
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf * @property opera
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf * @type float
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Gecko engine revision number. Will evaluate to 1 if Gecko
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * is detected but the revision could not be found. Other browsers
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * will be 0. Example: 1.8
bb5141e1c6407f6c507d7d05e75a1631f851389chx * Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Firefox 1.5.0.9: 1.8.0.9 <-- Reports 1.8
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Firefox 2.0.0.3: 1.8.1.3 <-- Reports 1.8
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Firefox 3 alpha: 1.9a4 <-- Reports 1.9
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @property gecko
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @type float
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * AppleWebKit version. KHTML browsers that are not WebKit browsers
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * will evaluate to 1, other browsers 0. Example: 418.9.1
bb5141e1c6407f6c507d7d05e75a1631f851389chx * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
bb5141e1c6407f6c507d7d05e75a1631f851389chx * latest available for Mac OSX 10.3.
bb5141e1c6407f6c507d7d05e75a1631f851389chx * Safari 2.0.2: 416 <-- hasOwnProperty introduced
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * Safari 2.0.4: 418 <-- preventDefault fixed
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * different versions of webkit
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * updated, but not updated
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * to the latest patch.
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native SVG
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * and many major issues fixed).
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * Safari 3.0.4 (523.12) 523.12 <-- First Tiger release - automatic update
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * from 2.x via the 10.4.11 OS patch
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * http://developer.apple.com/internet/safari/uamatrix.html
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * @property webkit
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * @type float
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * The mobile property will be set to a string containing any relevant
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * user agent information when a modern mobile browser is detected.
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * devices with the WebKit-based browser, and Opera Mini.
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * @property mobile
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China * @type string
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China mobile: null
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China var ua=navigator.userAgent, m;
bb5141e1c6407f6c507d7d05e75a1631f851389chx // Modern KHTML browsers should qualify as Safari X-Grade
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx // Modern WebKit browsers are at least X-Grade
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China m=ua.match(/AppleWebKit\/([^\s]*)/);
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China if (m&&m[1]) {
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China o.webkit=parseFloat(m[1]);
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China // Mobile browser check
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China if (/ Mobile\//.test(ua)) {
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China o.mobile = "Apple"; // iPhone or iPod Touch
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China m=ua.match(/NokiaN[^\/]*/);
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China o.mobile = m[0]; // Nokia N-series, ex: NokiaN95
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (m&&m[1]) {
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China o.opera=parseFloat(m[1]);
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China m=ua.match(/Opera Mini[^;]*/);
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx } else { // not opera or webkit
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (m&&m[1]) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx } else { // not opera, webkit, or ie
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (m&&m[1]) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx}, "@VERSION@");
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * YUI setTimeout/setInterval abstraction
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @module yui
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @submodule later
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx var L = Y.Lang;
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * Executes the supplied function in the context of the supplied
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * object 'when' milliseconds later. Executes the function a
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * single time unless periodic is set to true.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @method later
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @for YUI
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param when {int} the number of milliseconds to wait until the fn
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * is executed.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param o the context object.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param fn {Function|String} the function to execute or the name of
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * the method in the 'o' object to execute.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param data [Array] data that is provided to the function. This accepts
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * either a single item or an array. If an array is provided, the
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * function is executed with one parameter for each array item. If
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * you need to pass a single array parameter, it needs to be wrapped in
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * an array [myarray].
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @param periodic {boolean} if true, executes continuously at supplied
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * interval until canceled.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * @return {object} a timer object. Call the cancel() method on this object to
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx * stop the timer.
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx o = o || {};
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (!L.isArray(d)) {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx f = function() {
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China r = (periodic) ? setInterval(f, when) : setTimeout(f, when);
626dff7950e2fd00077128f6e79bacf668f45cf7pengcheng chen - Sun Microsystems - Beijing China cancel: function() {
84f7a9b9dca4f23b5f50edef0e59d7eb44301114hx if (this.interval) {
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf}, "@VERSION@");
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf * YUI initializer
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf * @module yui
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf * @submodule init
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf(function() {
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf var min = ['yui-base', 'log', 'lang', 'array', 'core'], core,
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf M = function(Y) {
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf var C = Y.config;
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf // apply the minimal required functionality
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf "loader");
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf // the following will be bound automatically when this code is loaded
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf // use: core