2 Copyright (c) 2009, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.net/yui/license.txt
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 created by the library. defined by YUI -- create
93 * your own (YAHOO.util, YAHOO.widget, YAHOO.lang, YAHOO.env)
97 * @param {String*} arguments 1-n namespaces to create
98 * @return {Object} A reference to the last namespace object created
100 YAHOO.namespace = function() {
101 var a=arguments, o=null, i, j, d;
102 for (i=0; i<a.length; i=i+1) {
103 d=(""+a[i]).split(".");
106 // YAHOO is implied, so it is ignored if it is included
107 for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; j=j+1) {
108 o[d[j]]=o[d[j]] || {};
117 * Uses YAHOO.widget.Logger to output a log message, if the widget is
122 * @param {String} msg The message to log.
123 * @param {String} cat The log category for the message. Default
124 * categories are "info", "warn", "error", time".
125 * Custom categories can be used as well. (opt)
126 * @param {String} src The source of the the message (opt)
127 * @return {Boolean} True if the log operation was successful.
129 YAHOO.log = function(msg, cat, src) {
130 var l=YAHOO.widget.Logger;
132 return l.log(msg, cat, src);
139 * Registers a module with the YAHOO object
142 * @param {String} name the name of the module (event, slider, etc)
143 * @param {Function} mainClass a reference to class in the module. This
144 * class will be tagged with the version info
145 * so that it will be possible to identify the
146 * version that is in use when multiple versions
148 * @param {Object} data metadata object for the module. Currently it
149 * is expected to contain a "version" property
150 * and a "build" property at minimum.
152 YAHOO.register = function(name, mainClass, data) {
153 var mods = YAHOO.env.modules, m, v, b, ls, i;
165 ls = YAHOO.env.listeners;
172 m.mainClass = mainClass;
174 // fire the module load listeners
175 for (i=0;i<ls.length;i=i+1) {
178 // label the main class
180 mainClass.VERSION = v;
183 YAHOO.log("mainClass is undefined for module " + name, "warn");
188 * YAHOO.env is used to keep track of what is known about the YUI library and
189 * the browsing environment
193 YAHOO.env = YAHOO.env || {
196 * Keeps the version info for all YUI modules that have reported themselves
203 * List of functions that should be executed every time a YUI module
205 * @property listeners
212 * Returns the version data for the specified module:
214 * <dt>name:</dt> <dd>The name of the module</dd>
215 * <dt>version:</dt> <dd>The version in use</dd>
216 * <dt>build:</dt> <dd>The build number in use</dd>
217 * <dt>versions:</dt> <dd>All versions that were registered</dd>
218 * <dt>builds:</dt> <dd>All builds that were registered.</dd>
219 * <dt>mainClass:</dt> <dd>An object that was was stamped with the
220 * current version and build. If
221 * mainClass.VERSION != version or mainClass.BUILD != build,
222 * multiple versions of pieces of the library have been
223 * loaded, potentially causing issues.</dd>
228 * @param {String} name the name of the module (event, slider, etc)
229 * @return {Object} The version info
231 YAHOO.env.getVersion = function(name) {
232 return YAHOO.env.modules[name] || null;
236 * Do not fork for a browser if it can be avoided. Use feature detection when
237 * you can. Use the user agent as a last resort. YAHOO.env.ua stores a version
238 * number for the browser engine, 0 otherwise. This value may or may not map
239 * to the version number of the browser using the engine. The value is
240 * presented as a float so that it can easily be used for boolean evaluation
241 * as well as for looking for a particular range of versions. Because of this,
242 * some of the granularity of the version info may be lost (e.g., Gecko 1.8.0.9
244 * @class YAHOO.env.ua
247 YAHOO.env.ua = function() {
251 * Internet Explorer version number or 0. Example: 6
258 * Opera version number or 0. Example: 9.2
265 * Gecko engine revision number. Will evaluate to 1 if Gecko
266 * is detected but the revision could not be found. Other browsers
267 * will be 0. Example: 1.8
269 * Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7
270 * Firefox 1.5.0.9: 1.8.0.9 <-- Reports 1.8
271 * Firefox 2.0.0.3: 1.8.1.3 <-- Reports 1.8
272 * Firefox 3 alpha: 1.9a4 <-- Reports 1.9
280 * AppleWebKit version. KHTML browsers that are not WebKit browsers
281 * will evaluate to 1, other browsers 0. Example: 418.9.1
283 * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
284 * latest available for Mac OSX 10.3.
285 * Safari 2.0.2: 416 <-- hasOwnProperty introduced
286 * Safari 2.0.4: 418 <-- preventDefault fixed
287 * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
288 * different versions of webkit
289 * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been
290 * updated, but not updated
291 * to the latest patch.
292 * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native SVG
293 * and many major issues fixed).
294 * 3.x yahoo.com, flickr:422 <-- Safari 3.x hacks the user agent
295 * string when hitting yahoo.com and
297 * Safari 3.0.4 (523.12):523.12 <-- First Tiger release - automatic update
298 * from 2.x via the 10.4.11 OS patch
299 * Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event.
300 * yahoo.com user agent hack removed.
303 * http://developer.apple.com/internet/safari/uamatrix.html
310 * The mobile property will be set to a string containing any relevant
311 * user agent information when a modern mobile browser is detected.
312 * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
313 * devices with the WebKit-based browser, and Opera Mini.
320 * Adobe AIR version number or 0. Only populated if webkit is detected.
328 * Google Caja version number or 0.
336 ua = navigator.userAgent,
340 // Modern KHTML browsers should qualify as Safari X-Grade
341 if ((/KHTML/).test(ua)) {
344 // Modern WebKit browsers are at least X-Grade
345 m=ua.match(/AppleWebKit\/([^\s]*)/);
347 o.webkit=parseFloat(m[1]);
349 // Mobile browser check
350 if (/ Mobile\//.test(ua)) {
351 o.mobile = "Apple"; // iPhone or iPod Touch
353 m=ua.match(/NokiaN[^\/]*/);
355 o.mobile = m[0]; // Nokia N-series, ex: NokiaN95
359 m=ua.match(/AdobeAIR\/([^\s]*)/);
361 o.air = m[0]; // Adobe AIR 1.0 or better
366 if (!o.webkit) { // not webkit
367 // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
368 m=ua.match(/Opera[\s\/]([^\s]*)/);
370 o.opera=parseFloat(m[1]);
371 m=ua.match(/Opera Mini[^;]*/);
373 o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
375 } else { // not opera or webkit
376 m=ua.match(/MSIE\s([^;]*)/);
378 o.ie=parseFloat(m[1]);
379 } else { // not opera, webkit, or ie
380 m=ua.match(/Gecko\/([^\s]*)/);
382 o.gecko=1; // Gecko detected, look for revision
383 m=ua.match(/rv:([^\s\)]*)/);
385 o.gecko=parseFloat(m[1]);
392 m=ua.match(/Caja\/([^\s]*)/);
394 o.caja=parseFloat(m[1]);
401 * Initializes the global by creating the default namespaces and applying
402 * any new configuration information that is detected. This is the setup
409 YAHOO.namespace("util", "widget", "example");
410 /*global YAHOO_config*/
411 if ("undefined" !== typeof YAHOO_config) {
412 var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i;
414 // if YAHOO is loaded multiple times we need to check to see if
415 // this is a new config object. If it is, add the new component
416 // load listener to the stack
417 for (i=0;i<ls.length;i=i+1) {
430 * Provides the language utilites and extensions used by the library
433 YAHOO.lang = YAHOO.lang || {};
440 ARRAY_TOSTRING = '[object Array]',
441 FUNCTION_TOSTRING = '[object Function]',
442 OP = Object.prototype,
444 // ADD = ["toString", "valueOf", "hasOwnProperty"],
445 ADD = ["toString", "valueOf"],
450 * Determines wheather or not the provided object is an array.
452 * @param {any} o The object being testing
453 * @return {boolean} the result
455 isArray: function(o) {
456 return OP.toString.apply(o) === ARRAY_TOSTRING;
460 * Determines whether or not the provided object is a boolean
462 * @param {any} o The object being testing
463 * @return {boolean} the result
465 isBoolean: function(o) {
466 return typeof o === 'boolean';
470 * Determines whether or not the provided object is a function.
471 * Note: Internet Explorer thinks certain functions are objects:
473 * var obj = document.createElement("object");
474 * YAHOO.lang.isFunction(obj.getAttribute) // reports false in IE
476 * var input = document.createElement("input"); // append to body
477 * YAHOO.lang.isFunction(input.focus) // reports false in IE
479 * You will have to implement additional tests if these functions
483 * @param {any} o The object being testing
484 * @return {boolean} the result
486 isFunction: function(o) {
487 return OP.toString.apply(o) === FUNCTION_TOSTRING;
491 * Determines whether or not the provided object is null
493 * @param {any} o The object being testing
494 * @return {boolean} the result
496 isNull: function(o) {
501 * Determines whether or not the provided object is a legal number
503 * @param {any} o The object being testing
504 * @return {boolean} the result
506 isNumber: function(o) {
507 return typeof o === 'number' && isFinite(o);
511 * Determines whether or not the provided object is of type object
514 * @param {any} o The object being testing
515 * @return {boolean} the result
517 isObject: function(o) {
518 return (o && (typeof o === 'object' || L.isFunction(o))) || false;
522 * Determines whether or not the provided object is a string
524 * @param {any} o The object being testing
525 * @return {boolean} the result
527 isString: function(o) {
528 return typeof o === 'string';
532 * Determines whether or not the provided object is undefined
533 * @method isUndefined
534 * @param {any} o The object being testing
535 * @return {boolean} the result
537 isUndefined: function(o) {
538 return typeof o === 'undefined';
543 * IE will not enumerate native functions in a derived object even if the
544 * function was overridden. This is a workaround for specific functions
545 * we care about on the Object prototype.
546 * @property _IEEnumFix
547 * @param {Function} r the object to receive the augmentation
548 * @param {Function} s the object that supplies the properties to augment
552 _IEEnumFix: (YAHOO.env.ua.ie) ? function(r, s) {
554 for (i=0;i<ADD.length;i=i+1) {
559 if (L.isFunction(f) && f!=OP[fname]) {
566 * Utility to set up the prototype, constructor and superclass properties to
567 * support an inheritance strategy that can chain constructors and methods.
568 * Static members will not be inherited.
572 * @param {Function} subc the object to modify
573 * @param {Function} superc the object to inherit
574 * @param {Object} overrides additional properties/methods to add to the
575 * subclass prototype. These will override the
576 * matching items obtained from the superclass
579 extend: function(subc, superc, overrides) {
580 if (!superc||!subc) {
581 throw new Error("extend failed, please check that " +
582 "all dependencies are included.");
584 var F = function() {}, i;
585 F.prototype=superc.prototype;
586 subc.prototype=new F();
587 subc.prototype.constructor=subc;
588 subc.superclass=superc.prototype;
589 if (superc.prototype.constructor == OP.constructor) {
590 superc.prototype.constructor=superc;
594 for (i in overrides) {
595 if (L.hasOwnProperty(overrides, i)) {
596 subc.prototype[i]=overrides[i];
600 L._IEEnumFix(subc.prototype, overrides);
605 * Applies all properties in the supplier to the receiver if the
606 * receiver does not have these properties yet. Optionally, one or
607 * more methods/properties can be specified (as additional
608 * parameters). This option will overwrite the property if receiver
609 * has it already. If true is passed as the third parameter, all
610 * properties will be applied and _will_ overwrite properties in
613 * @method augmentObject
616 * @param {Function} r the object to receive the augmentation
617 * @param {Function} s the object that supplies the properties to augment
618 * @param {String*|boolean} arguments zero or more properties methods
619 * to augment the receiver with. If none specified, everything
620 * in the supplier will be used unless it would
621 * overwrite an existing property in the receiver. If true
622 * is specified as the third parameter, all properties will
623 * be applied and will overwrite an existing property in
626 augmentObject: function(r, s) {
628 throw new Error("Absorb failed, verify dependencies.");
630 var a=arguments, i, p, overrideList=a[2];
631 if (overrideList && overrideList!==true) { // only absorb the specified properties
632 for (i=2; i<a.length; i=i+1) {
635 } else { // take everything, overwriting only if the third parameter is true
637 if (overrideList || !(p in r)) {
647 * Same as YAHOO.lang.augmentObject, except it only applies prototype properties
648 * @see YAHOO.lang.augmentObject
649 * @method augmentProto
651 * @param {Function} r the object to receive the augmentation
652 * @param {Function} s the object that supplies the properties to augment
653 * @param {String*|boolean} arguments zero or more properties methods
654 * to augment the receiver with. If none specified, everything
655 * in the supplier will be used unless it would overwrite an existing
656 * property in the receiver. if true is specified as the third
657 * parameter, all properties will be applied and will overwrite an
658 * existing property in the receiver
660 augmentProto: function(r, s) {
662 throw new Error("Augment failed, verify dependencies.");
664 //var a=[].concat(arguments);
665 var a=[r.prototype,s.prototype], i;
666 for (i=2;i<arguments.length;i=i+1) {
667 a.push(arguments[i]);
669 L.augmentObject.apply(this, a);
674 * Returns a simple string representation of the object or array.
675 * Other types of objects will be returned unprocessed. Arrays
676 * are expected to be indexed. Use object notation for
677 * associative arrays.
680 * @param o {Object} The object to dump
681 * @param d {int} How deep to recurse child objects, default 3
682 * @return {String} the dump result
684 dump: function(o, d) {
685 var i,len,s=[],OBJ="{...}",FUN="f(){...}",
686 COMMA=', ', ARROW=' => ';
688 // Cast non-objects to string
689 // Skip dates because the std toString is what we want
690 // Skip HTMLElement-like objects because trying to dump
691 // an element will cause an unhandled exception in FF 2.x
692 if (!L.isObject(o)) {
694 } else if (o instanceof Date || ("nodeType" in o && "tagName" in o)) {
696 } else if (L.isFunction(o)) {
700 // dig into child objects the depth specifed. Default 3
701 d = (L.isNumber(d)) ? d : 3;
706 for (i=0,len=o.length;i<len;i=i+1) {
707 if (L.isObject(o[i])) {
708 s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
718 // objects {k1 => v1, k2 => v2}
722 if (L.hasOwnProperty(o, i)) {
724 if (L.isObject(o[i])) {
725 s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
742 * Does variable substitution on a string. It scans through the string
743 * looking for expressions enclosed in { } braces. If an expression
744 * is found, it is used a key on the object. If there is a space in
745 * the key, the first word is used for the key and the rest is provided
746 * to an optional function to be used to programatically determine the
747 * value (the extra information might be used for this decision). If
748 * the value for the key in the object, or what is returned from the
749 * function has a string value, number value, or object value, it is
750 * substituted for the bracket expression and it repeats. If this
751 * value is an object, it uses the Object's toString() if this has
752 * been overridden, otherwise it does a shallow dump of the key/value
756 * @param s {String} The string that will be modified.
757 * @param o {Object} An object containing the replacement values
758 * @param f {Function} An optional function that can be used to
759 * process each match. It receives the key,
760 * value, and any extra metadata included with
761 * the key inside of the braces.
762 * @return {String} the substituted string
764 substitute: function (s, o, f) {
765 var i, j, k, key, v, meta, saved=[], token,
766 DUMP='dump', SPACE=' ', LBRACE='{', RBRACE='}',
771 i = s.lastIndexOf(LBRACE);
775 j = s.indexOf(RBRACE, i);
780 //Extract key and meta info
781 token = s.substring(i + 1, j);
784 k = key.indexOf(SPACE);
786 meta = key.substring(k + 1);
787 key = key.substring(0, k);
793 // if a substitution function was provided, execute it
800 v = L.dump(v, parseInt(meta, 10));
804 // look for the keyword 'dump', if found force obj dump
805 dump = meta.indexOf(DUMP);
807 meta = meta.substring(4);
810 // use the toString if it is not the Object toString
811 // and the 'dump' meta info was not found
812 if (v.toString===OP.toString || dump>-1) {
813 v = L.dump(v, parseInt(meta, 10));
818 } else if (!L.isString(v) && !L.isNumber(v)) {
819 // This {block} has no replace string. Save it for later.
820 v = "~-" + saved.length + "-~";
821 saved[saved.length] = token;
826 s = s.substring(0, i) + v + s.substring(j + 1);
831 // restore saved {block}s
832 for (i=saved.length-1; i>=0; i=i-1) {
833 s = s.replace(new RegExp("~-" + i + "-~"), "{" + saved[i] + "}", "g");
841 * Returns a string without any leading or trailing whitespace. If
842 * the input is not a string, the input will be returned untouched.
845 * @param s {string} the string to trim
846 * @return {string} the trimmed string
850 return s.replace(/^\s+|\s+$/g, "");
857 * Returns a new object containing all of the properties of
858 * all the supplied objects. The properties from later objects
859 * will overwrite those in earlier objects.
862 * @param arguments {Object*} the objects to merge
863 * @return the new merged object
866 var o={}, a=arguments, l=a.length, i;
867 for (i=0; i<l; i=i+1) {
868 L.augmentObject(o, a[i], true);
874 * Executes the supplied function in the context of the supplied
875 * object 'when' milliseconds later. Executes the function a
876 * single time unless periodic is set to true.
879 * @param when {int} the number of milliseconds to wait until the fn
881 * @param o the context object
882 * @param fn {Function|String} the function to execute or the name of
883 * the method in the 'o' object to execute
884 * @param data [Array] data that is provided to the function. This accepts
885 * either a single item or an array. If an array is provided, the
886 * function is executed with one parameter for each array item. If
887 * you need to pass a single array parameter, it needs to be wrapped in
889 * @param periodic {boolean} if true, executes continuously at supplied
890 * interval until canceled
891 * @return a timer object. Call the cancel() method on this object to
894 later: function(when, o, fn, data, periodic) {
897 var m=fn, d=data, f, r;
899 if (L.isString(fn)) {
904 throw new TypeError("method undefined");
915 r = (periodic) ? setInterval(f, when) : setTimeout(f, when);
930 * A convenience method for detecting a legitimate non-null value.
931 * Returns false for null/undefined/NaN, true for other values,
932 * including 0/false/''
935 * @param o {any} the item to test
936 * @return {boolean} true if it is not null/undefined/NaN || false
938 isValue: function(o) {
939 // return (o || o === false || o === 0 || o === ''); // Infinity fails
940 return (L.isObject(o) || L.isString(o) || L.isNumber(o) || L.isBoolean(o));
946 * Determines whether or not the property was added
947 * to the object instance. Returns false if the property is not present
948 * in the object, or was inherited from the prototype.
949 * This abstraction is provided to enable hasOwnProperty for Safari 1.3.x.
950 * There is a discrepancy between YAHOO.lang.hasOwnProperty and
951 * Object.prototype.hasOwnProperty when the property is a primitive added to
952 * both the instance AND prototype with the same value:
954 * var A = function() {};
955 * A.prototype.foo = 'foo';
958 * alert(a.hasOwnProperty('foo')); // true
959 * alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback
961 * @method hasOwnProperty
962 * @param {any} o The object being testing
963 * @param prop {string} the name of the property to test
964 * @return {boolean} the result
966 L.hasOwnProperty = (OP.hasOwnProperty) ?
968 return o && o.hasOwnProperty(prop);
969 } : function(o, prop) {
970 return !L.isUndefined(o[prop]) &&
971 o.constructor.prototype[prop] !== o[prop];
975 OB.augmentObject(L, OB, true);
978 * An alias for <a href="YAHOO.lang.html">YAHOO.lang</a>
979 * @class YAHOO.util.Lang
984 * Same as YAHOO.lang.augmentObject, except it only applies prototype
985 * properties. This is an alias for augmentProto.
986 * @see YAHOO.lang.augmentObject
989 * @param {Function} r the object to receive the augmentation
990 * @param {Function} s the object that supplies the properties to augment
991 * @param {String*|boolean} arguments zero or more properties methods to
992 * augment the receiver with. If none specified, everything
993 * in the supplier will be used unless it would
994 * overwrite an existing property in the receiver. if true
995 * is specified as the third parameter, all properties will
996 * be applied and will overwrite an existing property in
999 L.augment = L.augmentProto;
1002 * An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a>
1006 * @param {Function} r the object to receive the augmentation
1007 * @param {Function} s the object that supplies the properties to augment
1008 * @param {String*} arguments zero or more properties methods to
1009 * augment the receiver with. If none specified, everything
1010 * in the supplier will be used unless it would
1011 * overwrite an existing property in the receiver
1013 YAHOO.augment = L.augmentProto;
1016 * An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a>
1019 * @param {Function} subc the object to modify
1020 * @param {Function} superc the object to inherit
1021 * @param {Object} overrides additional properties/methods to add to the
1022 * subclass prototype. These will override the
1023 * matching items obtained from the superclass if present.
1025 YAHOO.extend = L.extend;
1028 YAHOO.register("yahoo", YAHOO, {version: "2.7.0", build: "1799"});
1030 * Provides a mechanism to fetch remote resources and
1031 * insert them into a document
1037 * Fetches and inserts one or more script or link nodes into the document
1038 * @namespace YAHOO.util
1039 * @class YAHOO.util.Get
1041 YAHOO.util.Get = function() {
1044 * hash of queues to manage multiple requests
1051 * queue index used to generate transaction ids
1059 * node index used to generate unique node ids
1068 // sandboxFrame=null,
1071 * interal property used to prevent multiple simultaneous purge
1084 * Generates an HTML element, this is not appended to a document
1086 * @param type {string} the type of element
1087 * @param attr {string} the attributes
1088 * @param win {Window} optional window to create the element in
1089 * @return {HTMLElement} the generated node
1092 var _node = function(type, attr, win) {
1093 var w = win || window, d=w.document, n=d.createElement(type);
1095 for (var i in attr) {
1096 if (attr[i] && YAHOO.lang.hasOwnProperty(attr, i)) {
1097 n.setAttribute(i, attr[i]);
1105 * Generates a link node
1107 * @param url {string} the url for the css file
1108 * @param win {Window} optional window to create the node in
1109 * @return {HTMLElement} the generated node
1112 var _linkNode = function(url, win, charset) {
1113 var c = charset || "utf-8";
1114 return _node("link", {
1115 "id": "yui__dyn_" + (nidx++),
1118 "rel": "stylesheet",
1124 * Generates a script node
1125 * @method _scriptNode
1126 * @param url {string} the url for the script file
1127 * @param win {Window} optional window to create the node in
1128 * @return {HTMLElement} the generated node
1131 var _scriptNode = function(url, win, charset) {
1132 var c = charset || "utf-8";
1133 return _node("script", {
1134 "id": "yui__dyn_" + (nidx++),
1135 "type": "text/javascript",
1142 * Returns the data payload for callback functions
1143 * @method _returnData
1146 var _returnData = function(q, msg) {
1159 var _get = function(nId, tId) {
1160 var q = queues[tId],
1161 n = (lang.isString(nId)) ? q.win.document.getElementById(nId) : nId;
1163 _fail(tId, "target node not found: " + nId);
1170 * The request failed, execute fail handler with whatever
1171 * was accomplished. There isn't a failure case at the
1172 * moment unless you count aborted transactions
1174 * @param id {string} the id of the request
1177 var _fail = function(id, msg) {
1179 // execute failure callback
1181 var sc=q.scope || q.win;
1182 q.onFailure.call(sc, _returnData(q, msg));
1187 * The request is complete, so executing the requester's callback
1189 * @param id {string} the id of the request
1192 var _finish = function(id) {
1197 var msg = "transaction " + id + " was aborted";
1202 // execute success callback
1204 var sc=q.scope || q.win;
1205 q.onSuccess.call(sc, _returnData(q));
1212 * @param id {string} the id of the request
1215 var _timeout = function(id) {
1218 var sc=q.scope || q;
1219 q.onTimeout.call(sc, _returnData(q));
1224 * Loads the next item for a given request
1226 * @param id {string} the id of the request
1227 * @param loaded {string} the url that was just loaded, if any
1230 var _next = function(id, loaded) {
1234 // Y.log('cancel timer');
1239 var msg = "transaction " + id + " was aborted";
1250 // This is the first pass: make sure the url is an array
1251 q.url = (lang.isString(q.url)) ? [q.url] : q.url;
1253 q.varName = (lang.isString(q.varName)) ? [q.varName] : q.varName;
1257 var w=q.win, d=w.document, h=d.getElementsByTagName("head")[0], n;
1259 if (q.url.length === 0) {
1260 // Safari 2.x workaround - There is no way to know when
1261 // a script is ready in versions of Safari prior to 3.x.
1262 // Adding an extra node reduces the problem, but doesn't
1263 // eliminate it completely because the browser executes
1264 // them asynchronously.
1265 if (q.type === "script" && ua.webkit && ua.webkit < 420 &&
1266 !q.finalpass && !q.varName) {
1267 // Add another script node. This does not guarantee that the
1268 // scripts will execute in order, but it does appear to fix the
1269 // problem on fast connections more effectively than using an
1270 // arbitrary timeout. It is possible that the browser does
1271 // block subsequent script execution in this case for a limited
1273 var extra = _scriptNode(null, q.win, q.charset);
1274 extra.innerHTML='YAHOO.util.Get._finalize("' + id + '");';
1275 q.nodes.push(extra); h.appendChild(extra);
1287 // if the url is undefined, this is probably a trailing comma problem in IE
1295 // Y.log('create timer');
1296 q.timer = lang.later(q.timeout, q, _timeout, id);
1299 if (q.type === "script") {
1300 n = _scriptNode(url, w, q.charset);
1302 n = _linkNode(url, w, q.charset);
1305 // track this node's load progress
1306 _track(q.type, n, id, url, w, q.url.length);
1308 // add the node to the queue so we can return it to the user supplied callback
1311 // add it to the head or insert it before 'insertBefore'
1312 if (q.insertBefore) {
1313 var s = _get(q.insertBefore, id);
1315 s.parentNode.insertBefore(n, s);
1322 // FireFox does not support the onload event for link nodes, so there is
1323 // no way to make the css requests synchronous. This means that the css
1324 // rules in multiple files could be applied out of order in this browser
1325 // if a later request returns before an earlier one. Safari too.
1326 if ((ua.webkit || ua.gecko) && q.type === "css") {
1332 * Removes processed queues and corresponding nodes
1333 * @method _autoPurge
1336 var _autoPurge = function() {
1343 for (var i in queues) {
1345 if (q.autopurge && q.finished) {
1355 * Removes the nodes for the specified queue
1359 var _purge = function(tId) {
1362 var n=q.nodes, l=n.length, d=q.win.document,
1363 h=d.getElementsByTagName("head")[0];
1365 if (q.insertBefore) {
1366 var s = _get(q.insertBefore, tId);
1372 for (var i=0; i<l; i=i+1) {
1373 h.removeChild(n[i]);
1381 * Saves the state for the request and begins loading
1382 * the requested urls
1384 * @param type {string} the type of node to insert
1385 * @param url {string} the url to load
1386 * @param opts the hash of options for this request
1389 var _queue = function(type, url, opts) {
1391 var id = "q" + (qidx++);
1394 if (qidx % YAHOO.util.Get.PURGE_THRESH === 0) {
1398 queues[id] = lang.merge(opts, {
1408 q.win = q.win || window;
1409 q.scope = q.scope || q.win;
1410 q.autopurge = ("autopurge" in q) ? q.autopurge :
1411 (type === "script") ? true : false;
1413 lang.later(0, q, _next, id);
1421 * Detects when a node has been loaded. In the case of
1422 * script nodes, this does not guarantee that contained
1423 * script is ready to use.
1425 * @param type {string} the type of node to track
1426 * @param n {HTMLElement} the node to track
1427 * @param id {string} the id of the request
1428 * @param url {string} the url that is being loaded
1429 * @param win {Window} the targeted window
1430 * @param qlength the number of remaining items in the queue,
1431 * including this one
1432 * @param trackfn {Function} function to execute when finished
1433 * the default is _next
1436 var _track = function(type, n, id, url, win, qlength, trackfn) {
1437 var f = trackfn || _next;
1439 // IE supports the readystatechange event for script and css nodes
1441 n.onreadystatechange = function() {
1442 var rs = this.readyState;
1443 if ("loaded" === rs || "complete" === rs) {
1444 n.onreadystatechange = null;
1449 // webkit prior to 3.x is problemmatic
1450 } else if (ua.webkit) {
1452 if (type === "script") {
1454 // Safari 3.x supports the load event for script nodes (DOM2)
1455 if (ua.webkit >= 420) {
1457 n.addEventListener("load", function() {
1461 // Nothing can be done with Safari < 3.x except to pause and hope
1462 // for the best, particularly after last script is inserted. The
1463 // scripts will always execute in the order they arrive, not
1464 // necessarily the order in which they were inserted. To support
1465 // script nodes with complete reliability in these browsers, script
1466 // nodes either need to invoke a function in the window once they
1467 // are loaded or the implementer needs to provide a well-known
1468 // property that the utility can poll for.
1470 // Poll for the existence of the named variable, if it
1474 var freq=YAHOO.util.Get.POLL_FREQ;
1475 q.maxattempts = YAHOO.util.Get.TIMEOUT/freq;
1477 q._cache = q.varName[0].split(".");
1478 q.timer = lang.later(freq, q, function(o) {
1479 var a=this._cache, l=a.length, w=this.win, i;
1480 for (i=0; i<l; i=i+1) {
1483 // if we have exausted our attempts, give up
1485 if (this.attempts++ > this.maxattempts) {
1486 var msg = "Over retry limit, giving up";
1501 lang.later(YAHOO.util.Get.POLL_FREQ, null, f, [id, url]);
1506 // FireFox and Opera support onload (but not DOM2 in FF) handlers for
1507 // script nodes. Opera, but not FF, supports the onload event for link
1510 n.onload = function() {
1519 * The default poll freqency in ms, when needed
1520 * @property POLL_FREQ
1528 * The number of request required before an automatic purge.
1529 * property PURGE_THRESH
1537 * The length time to poll for varName when loading a script in
1538 * Safari 2.x before the transaction fails.
1547 * Called by the the helper for detecting script load in Safari
1549 * @param id {string} the transaction id
1552 _finalize: function(id) {
1553 lang.later(0, null, _finish, id);
1557 * Abort a transaction
1559 * @param {string|object} either the tId or the object returned from
1562 abort: function(o) {
1563 var id = (lang.isString(o)) ? o : o.tId;
1571 * Fetches and inserts one or more script nodes into the head
1572 * of the current document or the document in a specified window.
1576 * @param url {string|string[]} the url or urls to the script(s)
1577 * @param opts {object} Options:
1579 * <dt>onSuccess</dt>
1581 * callback to execute when the script(s) are finished loading
1582 * The callback receives an object back with the following
1586 * <dd>the window the script(s) were inserted into</dd>
1588 * <dd>the data object passed in when the request was made</dd>
1590 * <dd>An array containing references to the nodes that were
1593 * <dd>A function that, when executed, will remove the nodes
1594 * that were inserted</dd>
1598 * <dt>onFailure</dt>
1600 * callback to execute when the script load operation fails
1601 * The callback receives an object back with the following
1605 * <dd>the window the script(s) were inserted into</dd>
1607 * <dd>the data object passed in when the request was made</dd>
1609 * <dd>An array containing references to the nodes that were
1610 * inserted successfully</dd>
1612 * <dd>A function that, when executed, will remove any nodes
1613 * that were inserted</dd>
1617 * <dt>onTimeout</dt>
1619 * callback to execute when a timeout occurs.
1620 * The callback receives an object back with the following
1624 * <dd>the window the script(s) were inserted into</dd>
1626 * <dd>the data object passed in when the request was made</dd>
1628 * <dd>An array containing references to the nodes that were
1631 * <dd>A function that, when executed, will remove the nodes
1632 * that were inserted</dd>
1637 * <dd>the execution context for the callbacks</dd>
1639 * <dd>a window other than the one the utility occupies</dd>
1640 * <dt>autopurge</dt>
1642 * setting to true will let the utilities cleanup routine purge
1643 * the script once loaded
1647 * data that is supplied to the callback when the script(s) are
1652 * variable that should be available when a script is finished
1653 * loading. Used to help Safari 2.x and below with script load
1654 * detection. The type of this property should match what was
1655 * passed into the url parameter: if loading a single url, a
1656 * string can be supplied. If loading multiple scripts, you
1657 * must supply an array that contains the variable name for
1660 * <dt>insertBefore</dt>
1661 * <dd>node or node id that will become the new node's nextSibling</dd>
1664 * <dd>Node charset, default utf-8</dd>
1666 * <dd>Number of milliseconds to wait before aborting and firing the timeout event</dd>
1668 * // assumes yahoo, dom, and event are already on the page
1669 * YAHOO.util.Get.script(
1670 * ["http://yui.yahooapis.com/2.3.1/build/dragdrop/dragdrop-min.js",
1671 * "http://yui.yahooapis.com/2.3.1/build/animation/animation-min.js"], {
1672 * onSuccess: function(o) {
1673 * new YAHOO.util.DDProxy("dd1"); // also new o.reference("dd1"); would work
1674 * this.log("won't cause error because YAHOO is the scope");
1675 * this.log(o.nodes.length === 2) // true
1676 * // o.purge(); // optionally remove the script nodes immediately
1677 * },
1678 * onFailure: function(o) {
1679 * },
1680 * data: "foo",
1681 * timeout: 10000, // 10 second timeout
1682 * scope: YAHOO,
1683 * // win: otherframe // target another window/frame
1684 * autopurge: true // allow the utility to choose when to remove the nodes
1685 * });
1687 * @return {tId: string} an object containing info about the transaction
1689 script: function(url, opts) { return _queue("script", url, opts); },
1692 * Fetches and inserts one or more css link nodes into the
1693 * head of the current document or the document in a specified
1697 * @param url {string} the url or urls to the css file(s)
1698 * @param opts Options:
1700 * <dt>onSuccess</dt>
1702 * callback to execute when the css file(s) are finished loading
1703 * The callback receives an object back with the following
1706 * <dd>the window the link nodes(s) were inserted into</dd>
1708 * <dd>the data object passed in when the request was made</dd>
1710 * <dd>An array containing references to the nodes that were
1713 * <dd>A function that, when executed, will remove the nodes
1714 * that were inserted</dd>
1719 * <dd>the execution context for the callbacks</dd>
1721 * <dd>a window other than the one the utility occupies</dd>
1724 * data that is supplied to the callbacks when the nodes(s) are
1727 * <dt>insertBefore</dt>
1728 * <dd>node or node id that will become the new node's nextSibling</dd>
1730 * <dd>Node charset, default utf-8</dd>
1733 * YAHOO.util.Get.css("http://yui.yahooapis.com/2.3.1/build/menu/assets/skins/sam/menu.css");
1736 * YAHOO.util.Get.css(["http://yui.yahooapis.com/2.3.1/build/menu/assets/skins/sam/menu.css",
1738 * @return {tId: string} an object containing info about the transaction
1740 css: function(url, opts) {
1741 return _queue("css", url, opts);
1746 YAHOO.register("get", YAHOO.util.Get, {version: "2.7.0", build: "1799"});
1748 * Provides dynamic loading for the YUI library. It includes the dependency
1749 * info for the library, and will automatically pull in dependencies for
1750 * the modules requested. It supports rollup files (such as utilities.js
1751 * and yahoo-dom-event.js), and will automatically use these when
1752 * appropriate in order to minimize the number of http connections
1753 * required to load all of the dependencies.
1756 * @namespace YAHOO.util
1760 * YUILoader provides dynamic loading for YUI.
1761 * @class YAHOO.util.YUILoader
1763 * version management, automatic sandboxing
1767 var Y=YAHOO, util=Y.util, lang=Y.lang, env=Y.env,
1768 PROV = "_provides", SUPER = "_supersedes",
1769 REQ = "expanded", AFTER = "_after";
1773 dupsAllowed: {'yahoo': true, 'get': true},
1776 * The library metadata for the current release The is the default
1777 * value for YAHOO.util.YUILoader.moduleInfo
1783 // 'root': '2.5.2/build/',
1784 // 'base': 'http://yui.yahooapis.com/2.5.2/build/',
1786 'root': '2.7.0/build/',
1787 'base': 'http://yui.yahooapis.com/2.7.0/build/',
1789 'comboBase': 'http://yui.yahooapis.com/combo?',
1792 'defaultSkin': 'sam',
1793 'base': 'assets/skins/',
1795 'after': ['reset', 'fonts', 'grids', 'base'],
1799 dupsAllowed: ['yahoo', 'get'],
1805 'path': 'animation/animation-min.js',
1806 'requires': ['dom', 'event']
1811 'path': 'autocomplete/autocomplete-min.js',
1812 'requires': ['dom', 'event', 'datasource'],
1813 'optional': ['connection', 'animation'],
1819 'path': 'base/base-min.css',
1820 'after': ['reset', 'fonts', 'grids']
1825 'path': 'button/button-min.js',
1826 'requires': ['element'],
1827 'optional': ['menu'],
1833 'path': 'calendar/calendar-min.js',
1834 'requires': ['event', 'dom'],
1840 'path': 'carousel/carousel-min.js',
1841 'requires': ['element'],
1842 'optional': ['animation'],
1848 'path': 'charts/charts-min.js',
1849 'requires': ['element', 'json', 'datasource']
1854 'path': 'colorpicker/colorpicker-min.js',
1855 'requires': ['slider', 'element'],
1856 'optional': ['animation'],
1862 'path': 'connection/connection-min.js',
1863 'requires': ['event']
1868 'path': 'container/container-min.js',
1869 'requires': ['dom', 'event'],
1870 // button is also optional, but this creates a circular
1871 // dependency when loadOptional is specified. button
1872 // optionally includes menu, menu requires container.
1873 'optional': ['dragdrop', 'animation', 'connection'],
1874 'supersedes': ['containercore'],
1880 'path': 'container/container_core-min.js',
1881 'requires': ['dom', 'event'],
1887 'path': 'cookie/cookie-min.js',
1888 'requires': ['yahoo']
1893 'path': 'datasource/datasource-min.js',
1894 'requires': ['event'],
1895 'optional': ['connection']
1900 'path': 'datatable/datatable-min.js',
1901 'requires': ['element', 'datasource'],
1902 'optional': ['calendar', 'dragdrop', 'paginator'],
1908 'path': 'dom/dom-min.js',
1909 'requires': ['yahoo']
1914 'path': 'dragdrop/dragdrop-min.js',
1915 'requires': ['dom', 'event']
1920 'path': 'editor/editor-min.js',
1921 'requires': ['menu', 'element', 'button'],
1922 'optional': ['animation', 'dragdrop'],
1923 'supersedes': ['simpleeditor'],
1929 'path': 'element/element-min.js',
1930 'requires': ['dom', 'event']
1935 'path': 'event/event-min.js',
1936 'requires': ['yahoo']
1941 'path': 'fonts/fonts-min.css'
1946 'path': 'get/get-min.js',
1947 'requires': ['yahoo']
1952 'path': 'grids/grids-min.css',
1953 'requires': ['fonts'],
1954 'optional': ['reset']
1959 'path': 'history/history-min.js',
1960 'requires': ['event']
1965 'path': 'imagecropper/imagecropper-min.js',
1966 'requires': ['dom', 'event', 'dragdrop', 'element', 'resize'],
1972 'path': 'imageloader/imageloader-min.js',
1973 'requires': ['event', 'dom']
1978 'path': 'json/json-min.js',
1979 'requires': ['yahoo']
1984 'path': 'layout/layout-min.js',
1985 'requires': ['dom', 'event', 'element'],
1986 'optional': ['animation', 'dragdrop', 'resize', 'selector'],
1992 'path': 'logger/logger-min.js',
1993 'requires': ['event', 'dom'],
1994 'optional': ['dragdrop'],
2000 'path': 'menu/menu-min.js',
2001 'requires': ['containercore'],
2007 'path': 'paginator/paginator-min.js',
2008 'requires': ['element'],
2014 'path': 'profiler/profiler-min.js',
2015 'requires': ['yahoo']
2021 'path': 'profilerviewer/profilerviewer-min.js',
2022 'requires': ['profiler', 'yuiloader', 'element'],
2028 'path': 'reset/reset-min.css'
2031 'reset-fonts-grids': {
2033 'path': 'reset-fonts-grids/reset-fonts-grids.css',
2034 'supersedes': ['reset', 'fonts', 'grids', 'reset-fonts'],
2040 'path': 'reset-fonts/reset-fonts.css',
2041 'supersedes': ['reset', 'fonts'],
2047 'path': 'resize/resize-min.js',
2048 'requires': ['dom', 'event', 'dragdrop', 'element'],
2049 'optional': ['animation'],
2055 'path': 'selector/selector-min.js',
2056 'requires': ['yahoo', 'dom']
2061 'path': 'editor/simpleeditor-min.js',
2062 'requires': ['element'],
2063 'optional': ['containercore', 'menu', 'button', 'animation', 'dragdrop'],
2070 'path': 'slider/slider-min.js',
2071 'requires': ['dragdrop'],
2072 'optional': ['animation'],
2078 'path': 'stylesheet/stylesheet-min.js',
2079 'requires': ['yahoo']
2084 'path': 'tabview/tabview-min.js',
2085 'requires': ['element'],
2086 'optional': ['connection'],
2092 'path': 'treeview/treeview-min.js',
2093 'requires': ['event', 'dom'],
2094 'optional': ['json'],
2100 'path': 'uploader/uploader.js',
2101 'requires': ['element']
2106 'path': 'utilities/utilities.js',
2107 'supersedes': ['yahoo', 'event', 'dragdrop', 'animation', 'dom', 'connection', 'element', 'yahoo-dom-event', 'get', 'yuiloader', 'yuiloader-dom-event'],
2113 'path': 'yahoo/yahoo-min.js'
2116 'yahoo-dom-event': {
2118 'path': 'yahoo-dom-event/yahoo-dom-event.js',
2119 'supersedes': ['yahoo', 'event', 'dom'],
2125 'path': 'yuiloader/yuiloader-min.js',
2126 'supersedes': ['yahoo', 'get']
2129 'yuiloader-dom-event': {
2131 'path': 'yuiloader-dom-event/yuiloader-dom-event.js',
2132 'supersedes': ['yahoo', 'dom', 'event', 'get', 'yuiloader', 'yahoo-dom-event'],
2138 'path': 'yuitest/yuitest-min.js',
2139 'requires': ['logger'],
2147 appendArray: function(o, a) {
2149 for (var i=0; i<a.length; i=i+1) {
2155 keys: function(o, ordered) {
2158 if (lang.hasOwnProperty(o, i)) {
2169 appendArray: function(a1, a2) {
2170 Array.prototype.push.apply(a1, a2);
2172 for (var i=0; i<a2.length; i=i+1) {
2178 indexOf: function(a, val) {
2179 for (var i=0; i<a.length; i=i+1) {
2188 toObject: function(a) {
2190 for (var i=0; i<a.length; i=i+1) {
2198 * Returns a unique array. Does not maintain order, which is fine
2199 * for this application, and performs better than it would if it
2203 return YUI.ObjectUtil.keys(YUI.ArrayUtil.toObject(a));
2208 YAHOO.util.YUILoader = function(o) {
2211 * Internal callback to handle multiple internal insert() calls
2212 * so that css is inserted prior to js
2213 * @property _internalCallback
2216 this._internalCallback = null;
2219 * Use the YAHOO environment listener to detect script load. This
2220 * is only switched on for Safari 2.x and below.
2221 * @property _useYahooListener
2224 this._useYahooListener = false;
2227 * Callback that will be executed when the loader is finished
2232 this.onSuccess = null;
2235 * Callback that will be executed if there is a failure
2239 this.onFailure = Y.log;
2242 * Callback that will be executed each time a new module is loaded
2243 * @method onProgress
2246 this.onProgress = null;
2249 * Callback that will be executed if a timeout occurs
2253 this.onTimeout = null;
2256 * The execution scope for all callbacks
2263 * Data that is passed to all callbacks
2269 * Node reference or id where new nodes should be inserted before
2270 * @property insertBefore
2271 * @type string|HTMLElement
2273 this.insertBefore = null;
2276 * The charset attribute for inserted nodes
2281 this.charset = null;
2284 * The name of the variable in a sandbox or script node
2285 * (for external script support in Safari 2.x and earlier)
2286 * to reference when the load is complete. If this variable
2287 * is not available in the specified scripts, the operation will
2292 this.varName = null;
2295 * The base directory.
2298 * @default http://yui.yahooapis.com/[YUI VERSION]/build/
2300 this.base = YUI.info.base;
2303 * Base path for the combo service
2304 * @property comboBase
2306 * @default http://yui.yahooapis.com/combo?
2308 this.comboBase = YUI.info.comboBase;
2311 * If configured, YUI will use the the combo handler on the
2312 * Yahoo! CDN to pontentially reduce the number of http requests
2318 // this.combine = (o && !('base' in o));
2319 this.combine = false;
2323 * Root path to prepend to module path for the combo
2327 * @default [YUI VERSION]/build/
2329 this.root = YUI.info.root;
2332 * Timeout value in milliseconds. If set, this value will be used by
2333 * the get utility. the timeout event will fire if
2341 * A list of modules that should not be loaded, even if
2342 * they turn up in the dependency tree
2349 * A list of modules that should always be loaded, even
2350 * if they have already been inserted into the page.
2357 * Should we allow rollups
2358 * @property allowRollup
2362 this.allowRollup = true;
2365 * A filter to apply to result urls. This filter will modify the default
2366 * path for all modules. The default path for the YUI library is the
2367 * minified version of the files (e.g., event-min.js). The filter property
2368 * can be a predefined filter or a custom filter. The valid predefined
2372 * <dd>Selects the debug versions of the library (e.g., event-debug.js).
2373 * This option will automatically include the logger widget</dd>
2375 * <dd>Selects the non-minified version of the library (e.g., event.js).
2377 * You can also define a custom filter, which must be an object literal
2378 * containing a search expression and a replace string:
2381 * 'searchExp': "-min\\.js",
2382 * 'replaceStr': "-debug.js"
2386 * @type string|{searchExp: string, replaceStr: string}
2391 * The list of requested modules
2392 * @property required
2393 * @type {string: boolean}
2398 * The library metadata
2399 * @property moduleInfo
2401 this.moduleInfo = lang.merge(YUI.info.moduleInfo);
2404 * List of rollup files found in the library metadata
2407 this.rollups = null;
2410 * Whether or not to load optional dependencies for
2411 * the requested modules
2412 * @property loadOptional
2416 this.loadOptional = false;
2419 * All of the derived dependencies in sorted order, which
2420 * will be populated when either calculate() or insert()
2428 * Set when beginning to compute the dependency tree.
2429 * Composed of what YAHOO reports to be loaded combined
2430 * with what has been loaded by the tool
2432 * @type {string: boolean}
2437 * Flag to indicate the dependency tree needs to be recomputed
2438 * if insert is called again.
2446 * List of modules inserted by the utility
2447 * @property inserted
2448 * @type {string: boolean}
2453 * Provides the information used to skin the skinnable components.
2454 * The following skin definition would result in 'skin1' and 'skin2'
2455 * being loaded for calendar (if calendar was requested), and
2456 * 'sam' for all other skinnable components:
2461 * // The default skin, which is automatically applied if not
2462 * // overriden by a component-specific skin definition.
2463 * // Change this in to apply a different skin globally
2464 * defaultSkin: 'sam',
2466 * // This is combined with the loader base property to get
2467 * // the default root directory for a skin. ex:
2468 * // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/
2469 * base: 'assets/skins/',
2471 * // The name of the rollup css file for the skin
2474 * // The number of skinnable components requested that are
2475 * // required before using the rollup file rather than the
2476 * // individual component css files
2479 * // Any component-specific overrides can be specified here,
2480 * // making it possible to load different skins for different
2481 * // components. It is possible to load more than one skin
2482 * // for a given component as well.
2484 * calendar: ['skin1', 'skin2']
2493 env.listeners.push(function(m) {
2494 if (self._useYahooListener) {
2495 //Y.log("YAHOO listener: " + m.name);
2496 self.loadNext(m.name);
2500 this.skin = lang.merge(YUI.info.skin);
2506 Y.util.YUILoader.prototype = {
2510 'searchExp': "-min\\.js",
2514 'searchExp': "-min\\.js",
2515 'replaceStr': "-debug.js"
2519 SKIN_PREFIX: "skin-",
2521 _config: function(o) {
2523 // apply config values
2526 if (lang.hasOwnProperty(o, i)) {
2527 if (i == "require") {
2537 var f = this.filter;
2539 if (lang.isString(f)) {
2540 f = f.toUpperCase();
2542 // the logger must be available in order to use the debug
2543 // versions of the library
2544 if (f === "DEBUG") {
2545 this.require("logger");
2548 // hack to handle a a bug where LogWriter is being instantiated
2549 // at load time, and the loader has no way to sort above it
2551 if (!Y.widget.LogWriter) {
2552 Y.widget.LogWriter = function() {
2557 this.filter = this.FILTERS[f];
2562 /** Add a new module to the component metadata.
2564 * <dt>name:</dt> <dd>required, the component name</dd>
2565 * <dt>type:</dt> <dd>required, the component type (js or css)</dd>
2566 * <dt>path:</dt> <dd>required, the path to the script from "base"</dd>
2567 * <dt>requires:</dt> <dd>array of modules required by this component</dd>
2568 * <dt>optional:</dt> <dd>array of optional modules for this component</dd>
2569 * <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd>
2570 * <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd>
2571 * <dt>rollup:</dt> <dd>the number of superseded modules required for automatic rollup</dd>
2572 * <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd>
2573 * <dt>skinnable:</dt> <dd>flag to determine if skin assets should automatically be pulled in</dd>
2576 * @param o An object containing the module data
2577 * @return {boolean} true if the module was added, false if
2578 * the object passed in did not provide all required attributes
2580 addModule: function(o) {
2582 if (!o || !o.name || !o.type || (!o.path && !o.fullpath)) {
2586 o.ext = ('ext' in o) ? o.ext : true;
2587 o.requires = o.requires || [];
2589 this.moduleInfo[o.name] = o;
2596 * Add a requirement for one or more module
2598 * @param what {string[] | string*} the modules to load
2600 require: function(what) {
2601 var a = (typeof what === "string") ? arguments : what;
2603 YUI.ObjectUtil.appendArray(this.required, a);
2607 * Adds the skin def to the module info
2609 * @param skin {string} the name of the skin
2610 * @param mod {string} the name of the module
2611 * @return {string} the module name for the skin
2614 _addSkin: function(skin, mod) {
2616 // Add a module definition for the skin rollup css
2617 var name = this.formatSkin(skin), info = this.moduleInfo,
2618 sinf = this.skin, ext = info[mod] && info[mod].ext;
2620 // Y.log('ext? ' + mod + ": " + ext);
2622 // Y.log('adding skin ' + name);
2626 'path': sinf.base + skin + '/' + sinf.path,
2627 //'supersedes': '*',
2628 'after': sinf.after,
2629 'rollup': sinf.rollup,
2634 // Add a module definition for the module-specific skin css
2636 name = this.formatSkin(skin, mod);
2638 var mdef = info[mod], pkg = mdef.pkg || mod;
2639 // Y.log('adding skin ' + name);
2643 'after': sinf.after,
2644 'path': pkg + '/' + sinf.base + skin + '/' + mod + '.css',
2654 * Returns an object containing properties for all modules required
2655 * in order to load the requested module
2656 * @method getRequires
2657 * @param mod The module definition from moduleInfo
2659 getRequires: function(mod) {
2664 if (!this.dirty && mod.expanded) {
2665 return mod.expanded;
2668 mod.requires=mod.requires || [];
2669 var i, d=[], r=mod.requires, o=mod.optional, info=this.moduleInfo, m;
2670 for (i=0; i<r.length; i=i+1) {
2673 YUI.ArrayUtil.appendArray(d, this.getRequires(m));
2675 // add existing skins for skinnable modules as well. The only
2676 // way to do this is go through the list of required items (this
2677 // assumes that _skin is called before getRequires is called on
2679 // if (m.skinnable) {
2680 // var req=this.required, l=req.length;
2681 // for (var j=0; j<l; j=j+1) {
2682 // // YAHOO.log('checking ' + r[j]);
2683 // if (req[j].indexOf(r[j]) > -1) {
2684 // // YAHOO.log('adding ' + r[j]);
2691 if (o && this.loadOptional) {
2692 for (i=0; i<o.length; i=i+1) {
2694 YUI.ArrayUtil.appendArray(d, this.getRequires(info[o[i]]));
2698 mod.expanded = YUI.ArrayUtil.uniq(d);
2700 return mod.expanded;
2705 * Returns an object literal of the modules the supplied module satisfies
2706 * @method getProvides
2707 * @param name{string} The name of the module
2708 * @param notMe {string} don't add this module name, only include superseded modules
2709 * @return what this module provides
2711 getProvides: function(name, notMe) {
2712 var addMe = !(notMe), ckey = (addMe) ? PROV : SUPER,
2713 m = this.moduleInfo[name], o = {};
2720 // Y.log('cached: ' + name + ' ' + ckey + ' ' + lang.dump(this.moduleInfo[name][ckey], 0));
2724 var s = m.supersedes, done={}, me = this;
2726 // use worker to break cycles
2727 var add = function(mm) {
2729 // Y.log(name + ' provides worker trying: ' + mm);
2731 // we always want the return value normal behavior
2732 // (provides) for superseded modules.
2733 lang.augmentObject(o, me.getProvides(mm));
2737 // Y.log(name + ' provides worker skipping done: ' + mm);
2741 // calculate superseded modules
2743 for (var i=0; i<s.length; i=i+1) {
2751 m[PROV] = lang.merge(o);
2752 m[PROV][name] = true;
2754 // Y.log(name + " supersedes " + lang.dump(m[SUPER], 0));
2755 // Y.log(name + " provides " + lang.dump(m[PROV], 0));
2762 * Calculates the dependency tree, the result is stored in the sorted
2765 * @param o optional options object
2767 calculate: function(o) {
2768 if (o || this.dirty) {
2772 // this._skin(); // deprecated
2773 if (this.allowRollup) {
2779 // Y.log("after calculate: " + lang.dump(this.required));
2786 * Investigates the current YUI configuration on the page. By default,
2787 * modules already detected will not be loaded again unless a force
2788 * option is encountered. Called by calculate()
2792 _setup: function() {
2794 var info = this.moduleInfo, name, i, j;
2796 // Create skin modules
2797 for (name in info) {
2799 if (lang.hasOwnProperty(info, name)) {
2801 if (m && m.skinnable) {
2802 // Y.log("skinning: " + name);
2803 var o=this.skin.overrides, smod;
2805 for (i=0; i<o[name].length; i=i+1) {
2806 smod = this._addSkin(o[name][i], name);
2809 smod = this._addSkin(this.skin.defaultSkin, name);
2812 m.requires.push(smod);
2818 var l = lang.merge(this.inserted); // shallow clone
2820 if (!this._sandbox) {
2821 l = lang.merge(l, env.modules);
2824 // Y.log("Already loaded stuff: " + lang.dump(l, 0));
2826 // add the ignore list to the list of loaded packages
2828 YUI.ObjectUtil.appendArray(l, this.ignore);
2831 // remove modules on the force list from the loaded list
2833 for (i=0; i<this.force.length; i=i+1) {
2834 if (this.force[i] in l) {
2835 delete l[this.force[i]];
2840 // expand the list to include superseded modules
2842 // Y.log("expanding: " + j);
2843 if (lang.hasOwnProperty(l, j)) {
2844 lang.augmentObject(l, this.getProvides(j));
2848 // Y.log("loaded expanded: " + lang.dump(l, 0));
2856 * Inspects the required modules list looking for additional
2857 * dependencies. Expands the required list to include all
2858 * required modules. Called by calculate()
2862 _explode: function() {
2864 var r=this.required, i, mod;
2867 if (lang.hasOwnProperty(r, i)) {
2868 mod = this.moduleInfo[i];
2871 var req = this.getRequires(mod);
2874 YUI.ObjectUtil.appendArray(r, req);
2882 * Sets up the requirements for the skin assets if any of the
2883 * requested modules are skinnable
2886 * @deprecated skin modules are generated for all skinnable
2887 * components during _setup(), and the components
2888 * are configured to require the skin.
2895 * Returns the skin module name for the specified skin name. If a
2896 * module name is supplied, the returned skin module name is
2897 * specific to the module passed in.
2898 * @method formatSkin
2899 * @param skin {string} the name of the skin
2900 * @param mod {string} optional: the name of a module to skin
2901 * @return {string} the full skin module name
2903 formatSkin: function(skin, mod) {
2904 var s = this.SKIN_PREFIX + skin;
2913 * Reverses <code>formatSkin</code>, providing the skin name and
2914 * module name if the string matches the pattern for skins.
2916 * @param mod {string} the module name to parse
2917 * @return {skin: string, module: string} the parsed skin name
2918 * and module name, or null if the supplied string does not match
2921 parseSkin: function(mod) {
2923 if (mod.indexOf(this.SKIN_PREFIX) === 0) {
2924 var a = mod.split("-");
2925 return {skin: a[1], module: a[2]};
2932 * Look for rollup packages to determine if all of the modules a
2933 * rollup supersedes are required. If so, include the rollup to
2934 * help reduce the total number of connections required. Called
2939 _rollup: function() {
2940 var i, j, m, s, rollups={}, r=this.required, roll,
2941 info = this.moduleInfo;
2943 // find and cache rollup modules
2944 if (this.dirty || !this.rollups) {
2946 if (lang.hasOwnProperty(info, i)) {
2948 //if (m && m.rollup && m.supersedes) {
2949 if (m && m.rollup) {
2955 this.rollups = rollups;
2958 // make as many passes as needed to pick up rollup rollups
2962 // go through the rollup candidates
2963 for (i in rollups) {
2965 // there can be only one
2966 if (!r[i] && !this.loaded[i]) {
2967 m =info[i]; s = m.supersedes; roll=false;
2973 var skin = (m.ext) ? false : this.parseSkin(i), c = 0;
2975 // Y.log('skin? ' + i + ": " + skin);
2978 if (lang.hasOwnProperty(r, j)) {
2979 if (i !== j && this.parseSkin(j)) {
2981 roll = (c >= m.rollup);
2983 // Y.log("skin rollup " + lang.dump(r));
2992 // check the threshold
2993 for (j=0;j<s.length;j=j+1) {
2995 // if the superseded module is loaded, we can't load the rollup
2996 if (this.loaded[s[j]] && (!YUI.dupsAllowed[s[j]])) {
2999 // increment the counter if this module is required. if we are
3000 // beyond the rollup threshold, we will use the rollup module
3001 } else if (r[s[j]]) {
3003 roll = (c >= m.rollup);
3005 // Y.log("over thresh " + c + ", " + lang.dump(r));
3013 // Y.log("rollup: " + i + ", " + lang.dump(this, 1));
3018 // expand the rollup's dependencies
3019 this.getRequires(m);
3024 // if we made it here w/o rolling up something, we are done
3032 * Remove superceded modules and loaded modules. Called by
3033 * calculate() after we have the mega list of all dependencies
3037 _reduce: function() {
3039 var i, j, s, m, r=this.required;
3042 // remove if already loaded
3043 if (i in this.loaded) {
3046 // remove anything this module supersedes
3049 var skinDef = this.parseSkin(i);
3052 //YAHOO.log("skin found in reduce: " + skinDef.skin + ", " + skinDef.module);
3053 // the skin rollup will not have a module name
3054 if (!skinDef.module) {
3055 var skin_pre = this.SKIN_PREFIX + skinDef.skin;
3056 //YAHOO.log("skin_pre: " + skin_pre);
3059 if (lang.hasOwnProperty(r, j)) {
3060 m = this.moduleInfo[j];
3061 var ext = m && m.ext;
3062 if (!ext && j !== i && j.indexOf(skin_pre) > -1) {
3063 // Y.log ("removing component skin: " + j);
3071 m = this.moduleInfo[i];
3072 s = m && m.supersedes;
3074 for (j=0; j<s.length; j=j+1) {
3085 _onFailure: function(msg) {
3086 YAHOO.log('Failure', 'info', 'loader');
3088 var f = this.onFailure;
3090 f.call(this.scope, {
3091 msg: 'failure: ' + msg,
3098 _onTimeout: function() {
3099 YAHOO.log('Timeout', 'info', 'loader');
3100 var f = this.onTimeout;
3102 f.call(this.scope, {
3111 * Sorts the dependency tree. The last step of calculate()
3116 // create an indexed list
3117 var s=[], info=this.moduleInfo, loaded=this.loaded,
3118 checkOptional=!this.loadOptional, me = this;
3120 // returns true if b is not loaded, and is required
3121 // directly or by means of modules it supersedes.
3122 var requires = function(aa, bb) {
3126 if (loaded[bb] || !mm) {
3134 optional = mm.optional;
3137 // check if this module requires the other directly
3138 if (rr && YUI.ArrayUtil.indexOf(rr, bb) > -1) {
3142 // check if this module should be sorted after the other
3143 if (after && YUI.ArrayUtil.indexOf(after, bb) > -1) {
3147 // if loadOptional is not specified, optional dependencies still
3148 // must be sorted correctly when present.
3149 if (checkOptional && optional && YUI.ArrayUtil.indexOf(optional, bb) > -1) {
3153 // check if this module requires one the other supersedes
3154 var ss=info[bb] && info[bb].supersedes;
3156 for (ii=0; ii<ss.length; ii=ii+1) {
3157 if (requires(aa, ss[ii])) {
3163 // var ss=me.getProvides(bb, true);
3166 // if (requires(aa, ii)) {
3172 // external css files should be sorted below yui css
3173 if (mm.ext && mm.type == 'css' && !other.ext && other.type == 'css') {
3180 // get the required items out of the obj into an array so we
3182 for (var i in this.required) {
3183 if (lang.hasOwnProperty(this.required, i)) {
3188 // pointer to the first unsorted item
3191 // keep going until we make a pass without moving anything
3194 var l=s.length, a, b, j, k, moved=false;
3196 // start the loop after items that are already sorted
3197 for (j=p; j<l; j=j+1) {
3199 // check the next module on the list to see if its
3200 // dependencies have been met
3203 // check everything below current item and move if we
3204 // find a requirement for the current item
3205 for (k=j+1; k<l; k=k+1) {
3206 if (requires(a, s[k])) {
3208 // extract the dependency so we can move it up
3211 // insert the dependency above the item that
3213 s.splice(j, 0, b[0]);
3220 // jump out of loop if we moved something
3223 // this item is sorted, move our pointer and keep going
3229 // when we make it here and moved is false, we are
3240 toString: function() {
3244 filter: this.filter,
3245 required: this.required,
3246 loaded: this.loaded,
3247 inserted: this.inserted
3253 _combine: function() {
3255 this._combining = [];
3260 js = this.comboBase,
3261 css = this.comboBase,
3263 startLen = js.length,
3264 i, m, type = this.loadType;
3266 YAHOO.log('type ' + type);
3268 for (i=0; i<len; i=i+1) {
3270 m = this.moduleInfo[s[i]];
3272 if (m && !m.ext && (!type || type === m.type)) {
3274 target = this.root + m.path;
3280 if (m.type == 'js') {
3286 // YAHOO.log(target);
3287 this._combining.push(s[i]);
3291 if (this._combining.length) {
3293 YAHOO.log('Attempting to combine: ' + this._combining, "info", "loader");
3295 var callback=function(o) {
3296 // YAHOO.log('Combo complete: ' + o.data, "info", "loader");
3297 // this._combineComplete = true;
3299 var c=this._combining, len=c.length, i, m;
3300 for (i=0; i<len; i=i+1) {
3301 this.inserted[c[i]] = true;
3304 this.loadNext(o.data);
3307 loadScript = function() {
3308 // YAHOO.log('combining js: ' + js);
3309 if (js.length > startLen) {
3310 YAHOO.util.Get.script(self._filter(js), {
3311 data: self._loading,
3312 onSuccess: callback,
3313 onFailure: self._onFailure,
3314 onTimeout: self._onTimeout,
3315 insertBefore: self.insertBefore,
3316 charset: self.charset,
3317 timeout: self.timeout,
3323 // load the css first
3324 // YAHOO.log('combining css: ' + css);
3325 if (css.length > startLen) {
3326 YAHOO.util.Get.css(this._filter(css), {
3327 data: this._loading,
3328 onSuccess: loadScript,
3329 onFailure: this._onFailure,
3330 onTimeout: this._onTimeout,
3331 insertBefore: this.insertBefore,
3332 charset: this.charset,
3333 timeout: this.timeout,
3343 // this._combineComplete = true;
3344 this.loadNext(this._loading);
3349 * inserts the requested modules and their dependencies.
3350 * <code>type</code> can be "js" or "css". Both script and
3351 * css are inserted if type is not provided.
3353 * @param o optional options object
3354 * @param type {string} the type of dependency to insert
3356 insert: function(o, type) {
3358 // Y.log("insert: " + lang.dump(o, 1) + ", " + type);
3360 // Y.log("insert: " + this.toString() + ", " + type);
3363 // build the dependency list
3367 // set a flag to indicate the load has started
3368 this._loading = true;
3370 // flag to indicate we are done with the combo service
3371 // and any additional files will need to be loaded
3373 // this._combineComplete = false;
3375 // keep the loadType (js, css or undefined) cached
3376 this.loadType = type;
3379 return this._combine();
3383 // Y.log("trying to load css first");
3385 this._internalCallback = function() {
3386 self._internalCallback = null;
3387 self.insert(null, "js");
3389 this.insert(null, "css");
3400 * Interns the script for the requested modules. The callback is
3401 * provided a reference to the sandboxed YAHOO object. This only
3402 * applies to the script: css can not be sandboxed; css will be
3403 * loaded into the page normally if specified.
3405 * @param callback {Function} the callback to exectued when the load is
3408 sandbox: function(o, type) {
3410 // YAHOO.log("sandbox: " + lang.dump(o, 1) + ", " + type);
3412 // YAHOO.log("sandbox: " + this.toString() + ", " + type);
3417 if (!this.onSuccess) {
3418 throw new Error("You must supply an onSuccess handler for your sandbox");
3421 this._sandbox = true;
3425 // take care of any css first (this can't be sandboxed)
3426 if (!type || type !== "js") {
3427 this._internalCallback = function() {
3428 self._internalCallback = null;
3429 self.sandbox(null, "js");
3431 this.insert(null, "css");
3435 // get the connection manager if not on the page
3436 if (!util.Connect) {
3437 // get a new loader instance to load connection.
3438 var ld = new YAHOO.util.YUILoader();
3441 filter: this.filter,
3442 require: "connection",
3443 insertBefore: this.insertBefore,
3444 charset: this.charset,
3445 onSuccess: function() {
3446 this.sandbox(null, "js");
3453 this._scriptText = [];
3454 this._loadCount = 0;
3455 this._stopCount = this.sorted.length;
3460 var s=this.sorted, l=s.length, i, m, url;
3462 for (i=0; i<l; i=i+1) {
3463 m = this.moduleInfo[s[i]];
3465 // undefined modules cause a failure
3467 this._onFailure("undefined module " + m);
3468 for (var j=0;j<this._xhr.length;j=j+1) {
3469 this._xhr[j].abort();
3474 // css files should be done
3475 if (m.type !== "js") {
3481 url = (url) ? this._filter(url) : this._url(m.path);
3483 // YAHOO.log("xhr request: " + url + ", " + i);
3487 success: function(o) {
3489 var idx=o.argument[0], name=o.argument[2];
3491 // store the response in the position it was requested
3492 this._scriptText[idx] = o.responseText;
3494 // YAHOO.log("received: " + o.responseText.substr(0, 100) + ", " + idx);
3496 if (this.onProgress) {
3497 this.onProgress.call(this.scope, {
3499 scriptText: o.responseText,
3505 // only generate the sandbox once everything is loaded
3508 if (this._loadCount >= this._stopCount) {
3510 // the variable to find
3511 var v = this.varName || "YAHOO";
3513 // wrap the contents of the requested modules in an anonymous function
3514 var t = "(function() {\n";
3516 // return the locally scoped reference.
3517 var b = "\nreturn " + v + ";\n})();";
3519 var ref = eval(t + this._scriptText.join("\n") + b);
3521 this._pushEvents(ref);
3524 this.onSuccess.call(this.scope, {
3529 this._onFailure.call(this.varName + " reference failure");
3534 failure: function(o) {
3535 this.onFailure.call(this.scope, {
3544 // module index, module name, sandbox name
3545 argument: [i, url, s[i]]
3549 this._xhr.push(util.Connect.asyncRequest('GET', url, xhrData));
3554 * Executed every time a module is loaded, and if we are in a load
3555 * cycle, we attempt to load the next script. Public so that it
3556 * is possible to call this if using a method other than
3557 * YAHOO.register to determine when scripts are fully loaded
3559 * @param mname {string} optional the name of the module that has
3560 * been loaded (which is usually why it is time to load the next
3563 loadNext: function(mname) {
3565 // It is possible that this function is executed due to something
3566 // else one the page loading a YUI module. Only react when we
3567 // are actively loading something
3568 if (!this._loading) {
3575 // if the module that was just loaded isn't what we were expecting,
3577 if (mname !== this._loading) {
3581 // YAHOO.log("loadNext executing, just loaded " + mname);
3583 // The global handler that is called when each module is loaded
3584 // will pass that module name to this function. Storing this
3585 // data to avoid loading the same module multiple times
3586 this.inserted[mname] = true;
3588 if (this.onProgress) {
3589 this.onProgress.call(this.scope, {
3594 //var o = this.getProvides(mname);
3595 //this.inserted = lang.merge(this.inserted, o);
3598 var s=this.sorted, len=s.length, i, m;
3600 for (i=0; i<len; i=i+1) {
3602 // This.inserted keeps track of what the loader has loaded
3603 if (s[i] in this.inserted) {
3604 // YAHOO.log(s[i] + " alread loaded ");
3608 // Because rollups will cause multiple load notifications
3609 // from YAHOO, loadNext may be called multiple times for
3610 // the same module when loading a rollup. We can safely
3611 // skip the subsequent requests
3612 if (s[i] === this._loading) {
3613 // YAHOO.log("still loading " + s[i] + ", waiting");
3617 // log("inserting " + s[i]);
3618 m = this.moduleInfo[s[i]];
3621 this.onFailure.call(this.scope, {
3622 msg: "undefined module " + m,
3628 // The load type is stored to offer the possibility to load
3629 // the css separately from the script.
3630 if (!this.loadType || this.loadType === m.type) {
3631 this._loading = s[i];
3632 //YAHOO.log("attempting to load " + s[i] + ", " + this.base);
3634 var fn=(m.type === "css") ? util.Get.css : util.Get.script,
3638 self.loadNext(o.data);
3641 url = (url) ? this._filter(url) : this._url(m.path);
3643 // safari 2.x or lower, script, and part of YUI
3644 if (env.ua.webkit && env.ua.webkit < 420 && m.type === "js" &&
3646 //YUI.info.moduleInfo[s[i]]) {
3647 //YAHOO.log("using YAHOO env " + s[i] + ", " + m.varName);
3649 this._useYahooListener = true;
3655 onFailure: this._onFailure,
3656 onTimeout: this._onTimeout,
3657 insertBefore: this.insertBefore,
3658 charset: this.charset,
3659 timeout: this.timeout,
3669 this._loading = null;
3671 // internal callback for loading css first
3672 if (this._internalCallback) {
3673 var f = this._internalCallback;
3674 this._internalCallback = null;
3676 } else if (this.onSuccess) {
3678 this.onSuccess.call(this.scope, {
3686 * In IE, the onAvailable/onDOMReady events need help when Event is
3687 * loaded dynamically
3688 * @method _pushEvents
3689 * @param {Function} optional function reference
3692 _pushEvents: function(ref) {
3693 var r = ref || YAHOO;
3694 if (r.util && r.util.Event) {
3695 r.util.Event._load();
3702 * @return {string} the filtered string
3705 _filter: function(str) {
3706 var f = this.filter;
3707 return (f) ? str.replace(new RegExp(f.searchExp, 'g'), f.replaceStr) : str;
3711 * Generates the full url for a module
3713 * @param path {string} the path fragment
3714 * @return {string} the full url
3717 _url: function(path) {
3718 return this._filter((this.base || "") + path);
3724 YAHOO.register("yuiloader", YAHOO.util.YUILoader, {version: "2.7.0", build: "1799"});