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"});
1231 * Provides a mechanism to fetch remote resources and
1232 * insert them into a document
1233 * This utility can fetch JavaScript and CSS files, inserting script
1234 * tags for script and link tags for CSS. Note, this
1235 * is done via the normal browser mechanisms for inserting
1236 * these resources and making the content available to
1237 * code that would access it. Be careful when retreiving
1238 * remote resources. Only use this utility to fetch
1239 * files from sites you trust.
1246 * Fetches and inserts one or more script or link nodes into the document.
1247 * This utility can fetch JavaScript and CSS files, inserting script
1248 * tags for script and link tags for CSS. Note, this
1249 * is done via the normal browser mechanisms for inserting
1250 * these resources and making the content available to
1251 * code that would access it. Be careful when retreiving
1252 * remote resources. Only use this utility to fetch
1253 * files from sites you trust.
1255 * @namespace YAHOO.util
1256 * @class YAHOO.util.Get
1258 YAHOO.util.Get = function() {
1261 * hash of queues to manage multiple requests
1268 * queue index used to generate transaction ids
1276 * node index used to generate unique node ids
1284 * interal property used to prevent multiple simultaneous purge
1301 * Generates an HTML element, this is not appended to a document
1303 * @param type {string} the type of element
1304 * @param attr {string} the attributes
1305 * @param win {Window} optional window to create the element in
1306 * @return {HTMLElement} the generated node
1309 _node = function(type, attr, win) {
1310 var w = win || window, d=w.document, n=d.createElement(type), i;
1313 if (attr.hasOwnProperty(i)) {
1314 n.setAttribute(i, attr[i]);
1322 * Generates a link node
1324 * @param url {string} the url for the css file
1325 * @param win {Window} optional window to create the node in
1326 * @return {HTMLElement} the generated node
1329 _linkNode = function(url, win, attributes) {
1332 id: "yui__dyn_" + (nidx++),
1339 lang.augmentObject(o, attributes);
1342 return _node("link", o, win);
1346 * Generates a script node
1347 * @method _scriptNode
1348 * @param url {string} the url for the script file
1349 * @param win {Window} optional window to create the node in
1350 * @return {HTMLElement} the generated node
1353 _scriptNode = function(url, win, attributes) {
1355 id: "yui__dyn_" + (nidx++),
1356 type: "text/javascript",
1361 lang.augmentObject(o, attributes);
1364 return _node("script", o, win);
1368 * Returns the data payload for callback functions
1369 * @method _returnData
1372 _returnData = function(q, msg) {
1385 _get = function(nId, tId) {
1386 var q = queues[tId],
1387 n = (lang.isString(nId)) ? q.win.document.getElementById(nId) : nId;
1389 _fail(tId, "target node not found: " + nId);
1397 * The request is complete, so executing the requester's callback
1399 * @param id {string} the id of the request
1402 _finish = function(id) {
1403 YAHOO.log("Finishing transaction " + id);
1404 var q = queues[id], msg, context;
1408 msg = "transaction " + id + " was aborted";
1413 // execute success callback
1415 context = q.scope || q.win;
1416 q.onSuccess.call(context, _returnData(q));
1423 * @param id {string} the id of the request
1426 _timeout = function(id) {
1427 YAHOO.log("Timeout " + id, "info", "get");
1428 var q = queues[id], context;
1430 context = q.scope || q;
1431 q.onTimeout.call(context, _returnData(q));
1436 * Loads the next item for a given request
1438 * @param id {string} the id of the request
1439 * @param loaded {string} the url that was just loaded, if any
1442 _next = function(id, loaded) {
1444 YAHOO.log("_next: " + id + ", loaded: " + loaded, "info", "Get");
1446 var q = queues[id], w=q.win, d=w.document, h=d.getElementsByTagName("head")[0],
1447 n, msg, url, s, extra;
1450 // Y.log('cancel timer');
1455 msg = "transaction " + id + " was aborted";
1466 // This is the first pass: make sure the url is an array
1467 q.url = (lang.isString(q.url)) ? [q.url] : q.url;
1469 q.varName = (lang.isString(q.varName)) ? [q.varName] : q.varName;
1474 if (q.url.length === 0) {
1475 // Safari 2.x workaround - There is no way to know when
1476 // a script is ready in versions of Safari prior to 3.x.
1477 // Adding an extra node reduces the problem, but doesn't
1478 // eliminate it completely because the browser executes
1479 // them asynchronously.
1480 if (q.type === "script" && ua.webkit && ua.webkit < 420 &&
1481 !q.finalpass && !q.varName) {
1482 // Add another script node. This does not guarantee that the
1483 // scripts will execute in order, but it does appear to fix the
1484 // problem on fast connections more effectively than using an
1485 // arbitrary timeout. It is possible that the browser does
1486 // block subsequent script execution in this case for a limited
1488 extra = _scriptNode(null, q.win, q.attributes);
1489 extra.innerHTML='YAHOO.util.Get._finalize("' + id + '");';
1490 q.nodes.push(extra); h.appendChild(extra);
1502 // if the url is undefined, this is probably a trailing comma problem in IE
1505 YAHOO.log('skipping empty url');
1509 YAHOO.log("attempting to load " + url, "info", "Get");
1512 // Y.log('create timer');
1513 q.timer = lang.later(q.timeout, q, _timeout, id);
1516 if (q.type === "script") {
1517 n = _scriptNode(url, w, q.attributes);
1519 n = _linkNode(url, w, q.attributes);
1522 // track this node's load progress
1523 _track(q.type, n, id, url, w, q.url.length);
1525 // add the node to the queue so we can return it to the user supplied callback
1528 // add it to the head or insert it before 'insertBefore'
1529 if (q.insertBefore) {
1530 s = _get(q.insertBefore, id);
1532 s.parentNode.insertBefore(n, s);
1538 YAHOO.log("Appending node: " + url, "info", "Get");
1540 // FireFox does not support the onload event for link nodes, so there is
1541 // no way to make the css requests synchronous. This means that the css
1542 // rules in multiple files could be applied out of order in this browser
1543 // if a later request returns before an earlier one. Safari too.
1544 if ((ua.webkit || ua.gecko) && q.type === "css") {
1550 * Removes processed queues and corresponding nodes
1551 * @method _autoPurge
1554 _autoPurge = function() {
1565 if (queues.hasOwnProperty(i)) {
1567 if (q.autopurge && q.finished) {
1578 * Saves the state for the request and begins loading
1579 * the requested urls
1581 * @param type {string} the type of node to insert
1582 * @param url {string} the url to load
1583 * @param opts the hash of options for this request
1586 _queue = function(type, url, opts) {
1588 var id = "q" + (qidx++), q;
1591 if (qidx % YAHOO.util.Get.PURGE_THRESH === 0) {
1595 queues[id] = lang.merge(opts, {
1605 q.win = q.win || window;
1606 q.scope = q.scope || q.win;
1607 q.autopurge = ("autopurge" in q) ? q.autopurge :
1608 (type === "script") ? true : false;
1610 q.attributes = q.attributes || {};
1611 q.attributes.charset = opts.charset || q.attributes.charset || 'utf-8';
1613 lang.later(0, q, _next, id);
1621 * Detects when a node has been loaded. In the case of
1622 * script nodes, this does not guarantee that contained
1623 * script is ready to use.
1625 * @param type {string} the type of node to track
1626 * @param n {HTMLElement} the node to track
1627 * @param id {string} the id of the request
1628 * @param url {string} the url that is being loaded
1629 * @param win {Window} the targeted window
1630 * @param qlength the number of remaining items in the queue,
1631 * including this one
1632 * @param trackfn {Function} function to execute when finished
1633 * the default is _next
1636 _track = function(type, n, id, url, win, qlength, trackfn) {
1637 var f = trackfn || _next, rs, q, a, freq, w, l, i, msg;
1639 // IE supports the readystatechange event for script and css nodes
1641 n.onreadystatechange = function() {
1642 rs = this.readyState;
1643 if ("loaded" === rs || "complete" === rs) {
1644 YAHOO.log(id + " onload " + url, "info", "Get");
1645 n.onreadystatechange = null;
1650 // webkit prior to 3.x is problemmatic
1651 } else if (ua.webkit) {
1653 if (type === "script") {
1655 // Safari 3.x supports the load event for script nodes (DOM2)
1656 if (ua.webkit >= 420) {
1658 n.addEventListener("load", function() {
1659 YAHOO.log(id + " DOM2 onload " + url, "info", "Get");
1663 // Nothing can be done with Safari < 3.x except to pause and hope
1664 // for the best, particularly after last script is inserted. The
1665 // scripts will always execute in the order they arrive, not
1666 // necessarily the order in which they were inserted. To support
1667 // script nodes with complete reliability in these browsers, script
1668 // nodes either need to invoke a function in the window once they
1669 // are loaded or the implementer needs to provide a well-known
1670 // property that the utility can poll for.
1672 // Poll for the existence of the named variable, if it
1676 freq = YAHOO.util.Get.POLL_FREQ;
1677 YAHOO.log("Polling for " + q.varName[0]);
1678 q.maxattempts = YAHOO.util.Get.TIMEOUT/freq;
1680 q._cache = q.varName[0].split(".");
1681 q.timer = lang.later(freq, q, function(o) {
1685 for (i=0; i<l; i=i+1) {
1688 // if we have exausted our attempts, give up
1690 if (this.attempts++ > this.maxattempts) {
1691 msg = "Over retry limit, giving up";
1695 YAHOO.log(a[i] + " failed, retrying");
1701 YAHOO.log("Safari poll complete");
1708 lang.later(YAHOO.util.Get.POLL_FREQ, null, f, [id, url]);
1713 // FireFox and Opera support onload (but not DOM2 in FF) handlers for
1714 // script nodes. Opera, but not FF, supports the onload event for link
1717 n.onload = function() {
1718 YAHOO.log(id + " onload " + url, "info", "Get");
1725 * The request failed, execute fail handler with whatever
1726 * was accomplished. There isn't a failure case at the
1727 * moment unless you count aborted transactions
1729 * @param id {string} the id of the request
1732 _fail = function(id, msg) {
1733 YAHOO.log("get failure: " + msg, "warn", "Get");
1734 var q = queues[id], context;
1735 // execute failure callback
1737 context = q.scope || q.win;
1738 q.onFailure.call(context, _returnData(q, msg));
1743 * Removes the nodes for the specified queue
1747 _purge = function(tId) {
1750 var q = queues[tId],
1754 h = d.getElementsByTagName("head")[0],
1757 if (q.insertBefore) {
1758 sib = _get(q.insertBefore, tId);
1764 for (i=0; i<l; i=i+1) {
1766 if (node.clearAttributes) {
1767 node.clearAttributes();
1769 for (attr in node) {
1770 if (node.hasOwnProperty(attr)) {
1776 h.removeChild(node);
1787 * The default poll freqency in ms, when needed
1788 * @property POLL_FREQ
1796 * The number of request required before an automatic purge.
1797 * property PURGE_THRESH
1805 * The length time to poll for varName when loading a script in
1806 * Safari 2.x before the transaction fails.
1815 * Called by the the helper for detecting script load in Safari
1817 * @param id {string} the transaction id
1820 _finalize: function(id) {
1821 YAHOO.log(id + " finalized ", "info", "Get");
1822 lang.later(0, null, _finish, id);
1826 * Abort a transaction
1828 * @param {string|object} either the tId or the object returned from
1831 abort: function(o) {
1832 var id = (lang.isString(o)) ? o : o.tId,
1835 YAHOO.log("Aborting " + id, "info", "Get");
1841 * Fetches and inserts one or more script nodes into the head
1842 * of the current document or the document in a specified window.
1846 * @param url {string|string[]} the url or urls to the script(s)
1847 * @param opts {object} Options:
1849 * <dt>onSuccess</dt>
1851 * callback to execute when the script(s) are finished loading
1852 * The callback receives an object back with the following
1856 * <dd>the window the script(s) were inserted into</dd>
1858 * <dd>the data object passed in when the request was made</dd>
1860 * <dd>An array containing references to the nodes that were
1863 * <dd>A function that, when executed, will remove the nodes
1864 * that were inserted</dd>
1868 * <dt>onFailure</dt>
1870 * callback to execute when the script load operation fails
1871 * The callback receives an object back with the following
1875 * <dd>the window the script(s) were inserted into</dd>
1877 * <dd>the data object passed in when the request was made</dd>
1879 * <dd>An array containing references to the nodes that were
1880 * inserted successfully</dd>
1882 * <dd>A function that, when executed, will remove any nodes
1883 * that were inserted</dd>
1887 * <dt>onTimeout</dt>
1889 * callback to execute when a timeout occurs.
1890 * The callback receives an object back with the following
1894 * <dd>the window the script(s) were inserted into</dd>
1896 * <dd>the data object passed in when the request was made</dd>
1898 * <dd>An array containing references to the nodes that were
1901 * <dd>A function that, when executed, will remove the nodes
1902 * that were inserted</dd>
1907 * <dd>the execution context for the callbacks</dd>
1909 * <dd>a window other than the one the utility occupies</dd>
1910 * <dt>autopurge</dt>
1912 * setting to true will let the utilities cleanup routine purge
1913 * the script once loaded
1917 * data that is supplied to the callback when the script(s) are
1922 * variable that should be available when a script is finished
1923 * loading. Used to help Safari 2.x and below with script load
1924 * detection. The type of this property should match what was
1925 * passed into the url parameter: if loading a single url, a
1926 * string can be supplied. If loading multiple scripts, you
1927 * must supply an array that contains the variable name for
1930 * <dt>insertBefore</dt>
1931 * <dd>node or node id that will become the new node's nextSibling</dd>
1934 * <dd>Node charset, deprecated, use 'attributes'</dd>
1935 * <dt>attributes</dt>
1936 * <dd>A hash of attributes to apply to dynamic nodes.</dd>
1938 * <dd>Number of milliseconds to wait before aborting and firing the timeout event</dd>
1940 * // assumes yahoo, dom, and event are already on the page
1941 * YAHOO.util.Get.script(
1942 * ["http://yui.yahooapis.com/2.7.0/build/dragdrop/dragdrop-min.js",
1943 * "http://yui.yahooapis.com/2.7.0/build/animation/animation-min.js"], {
1944 * onSuccess: function(o) {
1945 * YAHOO.log(o.data); // foo
1946 * new YAHOO.util.DDProxy("dd1"); // also new o.reference("dd1"); would work
1947 * this.log("won't cause error because YAHOO is the scope");
1948 * this.log(o.nodes.length === 2) // true
1949 * // o.purge(); // optionally remove the script nodes immediately
1950 * },
1951 * onFailure: function(o) {
1952 * YAHOO.log("transaction failed");
1953 * },
1954 * data: "foo",
1955 * timeout: 10000, // 10 second timeout
1956 * scope: YAHOO,
1957 * // win: otherframe // target another window/frame
1958 * autopurge: true // allow the utility to choose when to remove the nodes
1959 * });
1961 * @return {tId: string} an object containing info about the transaction
1963 script: function(url, opts) { return _queue("script", url, opts); },
1966 * Fetches and inserts one or more css link nodes into the
1967 * head of the current document or the document in a specified
1971 * @param url {string} the url or urls to the css file(s)
1972 * @param opts Options:
1974 * <dt>onSuccess</dt>
1976 * callback to execute when the css file(s) are finished loading
1977 * The callback receives an object back with the following
1980 * <dd>the window the link nodes(s) were inserted into</dd>
1982 * <dd>the data object passed in when the request was made</dd>
1984 * <dd>An array containing references to the nodes that were
1987 * <dd>A function that, when executed, will remove the nodes
1988 * that were inserted</dd>
1993 * <dd>the execution context for the callbacks</dd>
1995 * <dd>a window other than the one the utility occupies</dd>
1998 * data that is supplied to the callbacks when the nodes(s) are
2001 * <dt>insertBefore</dt>
2002 * <dd>node or node id that will become the new node's nextSibling</dd>
2004 * <dd>Node charset, deprecated, use 'attributes'</dd>
2005 * <dt>attributes</dt>
2006 * <dd>A hash of attributes to apply to dynamic nodes.</dd>
2009 * YAHOO.util.Get.css("http://yui.yahooapis.com/2.7.0/build/menu/assets/skins/sam/menu.css");
2012 * YAHOO.util.Get.css(["http://yui.yahooapis.com/2.7.0/build/menu/assets/skins/sam/menu.css",
2013 * "http://yui.yahooapis.com/2.7.0/build/logger/assets/skins/sam/logger.css"]);
2015 * @return {tId: string} an object containing info about the transaction
2017 css: function(url, opts) {
2018 return _queue("css", url, opts);
2023 YAHOO.register("get", YAHOO.util.Get, {version: "2.9.0", build: "2800"});
2024 /*jslint evil: true, strict: false, regexp: false*/
2027 * Provides dynamic loading for the YUI library. It includes the dependency
2028 * info for the library, and will automatically pull in dependencies for
2029 * the modules requested. It supports rollup files (such as utilities.js
2030 * and yahoo-dom-event.js), and will automatically use these when
2031 * appropriate in order to minimize the number of http connections
2032 * required to load all of the dependencies.
2035 * @namespace YAHOO.util
2039 * YUILoader provides dynamic loading for YUI.
2040 * @class YAHOO.util.YUILoader
2042 * version management, automatic sandboxing
2051 SUPER = "_supersedes",
2056 // version hack for cdn testing
2057 // if (/VERSION/.test(VERSION)) {
2058 // VERSION = "2.8.2";
2063 dupsAllowed: {'yahoo': true, 'get': true},
2066 * The library metadata for the current release The is the default
2067 * value for YAHOO.util.YUILoader.moduleInfo
2073 // 'root': '2.5.2/build/',
2074 // 'base': 'http://yui.yahooapis.com/2.5.2/build/',
2076 'root': VERSION + '/build/',
2077 'base': 'http://yui.yahooapis.com/' + VERSION + '/build/',
2079 'comboBase': 'http://yui.yahooapis.com/combo?',
2082 'defaultSkin': 'sam',
2083 'base': 'assets/skins/',
2085 'after': ['reset', 'fonts', 'grids', 'base'],
2089 dupsAllowed: ['yahoo', 'get'],
2095 'path': 'animation/animation-min.js',
2096 'requires': ['dom', 'event']
2101 'path': 'autocomplete/autocomplete-min.js',
2102 'requires': ['dom', 'event', 'datasource'],
2103 'optional': ['connection', 'animation'],
2109 'path': 'base/base-min.css',
2110 'after': ['reset', 'fonts', 'grids']
2115 'path': 'button/button-min.js',
2116 'requires': ['element'],
2117 'optional': ['menu'],
2123 'path': 'calendar/calendar-min.js',
2124 'requires': ['event', 'dom'],
2125 supersedes: ['datemath'],
2131 'path': 'carousel/carousel-min.js',
2132 'requires': ['element'],
2133 'optional': ['animation'],
2139 'path': 'charts/charts-min.js',
2140 'requires': ['element', 'json', 'datasource', 'swf']
2145 'path': 'colorpicker/colorpicker-min.js',
2146 'requires': ['slider', 'element'],
2147 'optional': ['animation'],
2153 'path': 'connection/connection-min.js',
2154 'requires': ['event'],
2155 'supersedes': ['connectioncore']
2160 'path': 'connection/connection_core-min.js',
2161 'requires': ['event'],
2167 'path': 'container/container-min.js',
2168 'requires': ['dom', 'event'],
2169 // button is also optional, but this creates a circular
2170 // dependency when loadOptional is specified. button
2171 // optionally includes menu, menu requires container.
2172 'optional': ['dragdrop', 'animation', 'connection'],
2173 'supersedes': ['containercore'],
2179 'path': 'container/container_core-min.js',
2180 'requires': ['dom', 'event'],
2186 'path': 'cookie/cookie-min.js',
2187 'requires': ['yahoo']
2192 'path': 'datasource/datasource-min.js',
2193 'requires': ['event'],
2194 'optional': ['connection']
2199 'path': 'datatable/datatable-min.js',
2200 'requires': ['element', 'datasource'],
2201 'optional': ['calendar', 'dragdrop', 'paginator'],
2207 'path': 'datemath/datemath-min.js',
2208 'requires': ['yahoo']
2213 'path': 'dom/dom-min.js',
2214 'requires': ['yahoo']
2219 'path': 'dragdrop/dragdrop-min.js',
2220 'requires': ['dom', 'event']
2225 'path': 'editor/editor-min.js',
2226 'requires': ['menu', 'element', 'button'],
2227 'optional': ['animation', 'dragdrop'],
2228 'supersedes': ['simpleeditor'],
2234 'path': 'element/element-min.js',
2235 'requires': ['dom', 'event'],
2236 'optional': ['event-mouseenter', 'event-delegate']
2239 'element-delegate': {
2241 'path': 'element-delegate/element-delegate-min.js',
2242 'requires': ['element']
2247 'path': 'event/event-min.js',
2248 'requires': ['yahoo']
2253 'path': 'event-simulate/event-simulate-min.js',
2254 'requires': ['event']
2259 'path': 'event-delegate/event-delegate-min.js',
2260 'requires': ['event'],
2261 'optional': ['selector']
2264 'event-mouseenter': {
2266 'path': 'event-mouseenter/event-mouseenter-min.js',
2267 'requires': ['dom', 'event']
2272 'path': 'fonts/fonts-min.css'
2277 'path': 'get/get-min.js',
2278 'requires': ['yahoo']
2283 'path': 'grids/grids-min.css',
2284 'requires': ['fonts'],
2285 'optional': ['reset']
2290 'path': 'history/history-min.js',
2291 'requires': ['event']
2296 'path': 'imagecropper/imagecropper-min.js',
2297 'requires': ['dragdrop', 'element', 'resize'],
2303 'path': 'imageloader/imageloader-min.js',
2304 'requires': ['event', 'dom']
2309 'path': 'json/json-min.js',
2310 'requires': ['yahoo']
2315 'path': 'layout/layout-min.js',
2316 'requires': ['element'],
2317 'optional': ['animation', 'dragdrop', 'resize', 'selector'],
2323 'path': 'logger/logger-min.js',
2324 'requires': ['event', 'dom'],
2325 'optional': ['dragdrop'],
2331 'path': 'menu/menu-min.js',
2332 'requires': ['containercore'],
2338 'path': 'paginator/paginator-min.js',
2339 'requires': ['element'],
2345 'path': 'profiler/profiler-min.js',
2346 'requires': ['yahoo']
2352 'path': 'profilerviewer/profilerviewer-min.js',
2353 'requires': ['profiler', 'yuiloader', 'element'],
2359 'path': 'progressbar/progressbar-min.js',
2360 'requires': ['element'],
2361 'optional': ['animation'],
2367 'path': 'reset/reset-min.css'
2370 'reset-fonts-grids': {
2372 'path': 'reset-fonts-grids/reset-fonts-grids.css',
2373 'supersedes': ['reset', 'fonts', 'grids', 'reset-fonts'],
2379 'path': 'reset-fonts/reset-fonts.css',
2380 'supersedes': ['reset', 'fonts'],
2386 'path': 'resize/resize-min.js',
2387 'requires': ['dragdrop', 'element'],
2388 'optional': ['animation'],
2394 'path': 'selector/selector-min.js',
2395 'requires': ['yahoo', 'dom']
2400 'path': 'editor/simpleeditor-min.js',
2401 'requires': ['element'],
2402 'optional': ['containercore', 'menu', 'button', 'animation', 'dragdrop'],
2409 'path': 'slider/slider-min.js',
2410 'requires': ['dragdrop'],
2411 'optional': ['animation'],
2417 'path': 'storage/storage-min.js',
2418 'requires': ['yahoo', 'event', 'cookie'],
2419 'optional': ['swfstore']
2424 'path': 'stylesheet/stylesheet-min.js',
2425 'requires': ['yahoo']
2430 'path': 'swf/swf-min.js',
2431 'requires': ['element'],
2432 'supersedes': ['swfdetect']
2437 'path': 'swfdetect/swfdetect-min.js',
2438 'requires': ['yahoo']
2443 'path': 'swfstore/swfstore-min.js',
2444 'requires': ['element', 'cookie', 'swf']
2449 'path': 'tabview/tabview-min.js',
2450 'requires': ['element'],
2451 'optional': ['connection'],
2457 'path': 'treeview/treeview-min.js',
2458 'requires': ['event', 'dom'],
2459 'optional': ['json', 'animation', 'calendar'],
2465 'path': 'uploader/uploader-min.js',
2466 'requires': ['element']
2471 'path': 'utilities/utilities.js',
2472 'supersedes': ['yahoo', 'event', 'dragdrop', 'animation', 'dom', 'connection', 'element', 'yahoo-dom-event', 'get', 'yuiloader', 'yuiloader-dom-event'],
2478 'path': 'yahoo/yahoo-min.js'
2481 'yahoo-dom-event': {
2483 'path': 'yahoo-dom-event/yahoo-dom-event.js',
2484 'supersedes': ['yahoo', 'event', 'dom'],
2490 'path': 'yuiloader/yuiloader-min.js',
2491 'supersedes': ['yahoo', 'get']
2494 'yuiloader-dom-event': {
2496 'path': 'yuiloader-dom-event/yuiloader-dom-event.js',
2497 'supersedes': ['yahoo', 'dom', 'event', 'get', 'yuiloader', 'yahoo-dom-event'],
2503 'path': 'yuitest/yuitest-min.js',
2504 'requires': ['logger'],
2505 'optional': ['event-simulate'],
2511 appendArray: function(o, a) {
2513 for (var i=0; i<a.length; i=i+1) {
2519 keys: function(o, ordered) {
2522 if (lang.hasOwnProperty(o, i)) {
2533 appendArray: function(a1, a2) {
2534 Array.prototype.push.apply(a1, a2);
2536 for (var i=0; i<a2.length; i=i+1) {
2542 indexOf: function(a, val) {
2543 for (var i=0; i<a.length; i=i+1) {
2552 toObject: function(a) {
2554 for (var i=0; i<a.length; i=i+1) {
2562 * Returns a unique array. Does not maintain order, which is fine
2563 * for this application, and performs better than it would if it
2567 return YUI.ObjectUtil.keys(YUI.ArrayUtil.toObject(a));
2572 YAHOO.util.YUILoader = function(o) {
2575 * Internal callback to handle multiple internal insert() calls
2576 * so that css is inserted prior to js
2577 * @property _internalCallback
2580 this._internalCallback = null;
2583 * Use the YAHOO environment listener to detect script load. This
2584 * is only switched on for Safari 2.x and below.
2585 * @property _useYahooListener
2588 this._useYahooListener = false;
2591 * Callback that will be executed when the loader is finished
2596 this.onSuccess = null;
2599 * Callback that will be executed if there is a failure
2603 this.onFailure = Y.log;
2606 * Callback that will be executed each time a new module is loaded
2607 * @method onProgress
2610 this.onProgress = null;
2613 * Callback that will be executed if a timeout occurs
2617 this.onTimeout = null;
2620 * The execution scope for all callbacks
2627 * Data that is passed to all callbacks
2633 * Node reference or id where new nodes should be inserted before
2634 * @property insertBefore
2635 * @type string|HTMLElement
2637 this.insertBefore = null;
2640 * The charset attribute for inserted nodes
2645 this.charset = null;
2648 * The name of the variable in a sandbox or script node
2649 * (for external script support in Safari 2.x and earlier)
2650 * to reference when the load is complete. If this variable
2651 * is not available in the specified scripts, the operation will
2656 this.varName = null;
2659 * The base directory.
2662 * @default http://yui.yahooapis.com/[YUI VERSION]/build/
2664 this.base = YUI.info.base;
2667 * Base path for the combo service
2668 * @property comboBase
2670 * @default http://yui.yahooapis.com/combo?
2672 this.comboBase = YUI.info.comboBase;
2675 * If configured, YUI will use the the combo handler on the
2676 * Yahoo! CDN to pontentially reduce the number of http requests
2682 // this.combine = (o && !('base' in o));
2683 this.combine = false;
2687 * Root path to prepend to module path for the combo
2691 * @default [YUI VERSION]/build/
2693 this.root = YUI.info.root;
2696 * Timeout value in milliseconds. If set, this value will be used by
2697 * the get utility. the timeout event will fire if
2705 * A list of modules that should not be loaded, even if
2706 * they turn up in the dependency tree
2713 * A list of modules that should always be loaded, even
2714 * if they have already been inserted into the page.
2721 * Should we allow rollups
2722 * @property allowRollup
2726 this.allowRollup = true;
2729 * A filter to apply to result urls. This filter will modify the default
2730 * path for all modules. The default path for the YUI library is the
2731 * minified version of the files (e.g., event-min.js). The filter property
2732 * can be a predefined filter or a custom filter. The valid predefined
2736 * <dd>Selects the debug versions of the library (e.g., event-debug.js).
2737 * This option will automatically include the logger widget</dd>
2739 * <dd>Selects the non-minified version of the library (e.g., event.js).
2741 * You can also define a custom filter, which must be an object literal
2742 * containing a search expression and a replace string:
2745 * 'searchExp': "-min\\.js",
2746 * 'replaceStr': "-debug.js"
2750 * @type string|{searchExp: string, replaceStr: string}
2755 * The list of requested modules
2756 * @property required
2757 * @type {string: boolean}
2762 * The library metadata
2763 * @property moduleInfo
2765 this.moduleInfo = lang.merge(YUI.info.moduleInfo);
2768 * List of rollup files found in the library metadata
2771 this.rollups = null;
2774 * Whether or not to load optional dependencies for
2775 * the requested modules
2776 * @property loadOptional
2780 this.loadOptional = false;
2783 * All of the derived dependencies in sorted order, which
2784 * will be populated when either calculate() or insert()
2792 * Set when beginning to compute the dependency tree.
2793 * Composed of what YAHOO reports to be loaded combined
2794 * with what has been loaded by the tool
2796 * @type {string: boolean}
2801 * Flag to indicate the dependency tree needs to be recomputed
2802 * if insert is called again.
2810 * List of modules inserted by the utility
2811 * @property inserted
2812 * @type {string: boolean}
2817 * Provides the information used to skin the skinnable components.
2818 * The following skin definition would result in 'skin1' and 'skin2'
2819 * being loaded for calendar (if calendar was requested), and
2820 * 'sam' for all other skinnable components:
2825 * // The default skin, which is automatically applied if not
2826 * // overriden by a component-specific skin definition.
2827 * // Change this in to apply a different skin globally
2828 * defaultSkin: 'sam',
2830 * // This is combined with the loader base property to get
2831 * // the default root directory for a skin. ex:
2832 * // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/
2833 * base: 'assets/skins/',
2835 * // The name of the rollup css file for the skin
2838 * // The number of skinnable components requested that are
2839 * // required before using the rollup file rather than the
2840 * // individual component css files
2843 * // Any component-specific overrides can be specified here,
2844 * // making it possible to load different skins for different
2845 * // components. It is possible to load more than one skin
2846 * // for a given component as well.
2848 * calendar: ['skin1', 'skin2']
2857 env.listeners.push(function(m) {
2858 if (self._useYahooListener) {
2859 //Y.log("YAHOO listener: " + m.name);
2860 self.loadNext(m.name);
2864 this.skin = lang.merge(YUI.info.skin);
2870 Y.util.YUILoader.prototype = {
2874 'searchExp': "-min\\.js",
2878 'searchExp': "-min\\.js",
2879 'replaceStr': "-debug.js"
2883 SKIN_PREFIX: "skin-",
2885 _config: function(o) {
2887 // apply config values
2890 if (lang.hasOwnProperty(o, i)) {
2891 if (i == "require") {
2901 var f = this.filter;
2903 if (lang.isString(f)) {
2904 f = f.toUpperCase();
2906 // the logger must be available in order to use the debug
2907 // versions of the library
2908 if (f === "DEBUG") {
2909 this.require("logger");
2912 // hack to handle a a bug where LogWriter is being instantiated
2913 // at load time, and the loader has no way to sort above it
2915 if (!Y.widget.LogWriter) {
2916 Y.widget.LogWriter = function() {
2921 this.filter = this.FILTERS[f];
2926 /** Add a new module to the component metadata.
2928 * <dt>name:</dt> <dd>required, the component name</dd>
2929 * <dt>type:</dt> <dd>required, the component type (js or css)</dd>
2930 * <dt>path:</dt> <dd>required, the path to the script from "base"</dd>
2931 * <dt>requires:</dt> <dd>array of modules required by this component</dd>
2932 * <dt>optional:</dt> <dd>array of optional modules for this component</dd>
2933 * <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd>
2934 * <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd>
2935 * <dt>rollup:</dt> <dd>the number of superseded modules required for automatic rollup</dd>
2936 * <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd>
2937 * <dt>skinnable:</dt> <dd>flag to determine if skin assets should automatically be pulled in</dd>
2940 * @param o An object containing the module data
2941 * @return {boolean} true if the module was added, false if
2942 * the object passed in did not provide all required attributes
2944 addModule: function(o) {
2946 if (!o || !o.name || !o.type || (!o.path && !o.fullpath)) {
2950 o.ext = ('ext' in o) ? o.ext : true;
2951 o.requires = o.requires || [];
2953 this.moduleInfo[o.name] = o;
2960 * Add a requirement for one or more module
2962 * @param what {string[] | string*} the modules to load
2964 require: function(what) {
2965 var a = (typeof what === "string") ? arguments : what;
2967 YUI.ObjectUtil.appendArray(this.required, a);
2971 * Adds the skin def to the module info
2973 * @param skin {string} the name of the skin
2974 * @param mod {string} the name of the module
2975 * @return {string} the module name for the skin
2978 _addSkin: function(skin, mod) {
2980 // Add a module definition for the skin rollup css
2981 var name = this.formatSkin(skin), info = this.moduleInfo,
2982 sinf = this.skin, ext = info[mod] && info[mod].ext;
2984 // Y.log('ext? ' + mod + ": " + ext);
2986 // Y.log('adding skin ' + name);
2990 'path': sinf.base + skin + '/' + sinf.path,
2991 //'supersedes': '*',
2992 'after': sinf.after,
2993 'rollup': sinf.rollup,
2998 // Add a module definition for the module-specific skin css
3000 name = this.formatSkin(skin, mod);
3002 var mdef = info[mod], pkg = mdef.pkg || mod;
3003 // Y.log('adding skin ' + name);
3007 'after': sinf.after,
3008 'path': pkg + '/' + sinf.base + skin + '/' + mod + '.css',
3018 * Returns an object containing properties for all modules required
3019 * in order to load the requested module
3020 * @method getRequires
3021 * @param mod The module definition from moduleInfo
3023 getRequires: function(mod) {
3028 if (!this.dirty && mod.expanded) {
3029 return mod.expanded;
3032 mod.requires=mod.requires || [];
3033 var i, d=[], r=mod.requires, o=mod.optional, info=this.moduleInfo, m;
3034 for (i=0; i<r.length; i=i+1) {
3037 YUI.ArrayUtil.appendArray(d, this.getRequires(m));
3040 if (o && this.loadOptional) {
3041 for (i=0; i<o.length; i=i+1) {
3043 YUI.ArrayUtil.appendArray(d, this.getRequires(info[o[i]]));
3047 mod.expanded = YUI.ArrayUtil.uniq(d);
3049 return mod.expanded;
3054 * Returns an object literal of the modules the supplied module satisfies
3055 * @method getProvides
3056 * @param name{string} The name of the module
3057 * @param notMe {string} don't add this module name, only include superseded modules
3058 * @return what this module provides
3060 getProvides: function(name, notMe) {
3061 var addMe = !(notMe), ckey = (addMe) ? PROV : SUPER,
3062 m = this.moduleInfo[name], o = {};
3069 // Y.log('cached: ' + name + ' ' + ckey + ' ' + lang.dump(this.moduleInfo[name][ckey], 0));
3073 var s = m.supersedes, done={}, me = this;
3075 // use worker to break cycles
3076 var add = function(mm) {
3078 // Y.log(name + ' provides worker trying: ' + mm);
3080 // we always want the return value normal behavior
3081 // (provides) for superseded modules.
3082 lang.augmentObject(o, me.getProvides(mm));
3086 // Y.log(name + ' provides worker skipping done: ' + mm);
3090 // calculate superseded modules
3092 for (var i=0; i<s.length; i=i+1) {
3100 m[PROV] = lang.merge(o);
3101 m[PROV][name] = true;
3103 // Y.log(name + " supersedes " + lang.dump(m[SUPER], 0));
3104 // Y.log(name + " provides " + lang.dump(m[PROV], 0));
3111 * Calculates the dependency tree, the result is stored in the sorted
3114 * @param o optional options object
3116 calculate: function(o) {
3117 if (o || this.dirty) {
3121 if (this.allowRollup) {
3127 // Y.log("after calculate: " + lang.dump(this.required));
3134 * Investigates the current YUI configuration on the page. By default,
3135 * modules already detected will not be loaded again unless a force
3136 * option is encountered. Called by calculate()
3140 _setup: function() {
3142 var info = this.moduleInfo, name, i, j;
3144 // Create skin modules
3145 for (name in info) {
3147 if (lang.hasOwnProperty(info, name)) {
3149 if (m && m.skinnable) {
3150 // Y.log("skinning: " + name);
3151 var o=this.skin.overrides, smod;
3153 for (i=0; i<o[name].length; i=i+1) {
3154 smod = this._addSkin(o[name][i], name);
3157 smod = this._addSkin(this.skin.defaultSkin, name);
3160 if (YUI.ArrayUtil.indexOf(m.requires, smod) == -1) {
3161 m.requires.push(smod);
3168 var l = lang.merge(this.inserted); // shallow clone
3170 if (!this._sandbox) {
3171 l = lang.merge(l, env.modules);
3174 // Y.log("Already loaded stuff: " + lang.dump(l, 0));
3176 // add the ignore list to the list of loaded packages
3178 YUI.ObjectUtil.appendArray(l, this.ignore);
3181 // remove modules on the force list from the loaded list
3183 for (i=0; i<this.force.length; i=i+1) {
3184 if (this.force[i] in l) {
3185 delete l[this.force[i]];
3190 // expand the list to include superseded modules
3192 // Y.log("expanding: " + j);
3193 if (lang.hasOwnProperty(l, j)) {
3194 lang.augmentObject(l, this.getProvides(j));
3198 // Y.log("loaded expanded: " + lang.dump(l, 0));
3206 * Inspects the required modules list looking for additional
3207 * dependencies. Expands the required list to include all
3208 * required modules. Called by calculate()
3212 _explode: function() {
3214 var r=this.required, i, mod;
3217 if (lang.hasOwnProperty(r, i)) {
3218 mod = this.moduleInfo[i];
3221 var req = this.getRequires(mod);
3224 YUI.ObjectUtil.appendArray(r, req);
3240 * Returns the skin module name for the specified skin name. If a
3241 * module name is supplied, the returned skin module name is
3242 * specific to the module passed in.
3243 * @method formatSkin
3244 * @param skin {string} the name of the skin
3245 * @param mod {string} optional: the name of a module to skin
3246 * @return {string} the full skin module name
3248 formatSkin: function(skin, mod) {
3249 var s = this.SKIN_PREFIX + skin;
3258 * Reverses <code>formatSkin</code>, providing the skin name and
3259 * module name if the string matches the pattern for skins.
3261 * @param mod {string} the module name to parse
3262 * @return {skin: string, module: string} the parsed skin name
3263 * and module name, or null if the supplied string does not match
3266 parseSkin: function(mod) {
3268 if (mod.indexOf(this.SKIN_PREFIX) === 0) {
3269 var a = mod.split("-");
3270 return {skin: a[1], module: a[2]};
3277 * Look for rollup packages to determine if all of the modules a
3278 * rollup supersedes are required. If so, include the rollup to
3279 * help reduce the total number of connections required. Called
3284 _rollup: function() {
3285 var i, j, m, s, rollups={}, r=this.required, roll,
3286 info = this.moduleInfo;
3288 // find and cache rollup modules
3289 if (this.dirty || !this.rollups) {
3291 if (lang.hasOwnProperty(info, i)) {
3293 //if (m && m.rollup && m.supersedes) {
3294 if (m && m.rollup) {
3300 this.rollups = rollups;
3303 // make as many passes as needed to pick up rollup rollups
3307 // go through the rollup candidates
3308 for (i in rollups) {
3310 // there can be only one
3311 if (!r[i] && !this.loaded[i]) {
3312 m =info[i]; s = m.supersedes; roll=false;
3318 var skin = (m.ext) ? false : this.parseSkin(i), c = 0;
3320 // Y.log('skin? ' + i + ": " + skin);
3323 if (lang.hasOwnProperty(r, j)) {
3324 if (i !== j && this.parseSkin(j)) {
3326 roll = (c >= m.rollup);
3328 // Y.log("skin rollup " + lang.dump(r));
3337 // check the threshold
3338 for (j=0;j<s.length;j=j+1) {
3340 // if the superseded module is loaded, we can't load the rollup
3341 if (this.loaded[s[j]] && (!YUI.dupsAllowed[s[j]])) {
3344 // increment the counter if this module is required. if we are
3345 // beyond the rollup threshold, we will use the rollup module
3346 } else if (r[s[j]]) {
3348 roll = (c >= m.rollup);
3350 // Y.log("over thresh " + c + ", " + lang.dump(r));
3358 // Y.log("rollup: " + i + ", " + lang.dump(this, 1));
3363 // expand the rollup's dependencies
3364 this.getRequires(m);
3369 // if we made it here w/o rolling up something, we are done
3377 * Remove superceded modules and loaded modules. Called by
3378 * calculate() after we have the mega list of all dependencies
3382 _reduce: function() {
3384 var i, j, s, m, r=this.required;
3387 // remove if already loaded
3388 if (i in this.loaded) {
3391 // remove anything this module supersedes
3394 var skinDef = this.parseSkin(i);
3397 //YAHOO.log("skin found in reduce: " + skinDef.skin + ", " + skinDef.module);
3398 // the skin rollup will not have a module name
3399 if (!skinDef.module) {
3400 var skin_pre = this.SKIN_PREFIX + skinDef.skin;
3401 //YAHOO.log("skin_pre: " + skin_pre);
3404 if (lang.hasOwnProperty(r, j)) {
3405 m = this.moduleInfo[j];
3406 var ext = m && m.ext;
3407 if (!ext && j !== i && j.indexOf(skin_pre) > -1) {
3408 // Y.log ("removing component skin: " + j);
3416 m = this.moduleInfo[i];
3417 s = m && m.supersedes;
3419 for (j=0; j<s.length; j=j+1) {
3430 _onFailure: function(msg) {
3431 YAHOO.log('Failure', 'info', 'loader');
3433 var f = this.onFailure;
3435 f.call(this.scope, {
3436 msg: 'failure: ' + msg,
3443 _onTimeout: function() {
3444 YAHOO.log('Timeout', 'info', 'loader');
3445 var f = this.onTimeout;
3447 f.call(this.scope, {
3456 * Sorts the dependency tree. The last step of calculate()
3461 // create an indexed list
3462 var s=[], info=this.moduleInfo, loaded=this.loaded,
3463 checkOptional=!this.loadOptional, me = this;
3465 // returns true if b is not loaded, and is required
3466 // directly or by means of modules it supersedes.
3467 var requires = function(aa, bb) {
3471 if (loaded[bb] || !mm) {
3479 optional = mm.optional;
3482 // check if this module requires the other directly
3483 if (rr && YUI.ArrayUtil.indexOf(rr, bb) > -1) {
3487 // check if this module should be sorted after the other
3488 if (after && YUI.ArrayUtil.indexOf(after, bb) > -1) {
3492 // if loadOptional is not specified, optional dependencies still
3493 // must be sorted correctly when present.
3494 if (checkOptional && optional && YUI.ArrayUtil.indexOf(optional, bb) > -1) {
3498 // check if this module requires one the other supersedes
3499 var ss=info[bb] && info[bb].supersedes;
3501 for (ii=0; ii<ss.length; ii=ii+1) {
3502 if (requires(aa, ss[ii])) {
3508 // external css files should be sorted below yui css
3509 if (mm.ext && mm.type == 'css' && !other.ext && other.type == 'css') {
3516 // get the required items out of the obj into an array so we
3518 for (var i in this.required) {
3519 if (lang.hasOwnProperty(this.required, i)) {
3524 // pointer to the first unsorted item
3527 // keep going until we make a pass without moving anything
3530 var l=s.length, a, b, j, k, moved=false;
3532 // start the loop after items that are already sorted
3533 for (j=p; j<l; j=j+1) {
3535 // check the next module on the list to see if its
3536 // dependencies have been met
3539 // check everything below current item and move if we
3540 // find a requirement for the current item
3541 for (k=j+1; k<l; k=k+1) {
3542 if (requires(a, s[k])) {
3544 // extract the dependency so we can move it up
3547 // insert the dependency above the item that
3549 s.splice(j, 0, b[0]);
3556 // jump out of loop if we moved something
3559 // this item is sorted, move our pointer and keep going
3565 // when we make it here and moved is false, we are
3576 toString: function() {
3580 filter: this.filter,
3581 required: this.required,
3582 loaded: this.loaded,
3583 inserted: this.inserted
3589 _combine: function() {
3591 this._combining = [];
3596 js = this.comboBase,
3597 css = this.comboBase,
3599 startLen = js.length,
3600 i, m, type = this.loadType;
3602 YAHOO.log('type ' + type);
3604 for (i=0; i<len; i=i+1) {
3606 m = this.moduleInfo[s[i]];
3608 if (m && !m.ext && (!type || type === m.type)) {
3610 target = this.root + m.path;
3616 if (m.type == 'js') {
3622 // YAHOO.log(target);
3623 this._combining.push(s[i]);
3627 if (this._combining.length) {
3629 YAHOO.log('Attempting to combine: ' + this._combining, "info", "loader");
3631 var callback=function(o) {
3632 // YAHOO.log('Combo complete: ' + o.data, "info", "loader");
3633 // this._combineComplete = true;
3635 var c=this._combining, len=c.length, i, m;
3636 for (i=0; i<len; i=i+1) {
3637 this.inserted[c[i]] = true;
3640 this.loadNext(o.data);
3643 loadScript = function() {
3644 // YAHOO.log('combining js: ' + js);
3645 if (js.length > startLen) {
3646 YAHOO.util.Get.script(self._filter(js), {
3647 data: self._loading,
3648 onSuccess: callback,
3649 onFailure: self._onFailure,
3650 onTimeout: self._onTimeout,
3651 insertBefore: self.insertBefore,
3652 charset: self.charset,
3653 timeout: self.timeout,
3661 // load the css first
3662 // YAHOO.log('combining css: ' + css);
3663 if (css.length > startLen) {
3664 YAHOO.util.Get.css(this._filter(css), {
3665 data: this._loading,
3666 onSuccess: loadScript,
3667 onFailure: this._onFailure,
3668 onTimeout: this._onTimeout,
3669 insertBefore: this.insertBefore,
3670 charset: this.charset,
3671 timeout: this.timeout,
3681 // this._combineComplete = true;
3682 this.loadNext(this._loading);
3687 * inserts the requested modules and their dependencies.
3688 * <code>type</code> can be "js" or "css". Both script and
3689 * css are inserted if type is not provided.
3691 * @param o optional options object
3692 * @param type {string} the type of dependency to insert
3694 insert: function(o, type) {
3696 // Y.log("insert: " + lang.dump(o, 1) + ", " + type);
3698 // Y.log("insert: " + this.toString() + ", " + type);
3701 // build the dependency list
3705 // set a flag to indicate the load has started
3706 this._loading = true;
3708 // flag to indicate we are done with the combo service
3709 // and any additional files will need to be loaded
3711 // this._combineComplete = false;
3713 // keep the loadType (js, css or undefined) cached
3714 this.loadType = type;
3717 return this._combine();
3721 // Y.log("trying to load css first");
3723 this._internalCallback = function() {
3724 self._internalCallback = null;
3725 self.insert(null, "js");
3727 this.insert(null, "css");
3738 * Interns the script for the requested modules. The callback is
3739 * provided a reference to the sandboxed YAHOO object. This only
3740 * applies to the script: css can not be sandboxed; css will be
3741 * loaded into the page normally if specified.
3743 * @param callback {Function} the callback to exectued when the load is
3746 sandbox: function(o, type) {
3748 // YAHOO.log("sandbox: " + lang.dump(o, 1) + ", " + type);
3750 // YAHOO.log("sandbox: " + this.toString() + ", " + type);
3754 success = function(o) {
3756 var idx=o.argument[0], name=o.argument[2];
3758 // store the response in the position it was requested
3759 self._scriptText[idx] = o.responseText;
3761 // YAHOO.log("received: " + o.responseText.substr(0, 100) + ", " + idx);
3763 if (self.onProgress) {
3764 self.onProgress.call(self.scope, {
3766 scriptText: o.responseText,
3772 // only generate the sandbox once everything is loaded
3775 if (self._loadCount >= self._stopCount) {
3777 // the variable to find
3778 var v = self.varName || "YAHOO";
3780 // wrap the contents of the requested modules in an anonymous function
3781 var t = "(function() {\n";
3783 // return the locally scoped reference.
3784 var b = "\nreturn " + v + ";\n})();";
3786 var ref = eval(t + self._scriptText.join("\n") + b);
3788 self._pushEvents(ref);
3791 self.onSuccess.call(self.scope, {
3796 self._onFailure.call(self.varName + " reference failure");
3801 failure = function(o) {
3802 self.onFailure.call(self.scope, {
3811 if (!self.onSuccess) {
3812 throw new Error("You must supply an onSuccess handler for your sandbox");
3815 self._sandbox = true;
3818 // take care of any css first (this can't be sandboxed)
3819 if (!type || type !== "js") {
3820 self._internalCallback = function() {
3821 self._internalCallback = null;
3822 self.sandbox(null, "js");
3824 self.insert(null, "css");
3828 // get the connection manager if not on the page
3829 if (!util.Connect) {
3830 // get a new loader instance to load connection.
3831 var ld = new YAHOO.util.YUILoader();
3834 filter: self.filter,
3835 require: "connection",
3836 insertBefore: self.insertBefore,
3837 charset: self.charset,
3838 onSuccess: function() {
3839 self.sandbox(null, "js");
3846 self._scriptText = [];
3847 self._loadCount = 0;
3848 self._stopCount = self.sorted.length;
3853 var s=self.sorted, l=s.length, i, m, url;
3855 for (i=0; i<l; i=i+1) {
3856 m = self.moduleInfo[s[i]];
3858 // undefined modules cause a failure
3860 self._onFailure("undefined module " + m);
3861 for (var j=0;j<self._xhr.length;j=j+1) {
3862 self._xhr[j].abort();
3867 // css files should be done
3868 if (m.type !== "js") {
3874 url = (url) ? self._filter(url) : self._url(m.path);
3876 // YAHOO.log("xhr request: " + url + ", " + i);
3882 // [module index, module name, sandbox name]
3883 argument: [i, url, s[i]]
3886 self._xhr.push(util.Connect.asyncRequest('GET', url, xhrData));
3891 * Executed every time a module is loaded, and if we are in a load
3892 * cycle, we attempt to load the next script. Public so that it
3893 * is possible to call this if using a method other than
3894 * YAHOO.register to determine when scripts are fully loaded
3896 * @param mname {string} optional the name of the module that has
3897 * been loaded (which is usually why it is time to load the next
3900 loadNext: function(mname) {
3902 // It is possible that this function is executed due to something
3903 // else one the page loading a YUI module. Only react when we
3904 // are actively loading something
3905 if (!this._loading) {
3910 donext = function(o) {
3911 self.loadNext(o.data);
3912 }, successfn, s = this.sorted, len=s.length, i, fn, m, url;
3917 // if the module that was just loaded isn't what we were expecting,
3919 if (mname !== this._loading) {
3923 // YAHOO.log("loadNext executing, just loaded " + mname);
3925 // The global handler that is called when each module is loaded
3926 // will pass that module name to this function. Storing this
3927 // data to avoid loading the same module multiple times
3928 this.inserted[mname] = true;
3930 if (this.onProgress) {
3931 this.onProgress.call(this.scope, {
3936 //var o = this.getProvides(mname);
3937 //this.inserted = lang.merge(this.inserted, o);
3942 for (i=0; i<len; i=i+1) {
3944 // This.inserted keeps track of what the loader has loaded
3945 if (s[i] in this.inserted) {
3946 // YAHOO.log(s[i] + " alread loaded ");
3950 // Because rollups will cause multiple load notifications
3951 // from YAHOO, loadNext may be called multiple times for
3952 // the same module when loading a rollup. We can safely
3953 // skip the subsequent requests
3954 if (s[i] === this._loading) {
3955 // YAHOO.log("still loading " + s[i] + ", waiting");
3959 // log("inserting " + s[i]);
3960 m = this.moduleInfo[s[i]];
3963 this.onFailure.call(this.scope, {
3964 msg: "undefined module " + m,
3970 // The load type is stored to offer the possibility to load
3971 // the css separately from the script.
3972 if (!this.loadType || this.loadType === m.type) {
3976 this._loading = s[i];
3977 //YAHOO.log("attempting to load " + s[i] + ", " + this.base);
3979 fn = (m.type === "css") ? util.Get.css : util.Get.script;
3981 url = (url) ? this._filter(url) : this._url(m.path);
3983 // safari 2.x or lower, script, and part of YUI
3984 if (env.ua.webkit && env.ua.webkit < 420 && m.type === "js" &&
3986 //YUI.info.moduleInfo[s[i]]) {
3987 //YAHOO.log("using YAHOO env " + s[i] + ", " + m.varName);
3989 this._useYahooListener = true;
3994 onSuccess: successfn,
3995 onFailure: this._onFailure,
3996 onTimeout: this._onTimeout,
3997 insertBefore: this.insertBefore,
3998 charset: this.charset,
3999 timeout: this.timeout,
4009 this._loading = null;
4011 // internal callback for loading css first
4012 if (this._internalCallback) {
4013 var f = this._internalCallback;
4014 this._internalCallback = null;
4016 } else if (this.onSuccess) {
4018 this.onSuccess.call(this.scope, {
4026 * In IE, the onAvailable/onDOMReady events need help when Event is
4027 * loaded dynamically
4028 * @method _pushEvents
4029 * @param {Function} optional function reference
4032 _pushEvents: function(ref) {
4033 var r = ref || YAHOO;
4034 if (r.util && r.util.Event) {
4035 r.util.Event._load();
4042 * @return {string} the filtered string
4045 _filter: function(str) {
4046 var f = this.filter;
4047 return (f) ? str.replace(new RegExp(f.searchExp, 'g'), f.replaceStr) : str;
4051 * Generates the full url for a module
4053 * @param path {string} the path fragment
4054 * @return {string} the full url
4057 _url: function(path) {
4058 return this._filter((this.base || "") + path);
4065 YAHOO.register("yuiloader", YAHOO.util.YUILoader, {version: "2.9.0", build: "2800"});