get-debug.js revision 2077777dc207cc578a0eed314e996912addea2cb
* hash of queues to manage multiple requests * queue index used to generate transaction 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 // This is a hostile delete // operation attempting to improve // memory performance. As such, the // hasOwnProperty check is intentionally * Returns the data payload for callback functions * The transaction is finished * @param id {string} the id of the request * 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");
_end(
id,
'timeout',
'timeout');
* 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'); // q.timer = L.later(q.timeout, q, _timeout, id); 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;
// L.later(0, q, _next, id); * 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. * Can be configured via the 'purgethreshold' config * Called by the the helper for detecting script load in Safari * @param id {string} the transaction id Y.
log(
id +
" finalized ",
"info",
"get");
// L.later(0, null, _finish, id); * @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> * <dd>a function that executes when the transaction finishes, regardless of the exit path</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