⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yuiloader-debug.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 5 页
字号:
     * 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.     * @method merge     * @since 2.3.0     * @param arguments {Object*} the objects to merge     * @return the new merged object     */    merge: function() {        var o={}, a=arguments;        for (var i=0, l=a.length; i<l; i=i+1) {            L.augmentObject(o, a[i], true);        }        return o;    },    /**     * 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     * @since 2.4.0     * @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 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) {            throw new TypeError("method undefined");        }        if (!L.isArray(d)) {            d = [data];        }        f = function() {            m.apply(o, d);        };        r = (periodic) ? setInterval(f, when) : setTimeout(f, when);        return {            interval: periodic,            cancel: function() {                if (this.interval) {                    clearInterval(r);                } else {                    clearTimeout(r);                }            }        };    },        /**     * 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     * @since 2.3.0     * @param o {any} the item to test     * @return {boolean} true if it is not null/undefined/NaN || false     */    isValue: function(o) {        // return (o || o === false || o === 0 || o === ''); // Infinity failsreturn (L.isObject(o) || L.isString(o) || L.isNumber(o) || L.isBoolean(o));    }};/** * 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. * This abstraction is provided to enable hasOwnProperty for Safari 1.3.x. * There is a discrepancy between YAHOO.lang.hasOwnProperty and * Object.prototype.hasOwnProperty when the property is a primitive added to * both the instance AND prototype with the same value: * <pre> * var A = function() {}; * A.prototype.foo = 'foo'; * var a = new A(); * a.foo = 'foo'; * alert(a.hasOwnProperty('foo')); // true * alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback * </pre> * @method hasOwnProperty * @param {any} o The object being testing * @param prop {string} the name of the property to test * @return {boolean} the result */L.hasOwnProperty = (Object.prototype.hasOwnProperty) ?    function(o, prop) {        return o && o.hasOwnProperty(prop);    } : function(o, prop) {        return !L.isUndefined(o[prop]) &&                 o.constructor.prototype[prop] !== o[prop];    };// new lang winsOB.augmentObject(L, OB, true);/* * An alias for <a href="YAHOO.lang.html">YAHOO.lang</a> * @class YAHOO.util.Lang */YAHOO.util.Lang = L; /** * Same as YAHOO.lang.augmentObject, except it only applies prototype  * properties.  This is an alias for augmentProto. * @see YAHOO.lang.augmentObject * @method augment * @static * @param {Function} r  the object to receive the augmentation * @param {Function} s  the object that supplies the properties to augment * @param {String*|boolean}  arguments zero or more properties methods to  *        augment the receiver with.  If none specified, everything *        in the supplier will be used unless it would *        overwrite an existing property in the receiver.  if true *        is specified as the third parameter, all properties will *        be applied and will overwrite an existing property in *        the receiver */L.augment = L.augmentProto;/** * An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a> * @for YAHOO * @method augment * @static * @param {Function} r  the object to receive the augmentation * @param {Function} s  the object that supplies the properties to augment * @param {String*}  arguments zero or more properties methods to  *        augment the receiver with.  If none specified, everything *        in the supplier will be used unless it would *        overwrite an existing property in the receiver */YAHOO.augment = L.augmentProto;       /** * An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a> * @method extend * @static * @param {Function} subc   the object to modify * @param {Function} superc the object to inherit * @param {Object} overrides  additional properties/methods to add to the *        subclass prototype.  These will override the *        matching items obtained from the superclass if present. */YAHOO.extend = L.extend;})();YAHOO.register("yahoo", YAHOO, {version: "2.6.0", build: "1321"});/** * Provides a mechanism to fetch remote resources and * insert them into a document * @module get * @requires yahoo *//** * Fetches and inserts one or more script or link nodes into the document  * @namespace YAHOO.util * @class YAHOO.util.Get */YAHOO.util.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,             /**     * node index used to generate unique node ids     * @property nidx     * @type int     * @private     */        nidx=0,         // ridx=0,        // sandboxFrame=null,    /**     * interal property used to prevent multiple simultaneous purge      * processes     * @property purging     * @type boolean     * @private     */        purging=false,        ua=YAHOO.env.ua,                 lang=YAHOO.lang;        /**      * 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     */    var _node = function(type, attr, win) {        var w = win || window, d=w.document, n=d.createElement(type);        for (var i in attr) {            if (attr[i] && YAHOO.lang.hasOwnProperty(attr, 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     * @return {HTMLElement} the generated node     * @private     */    var _linkNode = function(url, win, charset) {        var c = charset || "utf-8";        return _node("link", {                "id":      "yui__dyn_" + (nidx++),                "type":    "text/css",                "charset": c,                "rel":     "stylesheet",                "href":    url            }, 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     * @return {HTMLElement} the generated node     * @private     */    var _scriptNode = function(url, win, charset) {        var c = charset || "utf-8";        return _node("script", {                "id":      "yui__dyn_" + (nidx++),                "type":    "text/javascript",                "charset": c,                "src":     url            }, win);    };    /**     * Returns the data payload for callback functions     * @method _returnData     * @private     */    var _returnData = function(q, msg) {        return {                tId: q.tId,                win: q.win,                data: q.data,                nodes: q.nodes,                msg: msg,                purge: function() {                    _purge(this.tId);                }            };    };    var _get = function(nId, tId) {        var q = queues[tId],            n = (lang.isString(nId)) ? q.win.document.getElementById(nId) : nId;        if (!n) {            _fail(tId, "target node not found: " + nId);        }        return n;    };    /*     * The request failed, execute fail handler with whatever     * was accomplished.  There isn't a failure case at the     * moment unless you count aborted transactions     * @method _fail     * @param id {string} the id of the request     * @private     */    var _fail = function(id, msg) {        var q = queues[id];        // execute failure callback        if (q.onFailure) {            var sc=q.scope || q.win;            q.onFailure.call(sc, _returnData(q, msg));        }    };    /**     * The request is complete, so executing the requester's callback     * @method _finish     * @param id {string} the id of the request     * @private     */    var _finish = function(id) {        var q = queues[id];        q.finished = true;        if (q.aborted) {            var msg = "transaction " + id + " was aborted";            _fail(id, msg);            return;        }        // execute success callback        if (q.onSuccess) {            var sc=q.scope || q.win;            q.onSuccess.call(sc, _returnData(q));        }    };    /**     * Timeout detected     * @method _timeout     * @param id {string} the id of the request     * @private     */    var _timeout = function(id) {        var q = queues[id];        if (q.onTimeout) {            var sc=q.context || q;            q.onTimeout.call(sc, _returnData(q));        }    };    /**     * Loads the next item for a given request     * @method _next     * @param id {string} the id of the request     * @param loaded {string} the url that was just loaded, if any     * @private     */    var _next = function(id, loaded) {        var q = queues[id];        if (q.timer) {            // Y.log('cancel timer');            q.timer.cancel();        }        if (q.aborted) {            var msg = "transaction " + id + " was aborted";            _fail(id, msg);            return;        }        if (loaded) {            q.url.shift();             if (q.varName) {                q.varName.shift();             }        } else {            // This is the first pass: make sure the url is an array            q.url = (lang.isString(q.url)) ? [q.url] : q.url;            if (q.varName) {                q.varName = (lang.isString(q.varName)) ? [q.varName] : q.varName;            }        }        var w=q.win, d=w.document, h=d.getElementsByTagName("head")[0], n;        if (q.url.length === 0) {            // Safari 2.x workaround - There is no way to know when             // a script is ready in versions of Safari prior to 3.x.            // Adding an extra node reduces the problem, but doesn't            // eliminate it completely because the browser executes

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -