diff -r 000000000000 -r 40c8f766c9b8 src/cm/media/js/lib/yui/yui_3.0.0b1/build/get/get-debug.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.0.0b1/build/get/get-debug.js Mon Nov 23 15:14:29 2009 +0100 @@ -0,0 +1,728 @@ +/* +Copyright (c) 2009, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 3.0.0b1 +build: 1163 +*/ +YUI.add('get', function(Y) { + +(function() { + +/** + * Provides a mechanism to fetch remote resources and + * insert them into a document. + * @module yui + * @submodule get + */ + +var ua = Y.UA, + L = Y.Lang, + // PREFIX = Y.guid(), + TYPE_JS = "text/javascript", + TYPE_CSS = "text/css", + STYLESHEET = "stylesheet"; + +/** + * Fetches and inserts one or more script or link nodes into the document + * @class Get + * @static + */ +Y.Get = function() { + + /** + * hash of queues to manage multiple requests + * @property queues + * @private + */ + var queues={}, + + /** + * queue index used to generate transaction ids + * @property qidx + * @type int + * @private + */ + qidx=0, + + /** + * interal property used to prevent multiple simultaneous purge + * processes + * @property purging + * @type boolean + * @private + */ + purging=false, + + + /** + * Generates an HTML element, this is not appended to a document + * @method _node + * @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 + * @private + */ + _node = function(type, attr, win) { + var w = win || Y.config.win, d=w.document, n=d.createElement(type), + i; + + for (i in attr) { + if (attr[i] && attr.hasOwnProperty(i)) { + n.setAttribute(i, attr[i]); + } + } + + return n; + }, + + /** + * Generates a link node + * @method _linkNode + * @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 + * @private + */ + _linkNode = function(url, win, attributes) { + var o = { + id: Y.guid(), + type: TYPE_CSS, + rel: STYLESHEET, + href: url + }; + if (attributes) { + Y.mix(o, attributes); + } + return _node("link", o, win); + }, + + /** + * Generates a script node + * @method _scriptNode + * @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 + * @private + */ + _scriptNode = function(url, win, attributes) { + var o = { + id: Y.guid(), + type: TYPE_JS, + src: url + }; + + if (attributes) { + Y.mix(o, attributes); + } + + return _node("script", o, win); + }, + + /** + * Removes the nodes for the specified queue + * @method _purge + * @private + */ + _purge = function(tId) { + var q=queues[tId], n, l, d, h, s, i; + if (q) { + n = q.nodes; + l = n.length; + d = q.win.document; + h = d.getElementsByTagName("head")[0]; + + if (q.insertBefore) { + s = _get(q.insertBefore, tId); + if (s) { + h = s.parentNode; + } + } + + for (i=0; i + *
onSuccess
+ *
+ * callback to execute when the script(s) are finished loading + * The callback receives an object back with the following + * data: + *
+ *
win
+ *
the window the script(s) were inserted into
+ *
data
+ *
the data object passed in when the request was made
+ *
nodes
+ *
An array containing references to the nodes that were + * inserted
+ *
purge
+ *
A function that, when executed, will remove the nodes + * that were inserted
+ *
+ *
+ *
+ *
onTimeout
+ *
+ * callback to execute when a timeout occurs. + * The callback receives an object back with the following + * data: + *
+ *
win
+ *
the window the script(s) were inserted into
+ *
data
+ *
the data object passed in when the request was made
+ *
nodes
+ *
An array containing references to the nodes that were + * inserted
+ *
purge
+ *
A function that, when executed, will remove the nodes + * that were inserted
+ *
+ *
+ *
+ *
onEnd
+ *
a function that executes when the transaction finishes, regardless of the exit path
+ *
onFailure
+ *
+ * callback to execute when the script load operation fails + * The callback receives an object back with the following + * data: + *
+ *
win
+ *
the window the script(s) were inserted into
+ *
data
+ *
the data object passed in when the request was made
+ *
nodes
+ *
An array containing references to the nodes that were + * inserted successfully
+ *
purge
+ *
A function that, when executed, will remove any nodes + * that were inserted
+ *
+ *
+ *
+ *
context
+ *
the execution context for the callbacks
+ *
win
+ *
a window other than the one the utility occupies
+ *
autopurge
+ *
+ * setting to true will let the utilities cleanup routine purge + * the script once loaded + *
+ *
purgethreshold
+ *
+ * The number of transaction before autopurge should be initiated + *
+ *
data
+ *
+ * data that is supplied to the callback when the script(s) are + * loaded. + *
+ *
insertBefore
+ *
node or node id that will become the new node's nextSibling
+ * + *
charset
+ *
Node charset, default utf-8 (deprecated, use the attributes config)
+ *
attributes
+ *
An object literal containing additional attributes to add to the link tags
+ *
timeout
+ *
Number of milliseconds to wait before aborting and firing the timeout event
+ *
+         *   Y.Get.script(
+         *   ["http://yui.yahooapis.com/2.5.2/build/yahoo/yahoo-min.js",
+         *    "http://yui.yahooapis.com/2.5.2/build/event/event-min.js"], {
+         *     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 + */ + script: function(url, opts) { + return _queue("script", url, opts); + }, + + /** + * Fetches and inserts one or more css link nodes into the + * head of the current document or the document in a specified + * window. + * @method css + * @static + * @param url {string} the url or urls to the css file(s) + * @param opts Options: + *
+ *
onSuccess
+ *
+ * callback to execute when the css file(s) are finished loading + * The callback receives an object back with the following + * data: + *
win
+ *
the window the link nodes(s) were inserted into
+ *
data
+ *
the data object passed in when the request was made
+ *
nodes
+ *
An array containing references to the nodes that were + * inserted
+ *
purge
+ *
A function that, when executed, will remove the nodes + * that were inserted
+ *
+ *
+ * + *
context
+ *
the execution context for the callbacks
+ *
win
+ *
a window other than the one the utility occupies
+ *
data
+ *
+ * data that is supplied to the callbacks when the nodes(s) are + * loaded. + *
+ *
insertBefore
+ *
node or node id that will become the new node's nextSibling
+ *
charset
+ *
Node charset, default utf-8 (deprecated, use the attributes config)
+ *
attributes
+ *
An object literal containing additional attributes to add to the link tags
+ * + *
+         *      Y.Get.css("http://yui.yahooapis.com/2.3.1/build/menu/assets/skins/sam/menu.css");
+         * 
+ *
+         *   Y.Get.css(
+         *   ["http://yui.yahooapis.com/2.3.1/build/menu/assets/skins/sam/menu.css",
+         *    "http://yui.yahooapis.com/2.3.1/build/logger/assets/skins/sam/logger.css"], {
+         *     insertBefore: 'custom-styles' // nodes will be inserted before the specified node
+         *   });
+         * 
+ * @return {tId: string} an object containing info about the transaction + */ + css: function(url, opts) { + return _queue("css", url, opts); + } + }; +}(); + +})(); + + +}, '3.0.0b1' );