diff -r 000000000000 -r 40c8f766c9b8 src/cm/media/js/lib/yui/yui_3.0.0b1/build/yui-base/yui-base.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.0.0b1/build/yui-base/yui-base.js Mon Nov 23 15:14:29 2009 +0100 @@ -0,0 +1,2068 @@ +/* +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 +*/ +(function() { + + var _instances = {}, + _startTime = new Date().getTime(), + p, + i, + + add = function () { + if (window.addEventListener) { + return function(el, type, fn, capture) { + el.addEventListener(type, fn, (!!capture)); + }; + } else if (window.attachEvent) { + return function(el, type, fn) { + el.attachEvent("on" + type, fn); + }; + } else { + return function(){}; + } + }(), + + remove = function() { + if (window.removeEventListener) { + return function (el, type, fn, capture) { + el.removeEventListener(type, fn, !!capture); + }; + } else if (window.detachEvent) { + return function (el, type, fn) { + el.detachEvent("on" + type, fn); + }; + } else { + return function(){}; + } + }(), + + globalListener = function() { + YUI.Env.windowLoaded = true; + YUI.Env.DOMReady = true; + remove(window, 'load', globalListener); + }, + +// @TODO: this needs to be created at build time from module metadata + + _APPLY_TO_WHITE_LIST = { + 'io.xdrReady': 1, + 'io.start': 1, + 'io.success': 1, + 'io.failure': 1 + }, + + SLICE = Array.prototype.slice; + +// reduce to one or the other +if (typeof YUI === 'undefined' || !YUI) { + + /** + * The YUI global namespace object. If YUI is already defined, the + * existing YUI object will not be overwritten so that defined + * namespaces are preserved. + * + * @class YUI + * @constructor + * @global + * @uses EventTarget + * @param o Optional configuration object. This object is stored + * in YUI.config. See config for the list of supported properties. + */ + + /*global YUI*/ + // Make a function, disallow direct instantiation + YUI = function(o) { + + var Y = this; + + // Allow instantiation without the new operator + if (!(Y instanceof YUI)) { + return new YUI(o); + } else { + // set up the core environment + Y._init(o); + + // bind the specified additional modules for this instance + Y._setup(); + + return Y; + } + }; +} + +// The prototype contains the functions that are required to allow the external +// modules to be registered and for the instance to be initialized. +YUI.prototype = { + + /** + * Initialize this YUI instance + * @param o config options + * @private + */ + _init: function(o) { + + o = o || {}; + + // find targeted window/frame + // @TODO create facades + var v = '3.0.0b1', Y = this; + o.win = o.win || window || {}; + o.win = o.win.contentWindow || o.win; + o.doc = o.win.document; + o.debug = ('debug' in o) ? o.debug : true; + o.useBrowserConsole = ('useBrowserConsole' in o) ? o.useBrowserConsole : true; + o.throwFail = ('throwFail' in o) ? o.throwFail : true; + + // add a reference to o for anything that needs it + // before _setup is called. + Y.config = o; + + Y.Env = { + // @todo expand the new module metadata + mods: {}, + _idx: 0, + _used: {}, + _attached: {}, + _yidx: 0, + _uidx: 0, + _loaded: {} + }; + + + if (v.indexOf('@') > -1) { + v = 'test'; + } + + Y.version = v; + + Y.Env._loaded[v] = {}; + + if (YUI.Env) { + Y.Env._yidx = (++YUI.Env._yidx); + Y.Env._guidp = ('yui_' + this.version + '-' + Y.Env._yidx + '-' + _startTime).replace(/\./g, '_'); + Y.id = Y.stamp(Y); + _instances[Y.id] = Y; + } + + Y.constructor = YUI; + + + // this.log(this.id + ') init '); + }, + + /** + * Finishes the instance setup. Attaches whatever modules were defined + * when the yui modules was registered. + * @method _setup + * @private + */ + _setup: function(o) { + this.use("yui-base"); + // @TODO eval the need to copy the config + this.config = this.merge(this.config); + }, + + /** + * Executes a method on a YUI instance with + * the specified id if the specified method is whitelisted. + * @method applyTo + * @param id {string} the YUI instance id + * @param method {string} the name of the method to exectute. + * Ex: 'Object.keys' + * @param args {Array} the arguments to apply to the method + * @return {object} the return value from the applied method or null + */ + applyTo: function(id, method, args) { + + if (!(method in _APPLY_TO_WHITE_LIST)) { + this.error(method + ': applyTo not allowed'); + return null; + } + + var instance = _instances[id], nest, m, i; + + if (instance) { + + nest = method.split('.'); + m = instance; + + for (i=0; i + * 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 + * + * @method namespace + * @param {string*} arguments 1-n namespaces to create + * @return {object} A reference to the last namespace object created + */ + namespace: function() { + var a=arguments, o=null, i, j, d; + for (i=0; i + * @property logExclude + * @type object + */ + +/** + * Set to true if the yui seed file was dynamically loaded in + * order to bootstrap components relying on the window load event + * and onDOMReady. + * @property injected + * @type object + */ + +/** + * If throwFail is set, Y.fail will generate or re-throw a JS Error. Otherwise the failure is logged. + * @property throwFail + * @type boolean + * @default true + */ + +/** + * The window/frame that this instance should operate in + * @property win + * @type Window + * @default the window hosting YUI + */ + +/** + * The document associated with the 'win' configuration + * @property doc + * @type Document + * @default the document hosting YUI + */ + +/** + * A list of modules that defines the YUI core (overrides the default) + * @property core + * @type string[] + */ + +/** + * The default date format + * @property dateFormat + * @type string + */ + +/** + * The default locale + * @property locale + * @type string + */ + +/** + * The default interval when polling in milliseconds. + * @property pollInterval + * @type int + * @default 20 + */ + +/** + * The number of dynamic nodes to insert by default before + * automatically removing them. This applies to script nodes + * because remove the node will not make the evaluated script + * unavailable. Dynamic CSS is not auto purged, because removing + * a linked style sheet will also remove the style definitions. + * @property purgethreshold + * @type int + * @default 20 + */ + +/** + * The default interval when polling in milliseconds. + * @property windowResizeDelay + * @type int + * @default 40 + */ + +/** + * Base directory for dynamic loading + * @property base + * @type string + */ + +/** + * The secure base dir (not implemented) + * For dynamic loading. + * @property secureBase + * @type string + */ + +/** + * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo? + * For dynamic loading. + * @property comboBase + * @type string + */ + +/** + * The root path to prepend to module names for the combo service. Ex: 3.0.0b1/build/ + * For dynamic loading. + * @property root + * @type string + */ + +/** + * 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 + * filters are: + *
+ *
DEBUG
+ *
Selects the debug versions of the library (e.g., event-debug.js). + * This option will automatically include the Logger widget
+ *
RAW
+ *
Selects the non-minified version of the library (e.g., event.js).
+ *
+ * You can also define a custom filter, which must be an object literal + * containing a search expression and a replace string: + *
+ *  myFilter: { 
+ *      'searchExp': "-min\\.js", 
+ *      'replaceStr': "-debug.js"
+ *  }
+ * 
+ * For dynamic loading. + * @property filter + * @type string|object + */ + +/** + * Hash of per-component filter specification. If specified for a given component, + * this overrides the filter config + * For dynamic loading. + * @property filters + * @type object + */ + +/** + * Use the YUI combo service to reduce the number of http connections + * required to load your dependencies + * For dynamic loading. + * @property combine + * @type boolean + * @default true if 'base' is not supplied, false if it is. + */ + +/** + * A list of modules that should never be dynamically loaded + * @property ignore + * @type string[] + */ + +/** + * A list of modules that should always be loaded when required, even if already + * present on the page. + * @property force + * @type string[] + */ + +/** + * Node or id for a node that should be used as the insertion point for new nodes + * For dynamic loading. + * @property insertBefore + * @type string + */ + +/** + * charset for dynamic nodes + * @property charset + * @type string + */ + +/** + * Object literal containing attributes to add to dynamically loaded script nodes. + * @property jsAttributes + * @type string + */ + +/** + * Object literal containing attributes to add to dynamically loaded link nodes. + * @property cssAttributes + * @type string + */ + +/** + * Number of milliseconds before a timeout occurs when dynamically + * loading nodes. If not set, there is no timeout. + * @property timeout + * @type int + */ + +/** + * Callback for the 'CSSComplete' event. When dynamically loading YUI + * components with CSS, this property fires when the CSS is finished + * loading but script loading is still ongoing. This provides an + * opportunity to enhance the presentation of a loading page a little + * bit before the entire loading process is done. + * @property onCSS + * @type function + */ + +/** + * A list of module definitions to add to the list of YUI components. + * These components can then be dynamically loaded side by side with + * YUI via the use() method.See Loader.addModule for the supported + * module metadata. + * @property modules + * @type function + */ + +YUI.add('yui-base', function(Y) { + +/* + * YUI stub + * @module yui + * @submodule yui-base + */ +(function() { + +var instance = Y, + LOGEVENT = 'yui:log', + _published; + +/** + * 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. + * + * @method log + * @for YUI + * @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.log = function(msg, cat, src, silent) { + var Y = instance, c = Y.config, bail = false, exc, inc, m, f; + // 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 + if (c.debug) { + // apply source filters + if (src) { + + exc = c.logExclude; + inc = c.logInclude; + + if (inc && !(src in inc)) { + bail = true; + } else if (exc && (src in exc)) { + bail = true; + } + } + + if (!bail) { + + if (c.useBrowserConsole) { + m = (src) ? src + ': ' + msg : msg; + if (typeof console != 'undefined') { + f = (cat && console[cat]) ? cat : 'log'; + console[f](m); + } else if (typeof opera != 'undefined') { + opera.postError(m); + } + } + + if (Y.fire && !bail && !silent) { + if (!_published) { + Y.publish(LOGEVENT, { + broadcast: 2, + emitFacade: true + }); + + _published = true; + + } + Y.fire(LOGEVENT, { + msg: msg, + cat: cat, + src: src + }); + } + } + } + + return Y; +}; + +/** + * Write a system message. This message will be preserved in the + * minified and raw versions of the YUI files, unlike log statements. + * @method message + * @for YUI + * @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.message = function() { + return instance.log.apply(instance, arguments); +}; + +/* + * @TODO I'm not convinced the current log statement scrubbing routine can + * be made safe with all the variations that could be supplied for + * the condition. + * + * logIf statements are stripped from the raw and min files. + * @method logIf + * @for YUI + * @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) { +// if (condition) { +// } +// }; + +})(); +(function() { +/** + * Provides the language utilites and extensions used by the library + * @class Lang + * @static + */ +Y.Lang = Y.Lang || {}; + +var L = Y.Lang, + +ARRAY = 'array', +BOOLEAN = 'boolean', +DATE = 'date', +ERROR = 'error', +FUNCTION = 'function', +NUMBER = 'number', +NULL = 'null', +OBJECT = 'object', +REGEX = 'regexp', +STRING = 'string', +TOSTRING = Object.prototype.toString, +UNDEFINED = 'undefined', + +TYPES = { + 'undefined' : UNDEFINED, + 'number' : NUMBER, + 'boolean' : BOOLEAN, + 'string' : STRING, + '[object Function]' : FUNCTION, + '[object RegExp]' : REGEX, + '[object Array]' : ARRAY, + '[object Date]' : DATE, + '[object Error]' : ERROR +}, + +TRIMREGEX = /^\s+|\s+$/g, +EMPTYSTRING = ''; + +/** + * 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 + * want to + * @method isArray + * @static + * @param o The object to test + * @return {boolean} true if o is an array + */ +L.isArray = function(o) { + return L.type(o) === ARRAY; +}; + +/** + * Determines whether or not the provided item is a boolean + * @method isBoolean + * @static + * @param o The object to test + * @return {boolean} true if o is a boolean + */ +L.isBoolean = function(o) { + return typeof o === 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 + * matter to you. + * + * @method isFunction + * @static + * @param o The object to test + * @return {boolean} true if o is a function + */ +L.isFunction = function(o) { + return L.type(o) === FUNCTION; +}; + +/** + * Determines whether or not the supplied item is a date instance + * @method isDate + * @static + * @param o The object to test + * @return {boolean} true if o is a date + */ +L.isDate = function(o) { + // return o instanceof Date; + return L.type(o) === DATE; +}; + +/** + * Determines whether or not the provided item is null + * @method isNull + * @static + * @param o The object to test + * @return {boolean} true if o is null + */ +L.isNull = function(o) { + return o === null; +}; + +/** + * Determines whether or not the provided item is a legal number + * @method isNumber + * @static + * @param o The object to test + * @return {boolean} true if o is a number + */ +L.isNumber = function(o) { + return typeof o === NUMBER && isFinite(o); +}; + +/** + * Determines whether or not the provided item is of type object + * or function + * @method isObject + * @static + * @param o The object to test + * @param failfn {boolean} fail if the input is a function + * @return {boolean} true if o is an object + */ +L.isObject = function(o, failfn) { +return (o && (typeof o === OBJECT || (!failfn && L.isFunction(o)))) || false; +}; + +/** + * Determines whether or not the provided item is a string + * @method isString + * @static + * @param o The object to test + * @return {boolean} true if o is a string + */ +L.isString = function(o) { + return typeof o === STRING; +}; + +/** + * Determines whether or not the provided item is undefined + * @method isUndefined + * @static + * @param o The object to test + * @return {boolean} true if o is undefined + */ +L.isUndefined = function(o) { + return typeof o === UNDEFINED; +}; + +/** + * Returns a string without any leading or trailing whitespace. If + * the input is not a string, the input will be returned untouched. + * @method trim + * @static + * @param s {string} the string to trim + * @return {string} the trimmed string + */ +L.trim = function(s){ + try { + return s.replace(TRIMREGEX, EMPTYSTRING); + } catch(e) { + return s; + } +}; + +/** + * A convenience method for detecting a legitimate non-null value. + * Returns false for null/undefined/NaN, true for other values, + * including 0/false/'' + * @method isValue + * @static + * @param o The item to test + * @return {boolean} true if it is not null/undefined/NaN || false + */ +L.isValue = function(o) { + var t = L.type(o); + switch (t) { + case NUMBER: + return isFinite(o); + case NULL: + case UNDEFINED: + return false; + default: + return !!(t); + } +}; + +/** + * Returns a string representing the type of the item passed in. + * @method type + * @param o the item to test + * @return {string} the detected type + */ +L.type = function (o) { + return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? OBJECT : NULL); +}; + +})(); + +/* + * Provides information about the environment hosting YUI + * @module yui + * @submodule Array + */ + +(function() { + +var L = Y.Lang, Native = Array.prototype, + +/** + * Adds the following array utilities to the YUI instance. Additional + * array helpers can be found in the collection component. + * @class Array + */ + +/** + * 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 + * force a conversion. + * + * @method () + * @static + * @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 + */ +YArray = function(o, startIdx, al) { + var t = (al) ? 2 : Y.Array.test(o), i, l, a; + + // switch (t) { + // case 1: + // // return (startIdx) ? o.slice(startIdx) : o; + // case 2: + // return Native.slice.call(o, startIdx || 0); + // default: + // return [o]; + // } + + if (t) { + try { + return Native.slice.call(o, startIdx || 0); + // IE errors when trying to slice element collections + } catch(e) { + a=[]; + for (i=0, l=o.length; i 1)) { + r = 2; + } + + } catch(e) {} + } + } + return r; +}; + +/** + * Executes the supplied function on each item in the array. + * @method each + * @param a {Array} the array to iterate + * @param f {Function} the function to execute on each item + * @param o Optional context object + * @static + * @return {YUI} the YUI instance + */ +YArray.each = (Native.forEach) ? + function (a, f, o) { + Native.forEach.call(a || [], f, o || Y); + return Y; + } : + function (a, f, o) { + var l = (a && a.length) || 0, i; + for (i = 0; i < l; i=i+1) { + f.call(o || Y, a[i], i, a); + } + return Y; + }; + +/** + * 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. + * @method hash + * @static + * @param k {Array} keyset + * @param v {Array} optional valueset + * @return {object} the hash + */ +YArray.hash = function(k, v) { + var o = {}, l = k.length, vl = v && v.length, i; + for (i=0; i i) ? v[i] : true; + } + + return o; +}; + +/** + * Returns the index of the first item in the array + * that contains the specified value, -1 if the + * value isn't found. + * @method indexOf + * @static + * @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 + */ +YArray.indexOf = (Native.indexOf) ? + function(a, val) { + return a.indexOf(val); + } : + function(a, val) { + for (var i=0; i 1) ? Array.prototype.join.call(arguments, DELIMITER) : arg1; + + // (?)() 51 8.06% 0.761ms 0.762ms 0.015ms 0.002ms 0.025ms + // var key = (arg2 !== undefined) ? Array.prototype.join.call(arguments, DELIMITER) : arg1; + + // (?)() 51 7.87% 0.749ms 0.751ms 0.015ms 0.001ms 0.027ms + // A() 30 2.23% 0.214ms 0.214ms 0.007ms 0.005ms 0.009ms + var key = (arg2) ? Array.prototype.join.call(arguments, DELIMITER) : arg1; + + if (!(key in cache)) { + cache[key] = source.apply(source, arguments); + } + + return cache[key]; + }; + +}; + +})(); + +(function() { + +/** + * Adds the following Object utilities to the YUI instance + * @class Object + */ + +/** + * Y.Object(o) returns a new object based upon the supplied object. + * @TODO Use native Object.create() when available + * @method () + * @static + * @param o the supplier object + * @return {Object} the new object + */ +Y.Object = function(o) { + var F = function() {}; + F.prototype = o; + return new F(); +}; + +var O = Y.Object, + +UNDEFINED = undefined, + +/** + * Extracts the keys, values, or size from an object + * + * @method _extract + * @param o the object + * @param what what to extract (0: keys, 1: values, 2: size) + * @return {boolean|Array} the extracted info + * @static + * @private + */ +_extract = function(o, what) { + var count = (what === 2), out = (count) ? 0 : [], i; + + for (i in o) { + if (count) { + out++; + } else { + if (o.hasOwnProperty(i)) { + out.push((what) ? o[i] : i); + } + } + } + + return out; +}; + +/** + * Returns an array containing the object's keys + * @TODO use native Object.keys() if available + * @method keys + * @static + * @param o an object + * @return {string[]} the keys + */ +O.keys = function(o) { + return _extract(o); +}; + +/** + * Returns an array containing the object's values + * @TODO use native Object.values() if available + * @method values + * @static + * @param o an object + * @return {Array} the values + */ +O.values = function(o) { + return _extract(o, 1); +}; + +/** + * Returns the size of an object + * @TODO use native Object.size() if available + * @method size + * @static + * @param o an object + * @return {int} the size + */ +O.size = function(o) { + return _extract(o, 2); +}; + +/** + * Returns true if the object contains a given key + * @method hasKey + * @static + * @param o an object + * @param k the key to query + * @return {boolean} true if the object contains the key + */ +O.hasKey = function(o, k) { + // return (o.hasOwnProperty(k)); + return (k in o); +}; + +/** + * Returns true if the object contains a given value + * @method hasValue + * @static + * @param o an object + * @param v the value to query + * @return {boolean} true if the object contains the value + */ +O.hasValue = function(o, v) { + return (Y.Array.indexOf(O.values(o), v) > -1); +}; + +/** + * 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 + * directly instead. + * + * @TODO Remove in B1 + * + * @method owns + * @static + * @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) { + return (o.hasOwnProperty(k)); +}; + +/** + * Executes a function on each item. The function + * receives the value, the key, and the object + * as paramters (in that order). + * @method each + * @static + * @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 + */ +O.each = function (o, f, c, proto) { + var s = c || Y, i; + + for (i in o) { + if (proto || o.hasOwnProperty(i)) { + f.call(s, o[i], i, o); + } + } + return Y; +}; + +/** + * Retrieves the sub value at the provided path, + * from the value object provided. + * + * @method getValue + * @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. + */ +O.getValue = function (o, path) { + var p=Y.Array(path), l=p.length, i; + + for (i=0; o !== UNDEFINED && i < l; i=i+1) { + o = o[p[i]]; + } + + return o; +}; + +/** + * 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. + * + * @method setValue + * @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. + */ +O.setValue = function(o, path, val) { + + var p=Y.Array(path), leafIdx=p.length-1, i, ref=o; + + if (leafIdx >= 0) { + for (i=0; ref !== UNDEFINED && i < leafIdx; i=i+1) { + ref = ref[p[i]]; + } + + if (ref !== UNDEFINED) { + ref[p[i]] = val; + } else { + return UNDEFINED; + } + } + + return o; +}; + + +})(); + +/* + * Provides information about the environment hosting YUI + * @module yui + * @submodule UA + */ +/** + * 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 + * reports 1.8). + * @class UA + * @static + */ +Y.UA = function() { + + var nav = navigator, + o = { + + /** + * Internet Explorer version number or 0. Example: 6 + * @property ie + * @type float + * @static + */ + ie:0, + + /** + * Opera version number or 0. Example: 9.2 + * @property opera + * @type float + * @static + */ + opera:0, + + /** + * 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
+         * 
+ * @property gecko + * @type float + * @static + */ + gecko:0, + + /** + * 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
+         *                                   to the latest patch.
+         * 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.
+         * 
+ * http://en.wikipedia.org/wiki/Safari_(web_browser)#Version_history + * @property webkit + * @type float + * @static + */ + webkit:0, + + /** + * 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. + * @property mobile + * @type string + * @static + */ + mobile: null, + + /** + * Adobe AIR version number or 0. Only populated if webkit is detected. + * Example: 1.0 + * @property air + * @type float + */ + air: 0, + + /** + * Google Caja version number or 0. + * @property caja + * @type float + */ + caja: nav.cajaVersion, + + /** + * Set to true if the page appears to be in SSL + * @property secure + * @type boolean + * @static + */ + secure: false, + + /** + * The operating system. Currently only detecting windows or macintosh + * @property os + * @type string + * @static + */ + os: null + + }, + + ua = nav && nav.userAgent, + + loc = Y.config.win.location, + + href = loc && loc.href, + + m; + + o.secure = href && (href.toLowerCase().indexOf("https") === 0); + + if (ua) { + + if ((/windows|win32/).test(ua)) { + o.os = 'windows'; + } else if ((/macintosh/).test(ua)) { + o.os = 'macintosh'; + } + + // Modern KHTML browsers should qualify as Safari X-Grade + if ((/KHTML/).test(ua)) { + o.webkit=1; + } + // Modern WebKit browsers are at least X-Grade + m=ua.match(/AppleWebKit\/([^\s]*)/); + if (m&&m[1]) { + o.webkit=parseFloat(m[1]); + + // Mobile browser check + if (/ Mobile\//.test(ua)) { + o.mobile = "Apple"; // iPhone or iPod Touch + } else { + m=ua.match(/NokiaN[^\/]*/); + if (m) { + o.mobile = m[0]; // Nokia N-series, ex: NokiaN95 + } + } + + m=ua.match(/AdobeAIR\/([^\s]*)/); + if (m) { + 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) + m=ua.match(/Opera[\s\/]([^\s]*)/); + if (m&&m[1]) { + o.opera=parseFloat(m[1]); + m=ua.match(/Opera Mini[^;]*/); + if (m) { + o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316 + } + } else { // not opera or webkit + m=ua.match(/MSIE\s([^;]*)/); + if (m&&m[1]) { + o.ie=parseFloat(m[1]); + } else { // not opera, webkit, or ie + m=ua.match(/Gecko\/([^\s]*)/); + if (m) { + o.gecko=1; // Gecko detected, look for revision + m=ua.match(/rv:([^\s\)]*)/); + if (m&&m[1]) { + o.gecko=parseFloat(m[1]); + } + } + } + } + } + } + + return o; +}(); +(function() { + var L = Y.Lang, + + /** + * 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. + * @method later + * @for YUI + * @param when {int} the number of milliseconds to wait until the fn + * is executed. + * @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 + * an array [myarray]. + * @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 + * stop the timer. + */ + later = function(when, o, fn, data, periodic) { + when = when || 0; + o = o || {}; + var m=fn, d=data, f, r; + + if (L.isString(fn)) { + m = o[fn]; + } + + if (!m) { + Y.error("method undefined"); + } + + if (!L.isArray(d)) { + d = [data]; + } + + f = function() { + m.apply(o, d); + }; + + r = (periodic) ? setInterval(f, when) : setTimeout(f, when); + + return { + id: r, + interval: periodic, + cancel: function() { + if (this.interval) { + clearInterval(r); + } else { + clearTimeout(r); + } + } + }; + }; + + Y.later = later; + L.later = later; + +})(); +(function() { + + // var min = ['yui-base', 'log', 'lang', 'array', 'core'], core, C = Y.config; + var min = ['yui-base'], core, C = Y.config; + + // apply the minimal required functionality + Y.use.apply(Y, min); + + + if (C.core) { + + core = C.core; + + } else { + + core = ['queue-base', 'get', 'loader']; + } + + Y.use.apply(Y, core); + + +})(); + + + +}, '3.0.0b1' );