/*
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
version: 2.3.0
*/
/**
* The YAHOO object is the single global object used by YUI Library. It
* contains utility function for setting up namespaces, inheritance, and
* logging. YAHOO.util, YAHOO.widget, and YAHOO.example are namespaces
* created automatically for and used by the library.
* @module yahoo
* @title YAHOO Global
*/
/**
* YAHOO_config is not included as part of the library. Instead it is an
* object that can be defined by the implementer immediately before
* including the YUI library. The properties included in this object
* will be used to configure global properties needed as soon as the
* library begins to load.
* @class YAHOO_config
* @static
*/
/**
* A reference to a function that will be executed every time a YAHOO module
* is loaded. As parameter, this function will receive the version
* information for the module. See <a href="YAHOO.env.html#getVersion">
* YAHOO.env.getVersion</a> for the description of the version data structure.
* @property listener
* @type Function
* @static
* @default undefined
*/
/**
* Set to true if the library will be dynamically loaded after window.onload.
* Defaults to false
* @property injecting
* @type boolean
* @static
* @default undefined
*/
/**
* Instructs the yuiloader component to dynamically load yui components and
* their dependencies. See the yuiloader documentation for more information
* about dynamic loading
* @property load
* @static
* @default undefined
* @see yuiloader
*/
if (typeof YAHOO == "undefined") {
/**
* The YAHOO global namespace object. If YAHOO is already defined, the
* existing YAHOO object will not be overwritten so that defined
* namespaces are preserved.
* @class YAHOO
* @static
*/
var YAHOO = {};
}
/**
* Returns the namespace specified and creates it if it doesn't exist
* <pre>
* YAHOO.namespace("property.package");
* YAHOO.namespace("YAHOO.property.package");
* </pre>
* Either of the above would create YAHOO.property, then
* YAHOO.property.package
*
* Be careful when naming packages. Reserved words may work in some browsers
* and not others. For instance, the following will fail in Safari:
* <pre>
* YAHOO.namespace("really.long.nested.namespace");
* </pre>
* This fails because "long" is a future reserved word in ECMAScript
*
* @method namespace
* @static
* @param {String*} arguments 1-n namespaces to create
* @return {Object} A reference to the last namespace object created
*/
var a=arguments, o=null, i, j, d;
d=a[i].split(".");
o=YAHOO;
// YAHOO is implied, so it is ignored if it is included
o[d[j]]=o[d[j]] || {};
o=o[d[j]];
}
}
return o;
};
/**
* Uses YAHOO.widget.Logger to output a log message, if the widget is
* available.
*
* @method log
* @static
* @param {String} msg The message to log.
* @param {String} cat The log category for the message. Default
* categories are "info", "warn", "error", time".
* Custom categories can be used as well. (opt)
* @param {String} src The source of the the message (opt)
* @return {Boolean} True if the log operation was successful.
*/
if(l && l.log) {
} else {
return false;
}
};
/**
* Registers a module with the YAHOO object
* @method register
* @static
* @param {String} name the name of the module (event, slider, etc)
* @param {Function} mainClass a reference to class in the module. This
* class will be tagged with the version info
* so that it will be possible to identify the
* version that is in use when multiple versions
* have loaded
* @param {Object} data metadata object for the module. Currently it
* is expected to contain a "version" property
* and a "build" property at minimum.
*/
}
m.version = v;
m.build = b;
// fire the module load listeners
ls[i](m);
}
// label the main class
if (mainClass) {
} else {
}
};
/**
* YAHOO.env is used to keep track of what is known about the YUI library and
* the browsing environment
* @class YAHOO.env
* @static
*/
/**
* Keeps the version info for all YUI modules that have reported themselves
* @property modules
* @type Object[]
*/
modules: [],
/**
* List of functions that should be executed every time a YUI module
* reports itself.
* @property listeners
* @type Function[]
*/
listeners: []
};
/**
* Returns the version data for the specified module:
* <dl>
* <dt>name:</dt> <dd>The name of the module</dd>
* <dt>version:</dt> <dd>The version in use</dd>
* <dt>build:</dt> <dd>The build number in use</dd>
* <dt>versions:</dt> <dd>All versions that were registered</dd>
* <dt>builds:</dt> <dd>All builds that were registered.</dd>
* <dt>mainClass:</dt> <dd>An object that was was stamped with the
* current version and build. If
* mainClass.VERSION != version or mainClass.BUILD != build,
* multiple versions of pieces of the library have been
* loaded, potentially causing issues.</dd>
* </dl>
*
* @method getVersion
* @static
* @param {String} name the name of the module (event, slider, etc)
* @return {Object} The version info
*/
};
/**
* Do not fork for a browser if it can be avoided. Use feature detection when
* you can. Use the user agent as a last resort. YAHOO.env.ua stores a version
* number for the browser engine, 0 otherwise. This value may or may not map
* to the version number of the browser using the engine. The value is
* presented as a float so that it can easily be used for boolean evaluation
* as well as for looking for a particular range of versions. Because of this,
* some of the granularity of the version info may be lost (e.g., Gecko 1.8.0.9
* reports 1.8).
* @class YAHOO.env.ua
* @static
*/
var o={
/**
* Internet Explorer version number or 0. Example: 6
* @property ie
* @type float
*/
ie:0,
/**
* Opera version number or 0. Example: 9.2
* @property opera
* @type float
*/
opera:0,
/**
* Gecko engine revision number. Will evaluate to 1 if Gecko
* is detected but the revision could not be found. Other browsers
* will be 0. Example: 1.8
* <pre>
* Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7
* Firefox 1.5.0.9: 1.8.0.9 <-- Reports 1.8
* Firefox 2.0.0.3: 1.8.1.3 <-- Reports 1.8
* Firefox 3 alpha: 1.9a4 <-- Reports 1.9
* </pre>
* @property gecko
* @type float
*/
gecko:0,
/**
* AppleWebKit version. KHTML browsers that are not WebKit browsers
* will evaluate to 1, other browsers 0. Example: 418.9.1
* <pre>
* Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
* latest available for Mac OSX 10.3.
* Safari 2.0.2: 416 <-- hasOwnProperty introduced
* Safari 2.0.4: 418 <-- preventDefault fixed
* Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
* different versions of webkit
* Safari 2.0.4 (419.3): 419 <-- Current Safari release
* Webkit 212 nightly: 522+ <-- Safari 3.0 (with native SVG) should
* be higher than this
*
* </pre>
* @property webkit
* @type float
*/
webkit:0
};
// Modern KHTML browsers should qualify as Safari X-Grade
o.webkit=1;
}
// Modern WebKit browsers are at least X-Grade
if (m&&m[1]) {
}
if (!o.webkit) { // not webkit
if (m&&m[1]) {
} else { // not opera or webkit
if (m&&m[1]) {
} else { // not opera, webkit, or ie
if (m) {
if (m&&m[1]) {
}
}
}
}
}
return o;
}();
/*
* Initializes the global by creating the default namespaces and applying
* any new configuration information that is detected. This is the setup
* for env.
* @method init
* @static
* @private
*/
(function() {
if (typeof YAHOO_config != "undefined") {
if (l) {
// if YAHOO is loaded multiple times we need to check to see if
// this is a new config object. If it is, add the new component
// load listener to the stack
if (ls[i]==l) {
unique=false;
break;
}
}
if (unique) {
}
}
}
})();
/**
* Provides the language utilites and extensions used by the library
* @class YAHOO.lang
*/
/**
* Determines whether or not the provided object is an array.
* Testing typeof/instanceof/constructor of arrays across frame
* boundaries isn't possible in Safari unless you have a reference
* to the other frame to test against its Array prototype. To
* handle this case, we test well-known array properties instead.
* properties.
* @method isArray
* @param {any} o The object being testing
* @return Boolean
*/
isArray: function(o) {
if (o) {
!l.hasOwnProperty(o.length);
}
return false;
},
/**
* Determines whether or not the provided object is a boolean
* @method isBoolean
* @param {any} o The object being testing
* @return Boolean
*/
isBoolean: function(o) {
return typeof o === 'boolean';
},
/**
* Determines whether or not the provided object is a function
* @method isFunction
* @param {any} o The object being testing
* @return Boolean
*/
isFunction: function(o) {
return typeof o === 'function';
},
/**
* Determines whether or not the provided object is null
* @method isNull
* @param {any} o The object being testing
* @return Boolean
*/
isNull: function(o) {
return o === null;
},
/**
* Determines whether or not the provided object is a legal number
* @method isNumber
* @param {any} o The object being testing
* @return Boolean
*/
isNumber: function(o) {
return typeof o === 'number' && isFinite(o);
},
/**
* Determines whether or not the provided object is of type object
* or function
* @method isObject
* @param {any} o The object being testing
* @return Boolean
*/
isObject: function(o) {
},
/**
* Determines whether or not the provided object is a string
* @method isString
* @param {any} o The object being testing
* @return Boolean
*/
isString: function(o) {
return typeof o === 'string';
},
/**
* Determines whether or not the provided object is undefined
* @method isUndefined
* @param {any} o The object being testing
* @return Boolean
*/
isUndefined: function(o) {
return typeof o === 'undefined';
},
/**
* Determines whether or not the property was added
* to the object instance. Returns false if the property is not present
* in the object, or was inherited from the prototype.
* This abstraction is provided to enable hasOwnProperty for Safari 1.3.x.
* There is a discrepancy between YAHOO.lang.hasOwnProperty and
* Object.prototype.hasOwnProperty when the property is a primitive added to
* both the instance AND prototype with the same value:
* <pre>
* var A = function() {};
* A.prototype.foo = 'foo';
* var a = new A();
* a.foo = 'foo';
* alert(a.hasOwnProperty('foo')); // true
* alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback
* </pre>
* @method hasOwnProperty
* @param {any} o The object being testing
* @return Boolean
*/
hasOwnProperty: function(o, prop) {
if (Object.prototype.hasOwnProperty) {
return o.hasOwnProperty(prop);
}
},
/**
* IE will not enumerate native functions in a derived object even if the
* function was overridden. This is a workaround for specific functions
* we care about on the Object prototype.
* @property _IEEnumFix
* @param {Function} r the object to receive the augmentation
* @param {Function} s the object that supplies the properties to augment
* @static
* @private
*/
_IEEnumFix: function(r, s) {
r[fname]=f;
}
}
}
},
/**
* Utility to set up the prototype, constructor and superclass properties to
* support an inheritance strategy that can chain constructors and methods.
* Static members will not be inherited.
*
* @method extend
* @static
* @param {Function} subc the object to modify
* @param {Function} superc the object to inherit
* @param {Object} overrides additional properties/methods to add to the
* subclass prototype. These will override the
* matching items obtained from the superclass
* if present.
*/
throw new Error("YAHOO.lang.extend failed, please check that " +
"all dependencies are included.");
}
var F = function() {};
}
if (overrides) {
for (var i in overrides) {
}
}
},
/**
* Applies all properties in the supplier to the receiver if the
* receiver does not have these properties yet. Optionally, one or
* more methods/properties can be specified (as additional
* parameters). This option will overwrite the property if receiver
* has it already. If true is passed as the third parameter, all
* properties will be applied and _will_ overwrite properties in
* the receiver.
*
* @method augmentObject
* @static
* @since 2.3.0
* @param {Function} r the object to receive the augmentation
* @param {Function} s the object that supplies the properties to augment
* @param {String*|boolean} arguments zero or more properties methods
* to augment the receiver with. If none specified, everything
* in the supplier will be used unless it would
* overwrite an existing property in the receiver. If true
* is specified as the third parameter, all properties will
* be applied and will overwrite an existing property in
* the receiver
*/
augmentObject: function(r, s) {
if (!s||!r) {
throw new Error("Absorb failed, verify dependencies.");
}
r[a[i]] = s[a[i]];
}
} else { // take everything, overwriting only if the third parameter is true
for (p in s) {
if (override || !r[p]) {
r[p] = s[p];
}
}
}
},
/**
* Same as YAHOO.lang.augmentObject, except it only applies prototype properties
* @see YAHOO.lang.augmentObject
* @method augmentProto
* @static
* @param {Function} r the object to receive the augmentation
* @param {Function} s the object that supplies the properties to augment
* @param {String*|boolean} arguments zero or more properties methods
* to augment the receiver with. If none specified, everything
* in the supplier will be used unless it would overwrite an existing
* property in the receiver. if true is specified as the third
* parameter, all properties will be applied and will overwrite an
* existing property in the receiver
*/
augmentProto: function(r, s) {
if (!s||!r) {
throw new Error("Augment failed, verify dependencies.");
}
//var a=[].concat(arguments);
}
},
/**
* Returns a simple string representation of the object or array.
* Other types of objects will be returned unprocessed. Arrays
* are expected to be indexed. Use object notation for
* associative arrays.
* @method dump
* @since 2.3.0
* @param o {Object} The object to dump
* @param d {int} How deep to recurse child objects, default 3
* @return {String} the dump result
*/
dump: function(o, d) {
// Skip non-objects
// Skip dates because the std toString is what we want
// Skip HTMLElement-like objects because trying to dump
// an element will cause an unhandled exception in FF 2.x
if (!l.isObject(o) || o instanceof Date ||
("nodeType" in o && "tagName" in o)) {
return o;
} else if (l.isFunction(o)) {
return FUN;
}
// dig into child objects the depth specifed. Default 3
d = (l.isNumber(d)) ? d : 3;
// arrays [1, 2, 3]
if (l.isArray(o)) {
s.push("[");
if (l.isObject(o[i])) {
} else {
s.push(o[i]);
}
}
if (s.length > 1) {
s.pop();
}
s.push("]");
// objects {k1 => v1, k2 => v2}
} else {
s.push("{");
for (i in o) {
if (l.hasOwnProperty(o, i)) {
if (l.isObject(o[i])) {
} else {
s.push(o[i]);
}
}
}
if (s.length > 1) {
s.pop();
}
s.push("}");
}
return s.join("");
},
/**
* Does variable substitution on a string. It scans through the string
* looking for expressions enclosed in { } braces. If an expression
* is found, it is used a key on the object. If there is a space in
* the key, the first word is used for the key and the rest is provided
* to an optional function to be used to programatically determine the
* value (the extra information might be used for this decision). If
* the value for the key in the object, or what is returned from the
* function has a string value, number value, or object value, it is
* substituted for the bracket expression and it repeats. If this
* value is an object, it uses the Object's toString() if this has
* pairs.
* @method substitute
* @since 2.3.0
* @param s {String} The string that will be modified.
* @param o {Object} An object containing the replacement values
* @param f {Function} An optional function that can be used to
* process each match. It receives the key,
* value, and any extra metadata included with
* the key inside of the braces.
* @return {String} the substituted string
*/
substitute: function (s, o, f) {
for (;;) {
i = s.lastIndexOf(LBRACE);
if (i < 0) {
break;
}
if (i + 1 >= j) {
break;
}
//Extract key and meta info
meta = null;
if (k > -1) {
}
// lookup the value
v = o[key];
// if a substitution function was provided, execute it
if (f) {
}
if (l.isObject(v)) {
if (l.isArray(v)) {
} else {
// look for the keyword 'dump', if found force obj dump
if (dump > -1) {
}
// use the toString if it is not the Object toString
// and the 'dump' meta info was not found
} else {
v = v.toString();
}
}
// This {block} has no replace string. Save it for later.
// break;
}
}
// restore saved {block}s
}
return s;
},
/**
* Returns a string without any leading or trailing whitespace. If
* the input is not a string, the input will be returned untouched.
* @method trim
* @since 2.3.0
* @param s {string} the string to trim
* @return {string} the trimmed string
*/
trim: function(s){
try {
return s.replace(/^\s+|\s+$/g, "");
} catch(e) {
return s;
}
},
/**
* Returns a new object containing all of the properties of
* all the supplied objects. The properties from later objects
* will overwrite those in earlier objects.
* @method merge
* @since 2.3.0
* @param arguments {Object*} the objects to merge
* @return the new merged object
*/
merge: function() {
var o={}, a=arguments, i;
/*
for (var j in a[i]) {
o[j] = a[i][j];
}
*/
}
return o;
},
/**
* A convenience method for detecting a legitimate non-null value.
* including 0/false/''
* @method isValue
* @since 2.3.0
* @param o {any} the item to test
*/
isValue: function(o) {
// return (o || o === false || o === 0 || o === ''); // Infinity fails
}
};
/*
* An alias for <a href="YAHOO.lang.html">YAHOO.lang</a>
* @class YAHOO.util.Lang
*/
/**
* Same as YAHOO.lang.augmentObject, except it only applies prototype
* properties. This is an alias for augmentProto.
* @see YAHOO.lang.augmentObject
* @method augment
* @static
* @param {Function} r the object to receive the augmentation
* @param {Function} s the object that supplies the properties to augment
* @param {String*|boolean} arguments zero or more properties methods to
* augment the receiver with. If none specified, everything
* in the supplier will be used unless it would
* overwrite an existing property in the receiver. if true
* is specified as the third parameter, all properties will
* be applied and will overwrite an existing property in
* the receiver
*/
/**
* An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a>
* @for YAHOO
* @method augment
* @static
* @param {Function} r the object to receive the augmentation
* @param {Function} s the object that supplies the properties to augment
* @param {String*} arguments zero or more properties methods to
* augment the receiver with. If none specified, everything
* in the supplier will be used unless it would
* overwrite an existing property in the receiver
*/
/**
* An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a>
* @method extend
* @static
* @param {Function} subc the object to modify
* @param {Function} superc the object to inherit
* @param {Object} overrides additional properties/methods to add to the
* subclass prototype. These will override the
* matching items obtained from the superclass if present.
*/