yui-debug.js revision 9c42541e375e7bb70c53012b3012d70f1a380254
4194N/A// @TODO: this needs to be created at build time from module metadata 197N/A// reduce to one or the other 187N/A * The YUI global namespace object. If YUI is already defined, the 187N/A * existing YUI object will not be overwritten so that defined 187N/A * namespaces are preserved. 192N/A * @param o Optional configuration object. Options: 145N/A * <li>------------------------------------------------------------------------</li> 187N/A * <li>------------------------------------------------------------------------</li> 3294N/A * <li>debug: Turn debug statements on or off</li> 187N/A * Log to the browser console if debug is on and the console is available</li> 1899N/A * A hash of log sources that should be logged. If specified, only log messages from these sources will be logged. 187N/A * A hash of log sources that should be not be logged. If specified, all sources are logged if not on this list.</li> 2520N/A * <li>injected: set to true if the yui seed file was dynamically loaded in 187N/A * order to bootstrap components relying on the window load event and onDOMReady.</li> 187N/A * If throwFail is set, Y.fail will generate or re-throw a JS error. Otherwise the failure is logged. 1899N/A * A list of modules that defines the YUI core (overrides the default)</li> 1899N/A * <li>dateFormat: default date format</li> 187N/A * <li>locale: default locale</li> 187N/A * <li>------------------------------------------------------------------------</li> 187N/A * <li>For event and get:</li> 145N/A * <li>------------------------------------------------------------------------</li> 197N/A * <li>pollInterval: The default poll interval</li> 197N/A * <li>windowResizeDelay: The time between browser events to wait before firing.</li> 197N/A * <li>-------------------------------------------------------------------------</li> 197N/A * <li>-------------------------------------------------------------------------</li> * <li>base: The base dir</li> * <li>secureBase: The secure base dir (not implemented)</li> * <li>root: The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li> * A filter to apply to result urls. This filter will modify the default * path for all modules. The default path for the YUI library is the * minified version of the files (e.g., event-min.js). The filter property * can be a predefined filter or a custom filter. The valid predefined * <dd>Selects the debug versions of the library (e.g., event-debug.js). * This option will automatically include the Logger widget</dd> * <dd>Selects the non-minified version of the library (e.g., event.js).</dd> * You can also define a custom filter, which must be an object literal * containing a search expression and a replace string: * 'searchExp': "-min\\.js", * <li>filters: per-component filter specification. If specified for a given component, this overrides the filter config</li> * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li> * A list of modules that should never be dynamically loaded</li> * A list of modules that should always be loaded when required, even if already present on the page</li> * Node or id for a node that should be used as the insertion point for new nodes</li> * charset for dynamic nodes</li> * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li> * execution context for all callbacks</li> * callback for the 'success' event</li> * callback for the 'failure' event</li> * callback for the 'timeout' event</li> * callback executed each time a script or css file is loaded</li> * A list of module definitions. See Loader.addModule for the supported module metadata</li> // Make a function, disallow direct instantiation // Allow instantiation without the new operator if (!(Y
instanceof YUI)) {
// set up the core environment // bind the specified additional modules for this instance // The prototype contains the functions that are required to allow the external // modules to be registered and for the instance to be initialized. * Initialize this YUI instance * @param o config options // @TODO resolve windowless environments v =
'@VERSION@', Y =
this;
// add a reference to o for anything that needs it // before _setup is called. // @todo expand the new module metadata // this.log(this.id + ') init '); * Finishes the instance setup. Attaches whatever modules were defined * when the yui modules was registered. // @TODO eval the need to copy the config * Executes a method on a YUI instance with * the specified id if the specified method is whitelisted. * @param id {string} the YUI instance id * @param method {string} the name of the method to exectute. * @param args {Array} the arguments to apply to the method * @return {object} the return value from the applied method or null * @param name {string} module name * @param fn {Function} entry point into the module that * is used to bind module to the YUI instance * @param version {string} version string * @param details optional config data: * requires - features that should be present before loading * optional - optional features that should be present if load optional defined * use - features that should be attached automatically * omit - features that should not be loaded if this module is present * @return {YUI} the YUI instance // this.log('Adding a new component ' + name); // @todo expand this to include version mapping // @todo may want to restore the build property // @todo fire moduleAvailable event return this;
// chain support // this.log('attaching ' + name, 'info', 'yui'); * Bind a module to a YUI instance * @param modules* {string} 1-n modules to bind (uses arguments array) * @param *callback {function} callback function executed when * the instance has the required functionality. If included, it * must be the last parameter. * Implement versioning? loader can load different versions? * we add syntax for specifying these? * YUI().use('dragdrop:2.4.0'); // specific version * YUI().use('dragdrop:2.4.0-'); // at least this version * YUI().use('dragdrop:2.4.0-2.9999.9999'); // version range * YUI().use('*'); // use all available modules * YUI().use('lang+dump+substitute'); // use lang and some plugins * YUI().use('lang+*'); // use lang and all known plugins * @return {YUI} the YUI instance // only attach a module once // Y.log(name + ' already used', 'info', 'yui'); // Y.log('USING ' + name, 'info', 'yui'); // CSS files don't register themselves, see if it has been loaded // While sorting out the packaged metadata in the modules, // let's look at the loader metadata as well // loaderMods = Y.Env.meta.modules; // m = loaderMods && loaderMods[name]; // if (m && m.parent && used[m.parent]) { // Y.log('USING FROM LOADER METADATA' + name, 'info', 'yui'); // Y.log('module not found: ' + name, 'info', 'yui'); Y.
log(
'module not found: ' +
name,
'info',
'yui');
// Y.log('module not found BUT HAS BEEN LOADED: ' + name, 'info', 'yui'); // make sure requirements are attached // Y.log('using module\'s requirements: ' + name, 'info', 'yui'); // add this module to full list of things to attach // Y.log('adding to requires list: ' + name); // Y.log('Use complete'); // process queued use requests as long until done // or dynamic load happens again. // Y.log(Y.id + ': use called: ' + a + ' :: ' + callback); // The last argument supplied to use can be a load complete callback // YUI().use('*'); // bind everything available // Y.log('loader before: ' + a.join(',')); // use loader to expand dependencies and sort the // requirements if it is available. // Y.log('loader after: ' + a.join(',')); // process each requirement and any additional requirements // the module metadata specifies // Y.log('all reqs: ' + r + ' --- missing: ' + missing + ', l: ' + l + ', ' + r[0]); Y.
log(
'Attempting to dynamically load the missing modules ' +
missing,
'info',
'yui');
return Y;
// chain support var yui = YUI().use('dragdrop'); * Returns the namespace specified and creates it if it doesn't exist * YUI.namespace("property.package"); * YUI.namespace("YAHOO.property.package"); * Either of the above would create YUI.property, then * YUI.property.package (YAHOO is scrubbed out, this is * to remain compatible with YUI2) * Be careful when naming packages. Reserved words may work in some browsers * and not others. For instance, the following will fail in Safari: * YUI.namespace("really.long.nested.namespace"); * This fails because "long" is a future reserved word in ECMAScript * @param {string*} arguments 1-n namespaces to create * @return {object} A reference to the last namespace object created for (i=
0; i<a.
length; i=i+
1) {
d = (
"" + a[i]).
split(
".");
for (j=(d[
0] ==
"YAHOO") ?
1 :
0; j<d.
length; j=j+
1) {
// this is replaced if the log module is included * Report an error. The reporting mechanism is controled by * the 'throwFail' configuration attribute. If throwFail is * not specified, the message is written to the Logger, otherwise * @param msg {string} the error message * @param e {Error} Optional JS error that was caught. If supplied * and throwFail is specified, this error will be re-thrown. * @return {YUI} this YUI instance this.
message(
msg,
"error");
// don't scrub this one * Generate an id that is unique among all YUI instances * @param pre {string} optional guid prefix * @return {string} the guid * Returns a guid associated with an object. If the object * does not have one, a new one is created unless readOnly * @param o The object to stamp * @param readOnly {boolean} if true, a valid guid will only * be returned if the object has one assigned to it. * @return {string} The object's guid or null var uid = (
typeof o ===
'string') ? o : o.
_yuid;
// Give the YUI global the same properties as an instance. // This makes it so that the YUI global can be used like the YAHOO // global was used prior to 3.x. More importantly, the YUI global // provides global metadata, so env needs to be configured. // inheritance utilities are not available yet // set up the environment // add a window load event at load time so we can capture // the case where it fires before dynamic loading is YUI.
add(
'yui-base',
function(Y) {
* If the 'debug' config is true, a 'yui:log' event will be * dispatched, which the Console widget and anything else * can consume. If the 'useBrowserConsole' config is true, it will * write to the browser console if available. YUI-specific log * messages will only be present in the -debug versions of the * JS files. The build system is supposed to remove log statements * from the raw and minified versions of the files. * @param {String} msg The message to log. * @param {String} cat The log category for the message. Default * categories are "info", "warn", "error", time". * Custom categories can be used as well. (opt) * @param {String} src The source of the the message (opt) * @param {boolean} silent If true, the log event won't fire * @return {YUI} YUI instance // suppress log message if the config is off or the event stack // or the event call stack contains a consumer of the yui:log event // console.log('checking src filter: ' + src + ', inc: ' + inc + ', exc: ' + exc); // console.log('bail: inc list found, but src is not in list: ' + src); // console.log('bail: exc list found, and src is in it: ' + src); if (
typeof console !=
'undefined') {
}
else if (
typeof opera !=
'undefined') {
* Write a system message. This message will be preserved in the * minified and raw versions of the YUI files, unlike log statements. * @param {String} msg The message to log. * @param {String} cat The log category for the message. Default * categories are "info", "warn", "error", time". * Custom categories can be used as well. (opt) * @param {String} src The source of the the message (opt) * @param {boolean} silent If true, the log event won't fire * @return {YUI} YUI instance * @TODO I'm not convinced the current log statement scrubbing routine can * be made safe with all the variations that could be supplied for * Logs a message with Y.log() if the first parameter is true * Y.logIf((life == 'good'), 'yay'); * logIf statements are stripped from the raw and min files. * @param {boolean} condition Logging only occurs if a truthy value is provided * @param {String} msg The message to log. * @param {String} cat The log category for the message. Default * categories are "info", "warn", "error", time". * Custom categories can be used as well. (opt) * @param {String} src The source of the the message (opt) * @param {boolean} silent If true, the log event won't fire * @return {YUI} YUI instance // instance.logIf = function(condition, msg, cat, src, silent) { // return Y.log.apply(Y, arguments); * Provides the language utilites and extensions used by the library '[object RegExp]' :
REGEX,
'[object Array]' :
ARRAY,
* Determines whether or not the provided item is an array. * Returns false for array-like collections such as the * function arguments collection or HTMLElement collection * will return false. You can use @see Array.test if you * @param o The object to test * @return {boolean} true if o is an array * Determines whether or not the provided item is a boolean * @param o The object to test * @return {boolean} true if o is a boolean * Determines whether or not the provided item is a function * Note: Internet Explorer thinks certain functions are objects: * var obj = document.createElement("object"); * Y.Lang.isFunction(obj.getAttribute) // reports false in IE * var input = document.createElement("input"); // append to body * Y.Lang.isFunction(input.focus) // reports false in IE * You will have to implement additional tests if these functions * @param o The object to test * @return {boolean} true if o is a function * Determines whether or not the supplied item is a date instance * @param o The object to test * @return {boolean} true if o is a date // return o instanceof Date; * Determines whether or not the provided item is null * @param o The object to test * @return {boolean} true if o is null * Determines whether or not the provided item is a legal number * @param o The object to test * @return {boolean} true if o is a number * Determines whether or not the provided item is of type object * @param o The object to test * @param failfn {boolean} fail if the input is a function * @return {boolean} true if o is an object * Determines whether or not the provided item is a string * @param o The object to test * @return {boolean} true if o is a string * Determines whether or not the provided item is undefined * @param o The object to test * @return {boolean} true if o is undefined * Returns a string without any leading or trailing whitespace. If * the input is not a string, the input will be returned untouched. * @param s {string} the string to trim * @return {string} the trimmed string * A convenience method for detecting a legitimate non-null value. * @param o The item to test * Returns a string representing the type of the item passed in. * @param o the item to test * @return {string} the detected type * Adds the following array utilities to the YUI instance * Y.Array(o) returns an array: * - Arrays are return unmodified unless the start position is specified. * - "Array-like" collections (@see Array.test) are converted to arrays * - For everything else, a new array is created with the input as the sole item * - The start position is used if the input is or is like an array to return * a subset of the collection. * @TODO this will not automatically convert elements that are also collections * such as forms and selects. Passing true as the third param will * @param o the item to arrayify * @param i {int} if an array or array-like, this is the start index * @param al {boolean} if true, it forces the array-like fork. This * can be used to avoid multiple array.test calls. * @return {Array} the resulting array var t = (
al) ?
2 : Y.
Array.
test(o), i, l, a;
// // return (startIdx) ? o.slice(startIdx) : o; // return Native.slice.call(o, startIdx || 0); // IE errors when trying to slice element collections for (i=
0, l=o.
length; i<l; i=i+
1) {
* Evaluates the input to determine if it is an array, array-like, or * something else. This is used to handle the arguments collection * available within functions, and HTMLElement collections * @todo current implementation (intenionally) will not implicitly * handle html elements that are array-like (forms, selects, etc). * @return {int} a number indicating the results: * 0: Not an array or an array-like collection * 2: array-like collection. // indexed, but no tagName (element) or alert (window) if (
"length" in o && !(
"tagName" in o) && !(
"alert" in o) &&
* Executes the supplied function on each item in the array. * @param a {Array} the array to iterate * @param f {Function} the function to execute on each item * @param o Optional context object * @return {YUI} the YUI instance var l = (a && a.
length) ||
0, i;
for (i =
0; i < l; i=i+
1) {
f.
call(o || Y, a[i], i, a);
* Returns an object using the first array as keys, and * the second as values. If the second array is not * provided the value is set to true for each. * @param k {Array} keyset * @param v {Array} optional valueset * @return {object} the hash A.
hash =
function(k, v) {
o[k[i]] = (
vl &&
vl > i) ? v[i] :
true;
* Returns the index of the first item in the array * that contains the specified value, -1 if the * @param a {Array} the array to search * @param val the value to search for * @return {int} the index of the item that contains the value or -1 for (
var i=
0; i<a.
length; i=i+
1) {
* Numeric sort convenience function. * Y.ArrayAssert.itemsAreEqual([1, 2, 3], [3, 1, 2].sort(Y.Array.numericSort)); * Executes the supplied function on each item in the array. * Returning true from the processing function will stop the * processing of the remaining * @param a {Array} the array to iterate * @param f {Function} the function to execute on each item * @param o Optional context object * @return {boolean} true if the function returns true on * any of the items in the array if (f.
call(o, a[i], i, a)) {
IEF = [
"toString",
"valueOf"],
* IE will not enumerate native functions in a derived object even if the * function was overridden. This is a workaround for specific functions * we care about on the Object prototype. * @param {Function} r the object to receive the augmentation * @param {Function} s the object that supplies the properties to augment * @param w a whitelist object (the keys are the valid items to reference) for (i=
0; i<a.
length; i=i+
1) {
* Returns a new object containing all of the properties of * all the supplied objects. The properties from later objects * will overwrite those in earlier objects. Passing in a * single object will create a shallow copy of it. For a deep * @param arguments {Object*} the objects to merge * @return {object} the new merged object * Applies the supplier's properties to the receiver. By default * all prototype and static propertes on the supplier are applied * to the corresponding spot on the receiver. By default all * properties are applied, and a property that is already on the * reciever will not be overwritten. The default behavior can * be modified by supplying the appropriate parameters. * @TODO add constants for the modes * @param {Function} r the object to receive the augmentation * @param {Function} s the object that supplies the properties to augment * @param ov {boolean} if true, properties already on the receiver * will be overwritten if found on the supplier. * @param wl {string[]} a whitelist. If supplied, only properties in * this list will be applied to the receiver. * @param {int} mode what should be copies, and to where * default(0): object to object * 1: prototype to prototype (old augment) * 2: prototype to prototype and object props (new augment) * @return {object} the augmented object // We never want to overwrite the prototype if (
PROTO === i ||
'_yuid' === i) {
// Y.log('i: ' + i + ", " + fs[i]); // @TODO deal with the hasownprop issue // check white list if it was supplied if (!w ||
iwl || (i
in w)) {
// if the receiver has this property, it is an object, // and merge is specified, merge the two objects. // console.log('aggregate RECURSE: ' + i); // @TODO recursive or no? // Y.mix(fr[i], fs[i]); // not recursive // otherwise apply the property only if overwrite // is specified or the receiver doesn't have one. // @TODO make sure the 'arr' check isn't desructive }
else if (!
arr && (
ov || !(i
in fr))) {
// console.log('hash: ' + i); // if merge is specified and the receiver is an array, // console.log('array: ' + i); // @TODO probably will need to remove dups case 1:
// proto to proto case 2:
// object to object and proto to proto case 3:
// proto to static case 4:
// static to proto default:
// object to object * Returns a wrapper for a function which caches the * return value of that function, keyed off of the combined * @param source {function} the function to memoize * @param cache an optional cache seed * @return {Function} the wrapped function * Adds the following Object utilities to the YUI instance * Y.Object(o) returns a new object based upon the supplied object. * @TODO Use native Object.create() when available * @param o the supplier object * @return {object} the new object * Extracts the keys, values, or size from an object * @param what what to extract (0: keys, 1: values, 2: size) * @return {boolean|Array} the extracted info * Returns an array containing the object's keys * @TODO use native Object.keys() if available * @return {string[]} the keys * Returns an array containing the object's values * @TODO use native Object.values() if available * @return {Array} the values * Returns the size of an object * @TODO use native Object.size() if available * Returns true if the object contains a given key * @param k the key to query * @return {boolean} true if the object contains the key // return (o.hasOwnProperty(k)); * Returns true if the object contains a given value * @method Object.hasValue * @param v the value to query * @return {boolean} true if the object contains the value * Determines whether or not the property was added * to the object instance. Returns false if the property is not present * in the object, or was inherited from the prototype. * @deprecated Safari 1.x support has been removed, so this is simply a * wrapper for the native implementation. Use the native implementation * @param o {any} The object being testing * @param p {string} the property to look for * @return {boolean} true if the object has the property on the instance O.
owns =
function(o, k) {
* Executes a function on each item. The function * receives the value, the key, and the object * as paramters (in that order). * @param o the object to iterate * @param f {function} the function to execute * @param c the execution context * @param proto {boolean} include proto * @return {YUI} the YUI instance * Retrieves the sub value at the provided path, * from the value object provided. * @param o The object from which to extract the property value * @param path {Array} A path array, specifying the object traversal path * from which to obtain the sub value. * @return {Any} The value stored in the path, undefined if not found. * Returns the source object if an empty path is provided. * Sets the sub-attribute value at the provided path on the * value object. Returns the modified value object, or * undefined if the path is invalid. * @param o The object on which to set the sub value. * @param path {Array} A path array, specifying the object traversal path * at which to set the sub value. * @param val {Any} The new value for the sub-attribute. * @return {Object} The modified object, with the new sub value set, or * undefined, if the path was invalid. * YUI user agent detection. * Do not fork for a browser if it can be avoided. Use feature detection when * you can. Use the user agent as a last resort. UA stores a version * number for the browser engine, 0 otherwise. This value may or may not map * to the version number of the browser using the engine. The value is * presented as a float so that it can easily be used for boolean evaluation * as well as for looking for a particular range of versions. Because of this, * some of the granularity of the version info may be lost (e.g., Gecko 1.8.0.9 * Internet Explorer version number or 0. Example: 6 * Opera version number or 0. Example: 9.2 * Gecko engine revision number. Will evaluate to 1 if Gecko * is detected but the revision could not be found. Other browsers * will be 0. Example: 1.8 * Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7 * Firefox 1.5.0.9: 1.8.0.9 <-- Reports 1.8 * Firefox 2.0.0.3: 1.8.1.3 <-- Reports 1.8 * Firefox 3 alpha: 1.9a4 <-- Reports 1.9 * AppleWebKit version. KHTML browsers that are not WebKit browsers * will evaluate to 1, other browsers 0. Example: 418.9 * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the * latest available for Mac OSX 10.3. * Safari 2.0.2: 416 <-- hasOwnProperty introduced * Safari 2.0.4: 418 <-- preventDefault fixed * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run * different versions of webkit * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been * updated, but not updated * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native SVG * and many major issues fixed). * Safari 3.0.4 (523.12) 523.12 <-- First Tiger release - automatic update * from 2.x via the 10.4.11 OS patch * Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event. * yahoo.com user agent hack removed. * The mobile property will be set to a string containing any relevant * user agent information when a modern mobile browser is detected. * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series * devices with the WebKit-based browser, and Opera Mini. * Adobe AIR version number or 0. Only populated if webkit is detected. * Google Caja version number or 0. * Set to true if the page appears to be in SSL * The operating system. Currently only detecting windows or macintosh // Modern KHTML browsers should qualify as Safari X-Grade // Modern WebKit browsers are at least X-Grade o.
mobile =
"Apple";
// iPhone or iPod Touch o.
mobile = m[
0];
// Nokia N-series, ex: NokiaN95 o.
air = m[
0];
// Adobe AIR 1.0 or better if (!o.
webkit) {
// not webkit // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr) o.
mobile = m[
0];
// ex: Opera Mini/2.0.4509/1316 }
else {
// not opera or webkit }
else {
// not opera, webkit, or ie o.
gecko=
1;
// Gecko detected, look for revision * Executes the supplied function in the context of the supplied * object 'when' milliseconds later. Executes the function a * single time unless periodic is set to true. * @param when {int} the number of milliseconds to wait until the fn * @param o the context object. * @param fn {Function|String} the function to execute or the name of * the method in the 'o' object to execute. * @param data [Array] data that is provided to the function. This accepts * either a single item or an array. If an array is provided, the * function is executed with one parameter for each array item. If * you need to pass a single array parameter, it needs to be wrapped in * @param periodic {boolean} if true, executes continuously at supplied * interval until canceled. * @return {object} a timer object. Call the cancel() method on this object to Y.
error(
"method undefined");
// var min = ['yui-base', 'log', 'lang', 'array', 'core'], core, C = Y.config; // apply the minimal required functionality Y.
log(Y.
id +
' initialized',
'info',
'yui');
core = [
'queue-base',
'get',
'loader'];
YUI.
add(
'queue-base',
function(Y) {
* A simple FIFO queue of function references. * @param callback* {Function} 0..n callback functions to seed the queue * The collection of enqueued functions * Get the next callback in the queue. * @return {Function} the next callback in the queue * Add 0..n callbacks to the end of the queue * @param callback* {Function} 0..n callback functions * Returns the current number of queued callbacks * Provides a mechanism to fetch remote resources and * insert them into a document. * Fetches and inserts one or more script or link nodes into the document * hash of queues to manage multiple requests * queue index used to generate transaction ids * node index used to generate unique node ids * interal property used to prevent multiple simultaneous purge * Generates an HTML element, this is not appended to a document * @param type {string} the type of element * @param attr {string} the attributes * @param win {Window} optional window to create the element in * @return {HTMLElement} the generated node * @param url {string} the url for the css file * @param win {Window} optional window to create the node in * @param attributes optional attributes collection to apply to the new node * @return {HTMLElement} the generated node * Generates a script node * @param url {string} the url for the script file * @param win {Window} optional window to create the node in * @param attributes optional attributes collection to apply to the new node * @return {HTMLElement} the generated node * Removes the nodes for the specified queue * Returns the data payload for callback functions * The request failed, execute fail handler with whatever * was accomplished. There isn't a failure case at the * moment unless you count aborted transactions * @param id {string} the id of the request Y.
log(
"get failure: " +
msg,
"warn",
"get");
// execute failure callback * The request is complete, so executing the requester's callback * @param id {string} the id of the request Y.
log(
"Finishing transaction " +
id,
"info",
"get");
msg =
"transaction " +
id +
" was aborted";
// execute success callback * @param id {string} the id of the request Y.
log(
"Timeout " +
id,
"info",
"get");
* Loads the next item for a given request * @param id {string} the id of the request * @param loaded {string} the url that was just loaded, if any Y.
log(
"_next: " +
id +
", loaded: " + (
loaded ||
"nothing"),
"info",
"get");
// Y.log('cancel timer'); msg =
"transaction " +
id +
" was aborted";
// This is the first pass: make sure the url is an array // if the url is undefined, this is probably a trailing comma problem in IE Y.
log(
'skipping empty url');
Y.
log(
"attempting to load " +
url,
"info",
"get");
// Y.log('create timer'); if (q.
type ===
"script") {
// track this node's load progress // add the node to the queue so we can return it to the user supplied callback // add it to the head or insert it before 'insertBefore' Y.
log(
"Appending node: " +
url,
"info",
"get");
// FireFox does not support the onload event for link nodes, so there is // no way to make the css requests synchronous. This means that the css // rules in multiple files could be applied out of order in this browser // if a later request returns before an earlier one. Safari too. * Removes processed queues and corresponding nodes * Saves the state for the request and begins loading * @param type {string} the type of node to insert * @param url {string} the url to load * @param opts the hash of options for this request (
type ===
"script") ?
true :
false;
* Detects when a node has been loaded. In the case of * script nodes, this does not guarantee that contained * script is ready to use. * @param type {string} the type of node to track * @param n {HTMLElement} the node to track * @param id {string} the id of the request * @param url {string} the url that is being loaded * @param win {Window} the targeted window * @param qlength the number of remaining items in the queue, * @param trackfn {Function} function to execute when finished // IE supports the readystatechange event for script and css nodes // Opera only for script nodes. Opera support onload for script // nodes, but this doesn't fire when there is a load failure. // The onreadystatechange appears to be a better way to respond // to both success and failure. if (
"loaded" ===
rs ||
"complete" ===
rs) {
Y.
log(
id +
" onreadstatechange " +
url,
"info",
"get");
// webkit prior to 3.x is no longer supported // Safari 3.x supports the load event for script nodes (DOM2) Y.
log(
id +
" DOM2 onload " +
url,
"info",
"get");
// FireFox and Opera support onload (but not DOM2 in FF) handlers for // script nodes. Opera, but not FF, supports the onload event for link Y.
log(
id +
" onload " +
url,
"info",
"get");
* The number of request required before an automatic purge. * Called by the the helper for detecting script load in Safari * @param id {string} the transaction id Y.
log(
id +
" finalized ",
"info",
"get");
* @param o {string|object} Either the tId or the object returned from Y.
log(
"Aborting " +
id,
"info",
"get");
* Fetches and inserts one or more script nodes into the head * of the current document or the document in a specified window. * @param url {string|string[]} the url or urls to the script(s) * @param opts {object} Options: * callback to execute when the script(s) are finished loading * The callback receives an object back with the following * <dd>the window the script(s) were inserted into</dd> * <dd>the data object passed in when the request was made</dd> * <dd>An array containing references to the nodes that were * <dd>A function that, when executed, will remove the nodes * that were inserted</dd> * callback to execute when a timeout occurs. * The callback receives an object back with the following * <dd>the window the script(s) were inserted into</dd> * <dd>the data object passed in when the request was made</dd> * <dd>An array containing references to the nodes that were * <dd>A function that, when executed, will remove the nodes * that were inserted</dd> * callback to execute when the script load operation fails * The callback receives an object back with the following * <dd>the window the script(s) were inserted into</dd> * <dd>the data object passed in when the request was made</dd> * <dd>An array containing references to the nodes that were * inserted successfully</dd> * <dd>A function that, when executed, will remove any nodes * that were inserted</dd> * <dd>the execution context for the callbacks</dd> * <dd>a window other than the one the utility occupies</dd> * setting to true will let the utilities cleanup routine purge * <dt>purgethreshold</dt> * The number of transaction before autopurge should be initiated * data that is supplied to the callback when the script(s) are * <dd>node or node id that will become the new node's nextSibling</dd> * <dd>Node charset, default utf-8 (deprecated, use the attributes config)</dd> * <dd>An object literal containing additional attributes to add to the link tags</dd> * <dd>Number of milliseconds to wait before aborting and firing the timeout event</dd> * Y.Get.script( * onSuccess: function(o) { * this.log("won't cause error because Y is the context"); * Y.log(o.data); // foo * Y.log(o.nodes.length === 2) // true * // o.purge(); // optionally remove the script nodes immediately * }, * onFailure: function(o) { * Y.log("transaction failed"); * }, * onTimeout: function(o) { * Y.log("transaction timed out"); * }, * data: "foo", * timeout: 10000, // 10 second timeout * context: Y, // make the YUI instance * // win: otherframe // target another window/frame * autopurge: true // allow the utility to choose when to remove the nodes * purgetheshold: 1 // purge previous transaction before next transaction * @return {tId: string} an object containing info about the transaction * Fetches and inserts one or more css link nodes into the * head of the current document or the document in a specified * @param url {string} the url or urls to the css file(s) * callback to execute when the css file(s) are finished loading * The callback receives an object back with the following * <dd>the window the link nodes(s) were inserted into</dd> * <dd>the data object passed in when the request was made</dd> * <dd>An array containing references to the nodes that were * <dd>A function that, when executed, will remove the nodes * that were inserted</dd> * <dd>the execution context for the callbacks</dd> * <dd>a window other than the one the utility occupies</dd> * data that is supplied to the callbacks when the nodes(s) are * <dd>node or node id that will become the new node's nextSibling</dd> * <dd>Node charset, default utf-8 (deprecated, use the attributes config)</dd> * <dd>An object literal containing additional attributes to add to the link tags</dd> * insertBefore: 'custom-styles' // nodes will be inserted before the specified node * @return {tId: string} an object containing info about the transaction YUI.
add(
'loader',
function(Y) {
* Loader dynamically loads script and css files. It includes the dependency * info for the version of the library in use, and will automatically pull in * dependencies for the modules requested. It supports rollup files and will * automatically use these when appropriate in order to minimize the number of * http connections required to load all of the dependencies. It can load the * files from the Yahoo! CDN, and it can utilize the combo service provided on * this network to reduce the number of http connections required to download * Loader dynamically loads script and css files. It includes the dependency * info for the version of the library in use, and will automatically pull in * dependencies for the modules requested. It supports rollup files and will * automatically use these when appropriate in order to minimize the number of * http connections required to load all of the dependencies. It can load the * files from the Yahoo! CDN, and it can utilize the combo service provided on * this network to reduce the number of http connections required to download * @param o an optional set of configuration options. Valid options: * The secure base dir (not implemented)</li> * The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li> * A filter to apply to result urls. This filter will modify the default * path for all modules. The default path for the YUI library is the * minified version of the files (e.g., event-min.js). The filter property * can be a predefined filter or a custom filter. The valid predefined * <dd>Selects the debug versions of the library (e.g., event-debug.js). * This option will automatically include the Logger widget</dd> * <dd>Selects the non-minified version of the library (e.g., event.js).</dd> * You can also define a custom filter, which must be an object literal * containing a search expression and a replace string: * 'searchExp': "-min\\.js", * <li>filters: per-component filter specification. If specified for a given component, this overrides the filter config</li> * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li> * A list of modules that should never be dynamically loaded</li> * A list of modules that should always be loaded when required, even if already present on the page</li> * Node or id for a node that should be used as the insertion point for new nodes</li> * charset for dynamic nodes (deprecated, use jsAttributes or cssAttributes)</li> * <li>jsAttributes: object literal containing attributes to add to script nodes</li> * <li>cssAttributes: object literal containing attributes to add to link nodes</li> * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li> * execution context for all callbacks</li> * callback for the 'success' event</li> * callback for the 'failure' event</li> * callback for the 'timeout' event</li> * callback executed each time a script or css file is loaded</li> * A list of module definitions. See Loader.addModule for the supported module metadata</li> // @TODO backed out the custom event changes so that the event system // isn't required in the seed build. If needed, we may want to // add them back if the event system is detected. * Executed when the loader successfully completes an insert operation * This can be subscribed to normally, or a listener can be passed * as an onSuccess config option. * Executed when the loader fails to complete an insert operation. * This can be subscribed to normally, or a listener can be passed * as an onFailure config option. * Executed when a Get operation times out. * This can be subscribed to normally, or a listener can be passed * as an onTimeout config option. 'cssreset-context',
'cssfonts-context',
'cssgrids-context'],
'datasource-arrayschema': {
'datasource-jsonschema': {
'datasource-scriptnode': {
'datasource-textschema': {
'datasource-xmlschema': {
// Create the metadata for both the regular and context-aware // versions of the YUI CSS foundation. // define -context module * Internal callback to handle multiple internal insert() calls * so that css is inserted prior to js * @property _internalCallback * Use the YUI environment listener to detect script load. This * is only switched on for Safari 2.x and below. * @property _useYahooListener * Callback that will be executed when the loader is finished * Callback that will be executed if there is a failure * Callback executed each time a script or css file is loaded * Callback that will be executed if a timeout occurs * The execution context for all callbacks * @default {YUI} the YUI instance * Data that is passed to all callbacks * Node reference or id where new nodes should be inserted before * @type string|HTMLElement * The charset attribute for inserted nodes * @deprecated, use cssAttributes or jsAttributes * An object literal containing attributes to add to link nodes * @property cssAttributes * An object literal containing attributes to add to script nodes * Base path for the combo service * If configured, YUI JS resources will use the combo * @default true if a base dir isn't in the config * Ignore modules registered on the YUI global * @property ignoreRegistered * Root path to prepend to module path for the combo * @default [YUI VERSION]/build/ * Timeout value in milliseconds. If set, this value will be used by * the get utility. the timeout event will fire if * A list of modules that should not be loaded, even if * they turn up in the dependency tree * A list of modules that should always be loaded, even * if they have already been inserted into the page. * Should we allow rollups * A filter to apply to result urls. This filter will modify the default * path for all modules. The default path for the YUI library is the * minified version of the files (e.g., event-min.js). The filter property * can be a predefined filter or a custom filter. The valid predefined * <dd>Selects the debug versions of the library (e.g., event-debug.js). * This option will automatically include the Logger widget</dd> * <dd>Selects the non-minified version of the library (e.g., event.js).</dd> * You can also define a custom filter, which must be an object literal * containing a search expression and a replace string: * 'searchExp': "-min\\.js", * @type string|{searchExp: string, replaceStr: string} * per-component filter specification. If specified for a given component, this * overrides the filter config. * The list of requested modules * @type {string: boolean} // this.moduleInfo = Y.merge(Y.Env.meta.moduleInfo); * Provides the information used to skin the skinnable components. * The following skin definition would result in 'skin1' and 'skin2' * being loaded for calendar (if calendar was requested), and * 'sam' for all other skinnable components: * // The default skin, which is automatically applied if not * // overriden by a component-specific skin definition. * // Change this in to apply a different skin globally * // This is combined with the loader base property to get * // the default root directory for a skin. ex: * // The name of the rollup css file for the skin * // The number of skinnable components requested that are * // required before using the rollup file rather than the * // individual component css files * // Any component-specific overrides can be specified here, * // making it possible to load different skins for different * // components. It is possible to load more than one skin * // for a given component as well. * calendar: ['skin1', 'skin2'] * List of rollup files found in the library metadata * Whether or not to load optional dependencies for * All of the derived dependencies in sorted order, which * will be populated when either calculate() or insert() * Set when beginning to compute the dependency tree. * Composed of what YUI reports to be loaded combined * with what has been loaded by any instance on the page * with the version number specified in the metadata. * @type {string: boolean} * A list of modules to attach to the YUI instance when complete. * If not supplied, the sorted list of dependencies are applied. * Flag to indicate the dependency tree needs to be recomputed * if insert is called again. * List of modules inserted by the utility * @type {string: boolean} * List of skipped modules during insert() because the module // Y.on('yui:load', this.loadNext, this); 'searchExp':
"-min\\.js",
'searchExp':
"-min\\.js",
}
else if (i ==
'modules') {
// add a hash of module definitions * Returns the skin module name for the specified skin name. If a * module name is supplied, the returned skin module name is * specific to the module passed in. * @param skin {string} the name of the skin * @param mod {string} optional: the name of a module to skin * @return {string} the full skin module name * Reverses <code>formatSkin</code>, providing the skin name and * module name if the string matches the pattern for skins. * @param mod {string} the module name to parse * @return {skin: string, module: string} the parsed skin name * and module name, or null if the supplied string does not match * Adds the skin def to the module info * @param skin {string} the name of the skin * @param mod {string} the name of the module * @param parent {string} parent module if this is a skin of a * @return {string} the module name for the skin // Add a module definition for the skin rollup css // Y.log('ext? ' + mod + ": " + ext); // Y.log('adding skin ' + name); 'path': sinf.base + skin + '/' + sinf.path, // Add a module definition for the module-specific skin css // Y.log('adding skin ' + name); /** Add a new module to the component metadata. * <dt>name:</dt> <dd>required, the component name</dd> * <dt>type:</dt> <dd>required, the component type (js or css)</dd> * <dt>path:</dt> <dd>required, the path to the script from "base"</dd> * <dt>requires:</dt> <dd>array of modules required by this component</dd> * <dt>optional:</dt> <dd>array of optional modules for this component</dd> * <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd> * <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd> * <dt>rollup:</dt> <dd>the number of superseded modules required for automatic rollup</dd> * <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd> * <dt>skinnable:</dt> <dd>flag to determine if skin assets should automatically be pulled in</dd> * <dt>submodules:</dt> <dd>a has of submodules</dd> * @param o An object containing the module data * @param name the module name (optional), required if not in the module data * @return {boolean} true if the module was added, false if * the object passed in did not provide all required attributes // o.path = name + "/" + name + "-min." + o.type; // Y.log('New module ' + name); // Handle submodule logic * Add a requirement for one or more module * @param what {string[] | string*} the modules to load * Returns an object containing properties for all modules required * in order to load the requested module * @param mod The module definition from moduleInfo // Y.log('getRequires, no module'); // Y.log('already expanded'); for (i=
0; i<r.
length; i=i+
1) {
// Y.log(mod.name + ' requiring ' + r[i]); // get the requirements from superseded modules, if any for (i=
0; i<r.
length; i=i+
1) {
// Y.log(mod.name + ' requiring ' + r[i]); for (i=
0; i<o.
length; i=i+
1) {
* Returns an object literal of the modules the supplied module satisfies * @param name{string} The name of the module * @param notMe {string} don't add this module name, only include superseded modules * @return what this module provides // use worker to break cycles // Y.log(name + ' provides worker trying: ' + mm); // we always want the return value normal behavior // (provides) for superseded modules. // Y.log(name + ' provides worker skipping done: ' + mm); // Y.log('cached: ' + name + ' ' + ckey + ' ' + L.dump(this.moduleInfo[name][ckey], 0)); // calculate superseded modules for (i=
0; i<s.
length; i=i+
1) {
// Y.log(name + " supersedes " + L.dump(m[SUPER], 0)); // Y.log(name + " provides " + L.dump(m[PROV], 0)); * Calculates the dependency tree, the result is stored in the sorted * @param o optional options object // Y.log("after calculate: " + this.sorted); * Investigates the current YUI configuration on the page. By default, * modules already detected will not be loaded again unless a force * option is encountered. Called by calculate() // Y.log("skinning: " + name); // Y.log("Already loaded stuff: " + L.dump(l, 0)); // add the ignore list to the list of loaded packages // OU.appendArray(l, this.ignore); // expand the list to include superseded modules // Y.log("expanding: " + j); // remove modules on the force list from the loaded list if (
this.
force[i]
in l) {
// Y.log("loaded expanded: " + L.dump(l, 0)); * Inspects the required modules list looking for additional * dependencies. Expands the required list to include all * required modules. Called by calculate() // Y.log('exploding ' + i); // Y.log('via explode: ' + req); // create the default module // Y.log('Module does not exist: ' + name + ', creating with defaults'); // m = this.addModule({ext: false}, name); * Look for rollup packages to determine if all of the modules a * rollup supersedes are required. If so, include the rollup to * help reduce the total number of connections required. Called // find and cache rollup modules // if (m && m.rollup && m.supersedes) { // make as many passes as needed to pick up rollup rollups // go through the rollup candidates if (!r[i] && !
this.
loaded[i]) {
// if the superseded module is loaded, we can't load the rollup // if (this.loaded[s[j]] && (!_Y.dupsAllowed[s[j]])) { // increment the counter if this module is required. if we are // beyond the rollup threshold, we will use the rollup module // Y.log("over thresh " + c + ", " + L.dump(r)); // Y.log("rollup: " + i + ", " + L.dump(this, 1)); // expand the rollup's dependencies // if we made it here w/o rolling up something, we are done * Remove superceded modules and loaded modules. Called by * calculate() after we have the mega list of all dependencies // remove if already loaded // remove anything this module supersedes for (j=
0; j<s.
length; j=j+
1) {
// this is the full list of items the YUI needs attached, // which is needed if some dependencies are already on // the page without their dependencies. Y.
log(
'attaching Y supplied deps: ' +
this.
attaching,
"info",
"loader");
Y.
log(
'attaching sorted list: ' +
this.
sorted,
"info",
"loader");
Y.
log(
'loader successful: ' + Y.
id,
"info",
"loader");
Y.
log(
'loader failure: ' + Y.
id,
"info",
"loader");
Y.
log(
'loader timeout: ' + Y.
id,
"info",
"loader");
* Sorts the dependency tree. The last step of calculate() // create an indexed list // returns true if b is not loaded, and is required // directly or by means of modules it supersedes. // check if this module requires the other directly // check if this module should be sorted after the other // check if this module requires one the other supersedes // external css files should be sorted below yui css // pointer to the first unsorted item // keep going until we make a pass without moving anything // start the loop after items that are already sorted // check the next module on the list to see if its // dependencies have been met // check everything below current item and move if we // find a requirement for the current item for (k=j+
1; k<l; k=k+
1) {
// extract the dependency so we can move it up // insert the dependency above the item that // jump out of loop if we moved something // this item is sorted, move our pointer and keep going // when we make it here and moved is false, we are // Y.log('private _insert() ' + (type || '') + ', ' + Y.id, "info", "loader"); // restore the state at the time of the request // build the dependency list // Y.log("trying to load css first"); // _queue.running = false; // set a flag to indicate the load has started // flag to indicate we are done with the combo service // and any additional files will need to be loaded // keep the loadType (js, css or undefined) cached * inserts the requested modules and their dependencies. * <code>type</code> can be "js" or "css". Both script and * css are inserted if type is not provided. * @param o optional options object * @param type {string} the type of dependency to insert Y.
log(
'public insert() ' + (
type ||
'') +
', ' + Y.
id,
"info",
"loader");
* Executed every time a module is loaded, and if we are in a load * cycle, we attempt to load the next script. Public so that it * is possible to call this if using a method other than * Y.register to determine when scripts are fully loaded * @param mname {string} optional the name of the module that has * been loaded (which is usually why it is time to load the next // It is possible that this function is executed due to something // else one the page loading a YUI module. Only react when we // are actively loading something var s,
len, i, m,
url,
self=
this,
type=
this.
loadType,
fn,
msg,
attr,
Y.
log(
'Combo complete: ' + o.
data,
"info",
"loader");
for (i=
0; i<
len; i=i+
1) {
// Y.log('loading next, just loaded' + o.data); // @TODO this will need to handle the two phase insert when for (i=
0; i<
len; i=i+
1) {
// @TODO we can't combine CSS yet until we deliver files with absolute paths to the assets // Do not try to combine non-yui JS Y.
log(
'Attempting to use combo: ' +
this.
_combining,
"info",
"loader");
// @TODO get rid of the redundant Get code // if the module that was just loaded isn't what we were expecting, Y.
log(
"loadNext executing, just loaded " +
mname +
", " + Y.
id,
"info",
"loader");
// The global handler that is called when each module is loaded // will pass that module name to this function. Storing this // data to avoid loading the same module multiple times for (i=
0; i<
len; i=i+
1) {
// this.inserted keeps track of what the loader has loaded. // move on if this item is done. // Y.log(s[i] + " alread loaded "); // Because rollups will cause multiple load notifications // from Y, loadNext may be called multiple times for // the same module when loading a rollup. We can safely // skip the subsequent requests Y.
log(
"still loading " + s[i] +
", waiting",
"info",
"loader");
// log("inserting " + s[i]); msg =
"Undefined module " + s[i] +
" skipped";
// The load type is stored to offer the possibility to load // the css separately from the script. Y.
log(
"attempting to load " + s[i] +
", " +
this.
base,
"info",
"loader");
// internal callback for loading css first // Y.log('loader internal'); // } else if (this.onSuccess) { // Y.log('loader complete'); // call Y.use passing this instance. Y will use the sorted * Apply filter defined for this instance to a url/path * @param u {string} the string to filter * @param name {string} the name of the module, if we are processing * a single module as opposed to a combined url * @return {string} the filtered string * Generates the full url for a module * @param path {string} the path fragment * @return {string} the full url },
'@VERSION@' ,{
requires:[
'queue-base']});
YUI.
add(
'yui',
function(Y){},
'@VERSION@' ,{
use:[
'yui-base',
'queue-base',
'get',
'loader']});