2 Copyright (c) 2011, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 * The YAHOO object is the single global object used by YUI Library. It
9 * contains utility function for setting up namespaces, inheritance, and
10 * logging. YAHOO.util, YAHOO.widget, and YAHOO.example are namespaces
11 * created automatically for and used by the library.
17 * YAHOO_config is not included as part of the library. Instead it is an
18 * object that can be defined by the implementer immediately before
19 * including the YUI library. The properties included in this object
20 * will be used to configure global properties needed as soon as the
21 * library begins to load.
27 * A reference to a function that will be executed every time a YAHOO module
28 * is loaded. As parameter, this function will receive the version
29 * information for the module. See <a href="YAHOO.env.html#getVersion">
30 * YAHOO.env.getVersion</a> for the description of the version data structure.
38 * Set to true if the library will be dynamically loaded after window.onload.
47 * Instructs the yuiloader component to dynamically load yui components and
48 * their dependencies. See the yuiloader documentation for more information
49 * about dynamic loading
57 * Forces the use of the supplied locale where applicable in the library
64 if (typeof YAHOO == "undefined" || !YAHOO) {
66 * The YAHOO global namespace object. If YAHOO is already defined, the
67 * existing YAHOO object will not be overwritten so that defined
68 * namespaces are preserved.
76 * Returns the namespace specified and creates it if it doesn't exist
78 * YAHOO.namespace("property.package");
79 * YAHOO.namespace("YAHOO.property.package");
81 * Either of the above would create YAHOO.property, then
82 * YAHOO.property.package
84 * Be careful when naming packages. Reserved words may work in some browsers
85 * and not others. For instance, the following will fail in Safari:
87 * YAHOO.namespace("really.long.nested.namespace");
89 * This fails because "long" is a future reserved word in ECMAScript
91 * For implementation code that uses YUI, do not create your components
92 * in the namespaces defined by YUI (
93 * <code>YAHOO.util</code>,
94 * <code>YAHOO.widget</code>,
95 * <code>YAHOO.lang</code>,
96 * <code>YAHOO.tool</code>,
97 * <code>YAHOO.example</code>,
98 * <code>YAHOO.env</code>) -- create your own namespace (e.g., 'companyname').
102 * @param {String*} arguments 1-n namespaces to create
103 * @return {Object} A reference to the last namespace object created
105 YAHOO.namespace = function() {
106 var a=arguments, o=null, i, j, d;
107 for (i=0; i<a.length; i=i+1) {
108 d=(""+a[i]).split(".");
111 // YAHOO is implied, so it is ignored if it is included
112 for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; j=j+1) {
113 o[d[j]]=o[d[j]] || {};
122 * Uses YAHOO.widget.Logger to output a log message, if the widget is
124 * Note: LogReader adds the message, category, and source to the DOM as HTML.
128 * @param {HTML} msg The message to log.
129 * @param {HTML} cat The log category for the message. Default
130 * categories are "info", "warn", "error", time".
131 * Custom categories can be used as well. (opt)
132 * @param {HTML} src The source of the the message (opt)
133 * @return {Boolean} True if the log operation was successful.
135 YAHOO.log = function(msg, cat, src) {
136 var l=YAHOO.widget.Logger;
138 return l.log(msg, cat, src);
145 * Registers a module with the YAHOO object
148 * @param {String} name the name of the module (event, slider, etc)
149 * @param {Function} mainClass a reference to class in the module. This
150 * class will be tagged with the version info
151 * so that it will be possible to identify the
152 * version that is in use when multiple versions
154 * @param {Object} data metadata object for the module. Currently it
155 * is expected to contain a "version" property
156 * and a "build" property at minimum.
158 YAHOO.register = function(name, mainClass, data) {
159 var mods = YAHOO.env.modules, m, v, b, ls, i;
171 ls = YAHOO.env.listeners;
178 m.mainClass = mainClass;
180 // fire the module load listeners
181 for (i=0;i<ls.length;i=i+1) {
184 // label the main class
186 mainClass.VERSION = v;
189 YAHOO.log("mainClass is undefined for module " + name, "warn");
194 * YAHOO.env is used to keep track of what is known about the YUI library and
195 * the browsing environment
199 YAHOO.env = YAHOO.env || {
202 * Keeps the version info for all YUI modules that have reported themselves
209 * List of functions that should be executed every time a YUI module
211 * @property listeners
218 * Returns the version data for the specified module:
220 * <dt>name:</dt> <dd>The name of the module</dd>
221 * <dt>version:</dt> <dd>The version in use</dd>
222 * <dt>build:</dt> <dd>The build number in use</dd>
223 * <dt>versions:</dt> <dd>All versions that were registered</dd>
224 * <dt>builds:</dt> <dd>All builds that were registered.</dd>
225 * <dt>mainClass:</dt> <dd>An object that was was stamped with the
226 * current version and build. If
227 * mainClass.VERSION != version or mainClass.BUILD != build,
228 * multiple versions of pieces of the library have been
229 * loaded, potentially causing issues.</dd>
234 * @param {String} name the name of the module (event, slider, etc)
235 * @return {Object} The version info
237 YAHOO.env.getVersion = function(name) {
238 return YAHOO.env.modules[name] || null;
242 * Do not fork for a browser if it can be avoided. Use feature detection when
243 * you can. Use the user agent as a last resort. YAHOO.env.ua stores a version
244 * number for the browser engine, 0 otherwise. This value may or may not map
245 * to the version number of the browser using the engine. The value is
246 * presented as a float so that it can easily be used for boolean evaluation
247 * as well as for looking for a particular range of versions. Because of this,
248 * some of the granularity of the version info may be lost (e.g., Gecko 1.8.0.9
250 * @class YAHOO.env.ua
255 * parses a user agent string (or looks for one in navigator to parse if
261 YAHOO.env.parseUA = function(agent) {
263 var numberify = function(s) {
265 return parseFloat(s.replace(/\./g, function() {
266 return (c++ == 1) ? '' : '.';
275 * Internet Explorer version number or 0. Example: 6
283 * Opera version number or 0. Example: 9.2
291 * Gecko engine revision number. Will evaluate to 1 if Gecko
292 * is detected but the revision could not be found. Other browsers
293 * will be 0. Example: 1.8
295 * Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7
296 * Firefox 1.5.0.9: 1.8.0.9 <-- 1.8
297 * Firefox 2.0.0.3: 1.8.1.3 <-- 1.81
298 * Firefox 3.0 <-- 1.9
299 * Firefox 3.5 <-- 1.91
308 * AppleWebKit version. KHTML browsers that are not WebKit browsers
309 * will evaluate to 1, other browsers 0. Example: 418.9
311 * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
312 * latest available for Mac OSX 10.3.
313 * Safari 2.0.2: 416 <-- hasOwnProperty introduced
314 * Safari 2.0.4: 418 <-- preventDefault fixed
315 * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
316 * different versions of webkit
317 * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been
318 * updated, but not updated
319 * to the latest patch.
320 * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native
321 * SVG and many major issues fixed).
322 * Safari 3.0.4 (523.12) 523.12 <-- First Tiger release - automatic
323 * update from 2.x via the 10.4.11 OS patch.
324 * Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event.
325 * yahoo.com user agent hack removed.
327 * http://en.wikipedia.org/wiki/Safari_version_history
335 * Chrome will be detected as webkit, but this property will also
336 * be populated with the Chrome version number
344 * The mobile property will be set to a string containing any relevant
345 * user agent information when a modern mobile browser is detected.
346 * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
347 * devices with the WebKit-based browser, and Opera Mini.
355 * Adobe AIR version number or 0. Only populated if webkit is detected.
362 * Detects Apple iPad's OS version
369 * Detects Apple iPhone's OS version
376 * Detects Apples iPod's OS version
383 * General truthy check for iPad, iPhone or iPod
390 * Detects Googles Android OS version
397 * Detects Palms WebOS version
405 * Google Caja version number or 0.
409 caja: nav && nav.cajaVersion,
412 * Set to true if the page appears to be in SSL
420 * The operating system. Currently only detecting windows or macintosh
429 ua = agent || (navigator && navigator.userAgent),
431 loc = window && window.location,
433 href = loc && loc.href,
437 o.secure = href && (href.toLowerCase().indexOf("https") === 0);
441 if ((/windows|win32/i).test(ua)) {
443 } else if ((/macintosh/i).test(ua)) {
445 } else if ((/rhino/i).test(ua)) {
449 // Modern KHTML browsers should qualify as Safari X-Grade
450 if ((/KHTML/).test(ua)) {
453 // Modern WebKit browsers are at least X-Grade
454 m = ua.match(/AppleWebKit\/([^\s]*)/);
456 o.webkit = numberify(m[1]);
458 // Mobile browser check
459 if (/ Mobile\//.test(ua)) {
460 o.mobile = 'Apple'; // iPhone or iPod Touch
462 m = ua.match(/OS ([^\s]*)/);
464 m = numberify(m[1].replace('_', '.'));
467 o.ipad = o.ipod = o.iphone = 0;
469 m = ua.match(/iPad|iPod|iPhone/);
471 o[m[0].toLowerCase()] = o.ios;
474 m = ua.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/);
476 // Nokia N-series, Android, webOS, ex: NokiaN95
479 if (/webOS/.test(ua)) {
481 m = ua.match(/webOS\/([^\s]*);/);
483 o.webos = numberify(m[1]);
486 if (/ Android/.test(ua)) {
487 o.mobile = 'Android';
488 m = ua.match(/Android ([^\s]*);/);
490 o.android = numberify(m[1]);
496 m = ua.match(/Chrome\/([^\s]*)/);
498 o.chrome = numberify(m[1]); // Chrome
500 m = ua.match(/AdobeAIR\/([^\s]*)/);
502 o.air = m[0]; // Adobe AIR 1.0 or better
507 if (!o.webkit) { // not webkit
508 // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
509 m = ua.match(/Opera[\s\/]([^\s]*)/);
511 o.opera = numberify(m[1]);
512 m = ua.match(/Version\/([^\s]*)/);
514 o.opera = numberify(m[1]); // opera 10+
516 m = ua.match(/Opera Mini[^;]*/);
518 o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
520 } else { // not opera or webkit
521 m = ua.match(/MSIE\s([^;]*)/);
523 o.ie = numberify(m[1]);
524 } else { // not opera, webkit, or ie
525 m = ua.match(/Gecko\/([^\s]*)/);
527 o.gecko = 1; // Gecko detected, look for revision
528 m = ua.match(/rv:([^\s\)]*)/);
530 o.gecko = numberify(m[1]);
541 YAHOO.env.ua = YAHOO.env.parseUA();
544 * Initializes the global by creating the default namespaces and applying
545 * any new configuration information that is detected. This is the setup
552 YAHOO.namespace("util", "widget", "example");
553 /*global YAHOO_config*/
554 if ("undefined" !== typeof YAHOO_config) {
555 var l=YAHOO_config.listener, ls=YAHOO.env.listeners,unique=true, i;
557 // if YAHOO is loaded multiple times we need to check to see if
558 // this is a new config object. If it is, add the new component
559 // load listener to the stack
560 for (i=0; i<ls.length; i++) {
574 * Provides the language utilites and extensions used by the library
577 YAHOO.lang = YAHOO.lang || {};
584 OP = Object.prototype,
585 ARRAY_TOSTRING = '[object Array]',
586 FUNCTION_TOSTRING = '[object Function]',
587 OBJECT_TOSTRING = '[object Object]',
600 // ADD = ["toString", "valueOf", "hasOwnProperty"],
601 ADD = ["toString", "valueOf"],
606 * Determines wheather or not the provided object is an array.
608 * @param {any} o The object being testing
609 * @return {boolean} the result
611 isArray: function(o) {
612 return OP.toString.apply(o) === ARRAY_TOSTRING;
616 * Determines whether or not the provided object is a boolean
618 * @param {any} o The object being testing
619 * @return {boolean} the result
621 isBoolean: function(o) {
622 return typeof o === 'boolean';
626 * Determines whether or not the provided object is a function.
627 * Note: Internet Explorer thinks certain functions are objects:
629 * var obj = document.createElement("object");
630 * YAHOO.lang.isFunction(obj.getAttribute) // reports false in IE
632 * var input = document.createElement("input"); // append to body
633 * YAHOO.lang.isFunction(input.focus) // reports false in IE
635 * You will have to implement additional tests if these functions
639 * @param {any} o The object being testing
640 * @return {boolean} the result
642 isFunction: function(o) {
643 return (typeof o === 'function') || OP.toString.apply(o) === FUNCTION_TOSTRING;
647 * Determines whether or not the provided object is null
649 * @param {any} o The object being testing
650 * @return {boolean} the result
652 isNull: function(o) {
657 * Determines whether or not the provided object is a legal number
659 * @param {any} o The object being testing
660 * @return {boolean} the result
662 isNumber: function(o) {
663 return typeof o === 'number' && isFinite(o);
667 * Determines whether or not the provided object is of type object
670 * @param {any} o The object being testing
671 * @return {boolean} the result
673 isObject: function(o) {
674 return (o && (typeof o === 'object' || L.isFunction(o))) || false;
678 * Determines whether or not the provided object is a string
680 * @param {any} o The object being testing
681 * @return {boolean} the result
683 isString: function(o) {
684 return typeof o === 'string';
688 * Determines whether or not the provided object is undefined
689 * @method isUndefined
690 * @param {any} o The object being testing
691 * @return {boolean} the result
693 isUndefined: function(o) {
694 return typeof o === 'undefined';
699 * IE will not enumerate native functions in a derived object even if the
700 * function was overridden. This is a workaround for specific functions
701 * we care about on the Object prototype.
702 * @property _IEEnumFix
703 * @param {Function} r the object to receive the augmentation
704 * @param {Function} s the object that supplies the properties to augment
708 _IEEnumFix: (YAHOO.env.ua.ie) ? function(r, s) {
710 for (i=0;i<ADD.length;i=i+1) {
715 if (L.isFunction(f) && f!=OP[fname]) {
723 * Returns a copy of the specified string with special HTML characters
724 * escaped. The following characters will be converted to their
725 * corresponding character entities:
726 * <code>& < > " ' / `</code>
730 * This implementation is based on the
731 * <a href="http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet">OWASP
732 * HTML escaping recommendations</a>. In addition to the characters
733 * in the OWASP recommendation, we also escape the <code>`</code>
734 * character, since IE interprets it as an attribute delimiter when used in
739 * @param {String} html String to escape.
740 * @return {String} Escaped string.
744 escapeHTML: function (html) {
745 return html.replace(/[&<>"'\/`]/g, function (match) {
746 return HTML_CHARS[match];
751 * Utility to set up the prototype, constructor and superclass properties to
752 * support an inheritance strategy that can chain constructors and methods.
753 * Static members will not be inherited.
757 * @param {Function} subc the object to modify
758 * @param {Function} superc the object to inherit
759 * @param {Object} overrides additional properties/methods to add to the
760 * subclass prototype. These will override the
761 * matching items obtained from the superclass
764 extend: function(subc, superc, overrides) {
765 if (!superc||!subc) {
766 throw new Error("extend failed, please check that " +
767 "all dependencies are included.");
769 var F = function() {}, i;
770 F.prototype=superc.prototype;
771 subc.prototype=new F();
772 subc.prototype.constructor=subc;
773 subc.superclass=superc.prototype;
774 if (superc.prototype.constructor == OP.constructor) {
775 superc.prototype.constructor=superc;
779 for (i in overrides) {
780 if (L.hasOwnProperty(overrides, i)) {
781 subc.prototype[i]=overrides[i];
785 L._IEEnumFix(subc.prototype, overrides);
790 * Applies all properties in the supplier to the receiver if the
791 * receiver does not have these properties yet. Optionally, one or
792 * more methods/properties can be specified (as additional
793 * parameters). This option will overwrite the property if receiver
794 * has it already. If true is passed as the third parameter, all
795 * properties will be applied and _will_ overwrite properties in
798 * @method augmentObject
801 * @param {Function} r the object to receive the augmentation
802 * @param {Function} s the object that supplies the properties to augment
803 * @param {String*|boolean} arguments zero or more properties methods
804 * to augment the receiver with. If none specified, everything
805 * in the supplier will be used unless it would
806 * overwrite an existing property in the receiver. If true
807 * is specified as the third parameter, all properties will
808 * be applied and will overwrite an existing property in
811 augmentObject: function(r, s) {
813 throw new Error("Absorb failed, verify dependencies.");
815 var a=arguments, i, p, overrideList=a[2];
816 if (overrideList && overrideList!==true) { // only absorb the specified properties
817 for (i=2; i<a.length; i=i+1) {
820 } else { // take everything, overwriting only if the third parameter is true
822 if (overrideList || !(p in r)) {
834 * Same as YAHOO.lang.augmentObject, except it only applies prototype properties
835 * @see YAHOO.lang.augmentObject
836 * @method augmentProto
838 * @param {Function} r the object to receive the augmentation
839 * @param {Function} s the object that supplies the properties to augment
840 * @param {String*|boolean} arguments zero or more properties methods
841 * to augment the receiver with. If none specified, everything
842 * in the supplier will be used unless it would overwrite an existing
843 * property in the receiver. if true is specified as the third
844 * parameter, all properties will be applied and will overwrite an
845 * existing property in the receiver
847 augmentProto: function(r, s) {
849 throw new Error("Augment failed, verify dependencies.");
851 //var a=[].concat(arguments);
852 var a=[r.prototype,s.prototype], i;
853 for (i=2;i<arguments.length;i=i+1) {
854 a.push(arguments[i]);
856 L.augmentObject.apply(this, a);
863 * Returns a simple string representation of the object or array.
864 * Other types of objects will be returned unprocessed. Arrays
865 * are expected to be indexed. Use object notation for
866 * associative arrays.
869 * @param o {Object} The object to dump
870 * @param d {int} How deep to recurse child objects, default 3
871 * @return {String} the dump result
873 dump: function(o, d) {
874 var i,len,s=[],OBJ="{...}",FUN="f(){...}",
875 COMMA=', ', ARROW=' => ';
877 // Cast non-objects to string
878 // Skip dates because the std toString is what we want
879 // Skip HTMLElement-like objects because trying to dump
880 // an element will cause an unhandled exception in FF 2.x
881 if (!L.isObject(o)) {
883 } else if (o instanceof Date || ("nodeType" in o && "tagName" in o)) {
885 } else if (L.isFunction(o)) {
889 // dig into child objects the depth specifed. Default 3
890 d = (L.isNumber(d)) ? d : 3;
895 for (i=0,len=o.length;i<len;i=i+1) {
896 if (L.isObject(o[i])) {
897 s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
907 // objects {k1 => v1, k2 => v2}
911 if (L.hasOwnProperty(o, i)) {
913 if (L.isObject(o[i])) {
914 s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
931 * Does variable substitution on a string. It scans through the string
932 * looking for expressions enclosed in { } braces. If an expression
933 * is found, it is used a key on the object. If there is a space in
934 * the key, the first word is used for the key and the rest is provided
935 * to an optional function to be used to programatically determine the
936 * value (the extra information might be used for this decision). If
937 * the value for the key in the object, or what is returned from the
938 * function has a string value, number value, or object value, it is
939 * substituted for the bracket expression and it repeats. If this
940 * value is an object, it uses the Object's toString() if this has
941 * been overridden, otherwise it does a shallow dump of the key/value
944 * By specifying the recurse option, the string is rescanned after
945 * every replacement, allowing for nested template substitutions.
946 * The side effect of this option is that curly braces in the
947 * replacement content must be encoded.
951 * @param s {String} The string that will be modified.
952 * @param o {Object} An object containing the replacement values
953 * @param f {Function} An optional function that can be used to
954 * process each match. It receives the key,
955 * value, and any extra metadata included with
956 * the key inside of the braces.
957 * @param recurse {boolean} default true - if not false, the replaced
958 * string will be rescanned so that nested substitutions are possible.
959 * @return {String} the substituted string
961 substitute: function (s, o, f, recurse) {
962 var i, j, k, key, v, meta, saved=[], token, lidx=s.length,
963 DUMP='dump', SPACE=' ', LBRACE='{', RBRACE='}',
967 i = s.lastIndexOf(LBRACE, lidx);
971 j = s.indexOf(RBRACE, i);
976 //Extract key and meta info
977 token = s.substring(i + 1, j);
980 k = key.indexOf(SPACE);
982 meta = key.substring(k + 1);
983 key = key.substring(0, k);
989 // if a substitution function was provided, execute it
996 v = L.dump(v, parseInt(meta, 10));
1000 // look for the keyword 'dump', if found force obj dump
1001 dump = meta.indexOf(DUMP);
1003 meta = meta.substring(4);
1006 objstr = v.toString();
1008 // use the toString if it is not the Object toString
1009 // and the 'dump' meta info was not found
1010 if (objstr === OBJECT_TOSTRING || dump > -1) {
1011 v = L.dump(v, parseInt(meta, 10));
1016 } else if (!L.isString(v) && !L.isNumber(v)) {
1017 // This {block} has no replace string. Save it for later.
1018 v = "~-" + saved.length + "-~";
1019 saved[saved.length] = token;
1024 s = s.substring(0, i) + v + s.substring(j + 1);
1026 if (recurse === false) {
1032 // restore saved {block}s
1033 for (i=saved.length-1; i>=0; i=i-1) {
1034 s = s.replace(new RegExp("~-" + i + "-~"), "{" + saved[i] + "}", "g");
1042 * Returns a string without any leading or trailing whitespace. If
1043 * the input is not a string, the input will be returned untouched.
1046 * @param s {string} the string to trim
1047 * @return {string} the trimmed string
1051 return s.replace(/^\s+|\s+$/g, "");
1058 * Returns a new object containing all of the properties of
1059 * all the supplied objects. The properties from later objects
1060 * will overwrite those in earlier objects.
1063 * @param arguments {Object*} the objects to merge
1064 * @return the new merged object
1067 var o={}, a=arguments, l=a.length, i;
1068 for (i=0; i<l; i=i+1) {
1069 L.augmentObject(o, a[i], true);
1075 * Executes the supplied function in the context of the supplied
1076 * object 'when' milliseconds later. Executes the function a
1077 * single time unless periodic is set to true.
1080 * @param when {int} the number of milliseconds to wait until the fn
1082 * @param o the context object
1083 * @param fn {Function|String} the function to execute or the name of
1084 * the method in the 'o' object to execute
1085 * @param data [Array] data that is provided to the function. This accepts
1086 * either a single item or an array. If an array is provided, the
1087 * function is executed with one parameter for each array item. If
1088 * you need to pass a single array parameter, it needs to be wrapped in
1089 * an array [myarray]
1090 * @param periodic {boolean} if true, executes continuously at supplied
1091 * interval until canceled
1092 * @return a timer object. Call the cancel() method on this object to
1095 later: function(when, o, fn, data, periodic) {
1098 var m=fn, d=data, f, r;
1100 if (L.isString(fn)) {
1105 throw new TypeError("method undefined");
1108 if (!L.isUndefined(data) && !L.isArray(d)) {
1113 m.apply(o, d || NOTHING);
1116 r = (periodic) ? setInterval(f, when) : setTimeout(f, when);
1120 cancel: function() {
1121 if (this.interval) {
1131 * A convenience method for detecting a legitimate non-null value.
1132 * Returns false for null/undefined/NaN, true for other values,
1133 * including 0/false/''
1136 * @param o {any} the item to test
1137 * @return {boolean} true if it is not null/undefined/NaN || false
1139 isValue: function(o) {
1140 // return (o || o === false || o === 0 || o === ''); // Infinity fails
1141 return (L.isObject(o) || L.isString(o) || L.isNumber(o) || L.isBoolean(o));
1147 * Determines whether or not the property was added
1148 * to the object instance. Returns false if the property is not present
1149 * in the object, or was inherited from the prototype.
1150 * This abstraction is provided to enable hasOwnProperty for Safari 1.3.x.
1151 * There is a discrepancy between YAHOO.lang.hasOwnProperty and
1152 * Object.prototype.hasOwnProperty when the property is a primitive added to
1153 * both the instance AND prototype with the same value:
1155 * var A = function() {};
1156 * A.prototype.foo = 'foo';
1159 * alert(a.hasOwnProperty('foo')); // true
1160 * alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback
1162 * @method hasOwnProperty
1163 * @param {any} o The object being testing
1164 * @param prop {string} the name of the property to test
1165 * @return {boolean} the result
1167 L.hasOwnProperty = (OP.hasOwnProperty) ?
1169 return o && o.hasOwnProperty && o.hasOwnProperty(prop);
1170 } : function(o, prop) {
1171 return !L.isUndefined(o[prop]) &&
1172 o.constructor.prototype[prop] !== o[prop];
1176 OB.augmentObject(L, OB, true);
1179 * An alias for <a href="YAHOO.lang.html">YAHOO.lang</a>
1180 * @class YAHOO.util.Lang
1182 YAHOO.util.Lang = L;
1185 * Same as YAHOO.lang.augmentObject, except it only applies prototype
1186 * properties. This is an alias for augmentProto.
1187 * @see YAHOO.lang.augmentObject
1190 * @param {Function} r the object to receive the augmentation
1191 * @param {Function} s the object that supplies the properties to augment
1192 * @param {String*|boolean} arguments zero or more properties methods to
1193 * augment the receiver with. If none specified, everything
1194 * in the supplier will be used unless it would
1195 * overwrite an existing property in the receiver. if true
1196 * is specified as the third parameter, all properties will
1197 * be applied and will overwrite an existing property in
1200 L.augment = L.augmentProto;
1203 * An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a>
1207 * @param {Function} r the object to receive the augmentation
1208 * @param {Function} s the object that supplies the properties to augment
1209 * @param {String*} arguments zero or more properties methods to
1210 * augment the receiver with. If none specified, everything
1211 * in the supplier will be used unless it would
1212 * overwrite an existing property in the receiver
1214 YAHOO.augment = L.augmentProto;
1217 * An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a>
1220 * @param {Function} subc the object to modify
1221 * @param {Function} superc the object to inherit
1222 * @param {Object} overrides additional properties/methods to add to the
1223 * subclass prototype. These will override the
1224 * matching items obtained from the superclass if present.
1226 YAHOO.extend = L.extend;
1229 YAHOO.register("yahoo", YAHOO, {version: "2.9.0", build: "2800"});