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

📄 element-beta.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 3 页
字号:
         * @param {Object} map A key-value map containing the         * attribute's properties.         * @deprecated Use setAttributeConfig         */        register: function(key, map) {            this.setAttributeConfig(key, map);        },                        /**         * Returns the attribute's properties.         * @method getAttributeConfig         * @param {String} key The attribute's name         * @private         * @return {object} A key-value map containing all of the         * attribute's properties.         */        getAttributeConfig: function(key) {            this._configs = this._configs || {};            var config = this._configs[key] || {};            var map = {}; // returning a copy to prevent overrides                        for (key in config) {                if ( Lang.hasOwnProperty(config, key) ) {                    map[key] = config[key];                }            }                return map;        },                /**         * Sets or updates an Attribute instance's properties.          * @method setAttributeConfig         * @param {String} key The attribute's name.         * @param {Object} map A key-value map of attribute properties         * @param {Boolean} init Whether or not this should become the intial config.         */        setAttributeConfig: function(key, map, init) {            this._configs = this._configs || {};            map = map || {};            if (!this._configs[key]) {                map.name = key;                this._configs[key] = this.createAttribute(map);            } else {                this._configs[key].configure(map, init);            }        },                /**         * Sets or updates an Attribute instance's properties.          * @method configureAttribute         * @param {String} key The attribute's name.         * @param {Object} map A key-value map of attribute properties         * @param {Boolean} init Whether or not this should become the intial config.         * @deprecated Use setAttributeConfig         */        configureAttribute: function(key, map, init) {            this.setAttributeConfig(key, map, init);        },                /**         * Resets an attribute to its intial configuration.          * @method resetAttributeConfig         * @param {String} key The attribute's name.         * @private         */        resetAttributeConfig: function(key){            this._configs = this._configs || {};            this._configs[key].resetConfig();        },                // wrapper for EventProvider.subscribe        // to create events on the fly        subscribe: function(type, callback) {            this._events = this._events || {};            if ( !(type in this._events) ) {                this._events[type] = this.createEvent(type);            }            YAHOO.util.EventProvider.prototype.subscribe.apply(this, arguments);        },        on: function() {            this.subscribe.apply(this, arguments);        },        addListener: function() {            this.subscribe.apply(this, arguments);        },        /**         * Fires the attribute's beforeChange event.          * @method fireBeforeChangeEvent         * @param {String} key The attribute's name.         * @param {Obj} e The event object to pass to handlers.         */        fireBeforeChangeEvent: function(e) {            var type = 'before';            type += e.type.charAt(0).toUpperCase() + e.type.substr(1) + 'Change';            e.type = type;            return this.fireEvent(e.type, e);        },                /**         * Fires the attribute's change event.          * @method fireChangeEvent         * @param {String} key The attribute's name.         * @param {Obj} e The event object to pass to the handlers.         */        fireChangeEvent: function(e) {            e.type += 'Change';            return this.fireEvent(e.type, e);        },        createAttribute: function(map) {            return new YAHOO.util.Attribute(map, this);        }    };        YAHOO.augment(YAHOO.util.AttributeProvider, YAHOO.util.EventProvider);})();(function() {// internal shorthandvar Dom = YAHOO.util.Dom,    AttributeProvider = YAHOO.util.AttributeProvider;/** * Element provides an wrapper object to simplify adding * event listeners, using dom methods, and managing attributes.  * @module element * @namespace YAHOO.util * @requires yahoo, dom, event * @beta *//** * Element provides an wrapper object to simplify adding * event listeners, using dom methods, and managing attributes.  * @class Element * @uses YAHOO.util.AttributeProvider * @constructor * @param el {HTMLElement | String} The html element that  * represents the Element. * @param {Object} map A key-value map of initial config names and values */YAHOO.util.Element = function(el, map) {    if (arguments.length) {        this.init(el, map);    }};YAHOO.util.Element.prototype = {    /**     * Dom events supported by the Element instance.     * @property DOM_EVENTS     * @type Object     */    DOM_EVENTS: null,    /**     * Wrapper for HTMLElement method.     * @method appendChild     * @param {YAHOO.util.Element || HTMLElement} child The element to append.      * @return {HTMLElement} The appended DOM element.      */    appendChild: function(child) {        child = child.get ? child.get('element') : child;        return this.get('element').appendChild(child);    },        /**     * Wrapper for HTMLElement method.     * @method getElementsByTagName     * @param {String} tag The tagName to collect     * @return {HTMLCollection} A collection of DOM elements.      */    getElementsByTagName: function(tag) {        return this.get('element').getElementsByTagName(tag);    },        /**     * Wrapper for HTMLElement method.     * @method hasChildNodes     * @return {Boolean} Whether or not the element has childNodes     */    hasChildNodes: function() {        return this.get('element').hasChildNodes();    },        /**     * Wrapper for HTMLElement method.     * @method insertBefore     * @param {HTMLElement} element The HTMLElement to insert     * @param {HTMLElement} before The HTMLElement to insert     * the element before.     * @return {HTMLElement} The inserted DOM element.      */    insertBefore: function(element, before) {        element = element.get ? element.get('element') : element;        before = (before && before.get) ? before.get('element') : before;                return this.get('element').insertBefore(element, before);    },        /**     * Wrapper for HTMLElement method.     * @method removeChild     * @param {HTMLElement} child The HTMLElement to remove     * @return {HTMLElement} The removed DOM element.      */    removeChild: function(child) {        child = child.get ? child.get('element') : child;        return this.get('element').removeChild(child);    },        /**     * Wrapper for HTMLElement method.     * @method replaceChild     * @param {HTMLElement} newNode The HTMLElement to insert     * @param {HTMLElement} oldNode The HTMLElement to replace     * @return {HTMLElement} The replaced DOM element.      */    replaceChild: function(newNode, oldNode) {        newNode = newNode.get ? newNode.get('element') : newNode;        oldNode = oldNode.get ? oldNode.get('element') : oldNode;        return this.get('element').replaceChild(newNode, oldNode);    },        /**     * Registers Element specific attributes.     * @method initAttributes     * @param {Object} map A key-value map of initial attribute configs     */    initAttributes: function(map) {    },    /**     * Adds a listener for the given event.  These may be DOM or      * customEvent listeners.  Any event that is fired via fireEvent     * can be listened for.  All handlers receive an event object.      * @method addListener     * @param {String} type The name of the event to listen for     * @param {Function} fn The handler to call when the event fires     * @param {Any} obj A variable to pass to the handler     * @param {Object} scope The object to use for the scope of the handler      */    addListener: function(type, fn, obj, scope) {        var el = this.get('element') || this.get('id');        scope = scope || this;                var self = this;         if (!this._events[type]) { // create on the fly            if (el && this.DOM_EVENTS[type]) {                YAHOO.util.Event.addListener(el, type, function(e) {                    if (e.srcElement && !e.target) { // supplement IE with target                        e.target = e.srcElement;                    }                    self.fireEvent(type, e);                }, obj, scope);            }            this.createEvent(type, this);        }                return YAHOO.util.EventProvider.prototype.subscribe.apply(this, arguments); // notify via customEvent    },            /**     * Alias for addListener     * @method on     * @param {String} type The name of the event to listen for     * @param {Function} fn The function call when the event fires     * @param {Any} obj A variable to pass to the handler     * @param {Object} scope The object to use for the scope of the handler      */    on: function() {        return this.addListener.apply(this, arguments);    },        /**     * Alias for addListener     * @method subscribe     * @param {String} type The name of the event to listen for     * @param {Function} fn The function call when the event fires     * @param {Any} obj A variable to pass to the handler     * @param {Object} scope The object to use for the scope of the handler      */    subscribe: function() {        return this.addListener.apply(this, arguments);    },        /**     * Remove an event listener     * @method removeListener     * @param {String} type The name of the event to listen for     * @param {Function} fn The function call when the event fires     */    removeListener: function(type, fn) {        return this.unsubscribe.apply(this, arguments);    },        /**     * Wrapper for Dom method.     * @method addClass     * @param {String} className The className to add     */    addClass: function(className) {        Dom.addClass(this.get('element'), className);    },        /**     * Wrapper for Dom method.     * @method getElementsByClassName     * @param {String} className The className to collect     * @param {String} tag (optional) The tag to use in     * conjunction with class name     * @return {Array} Array of HTMLElements     */    getElementsByClassName: function(className, tag) {        return Dom.getElementsByClassName(className, tag,                this.get('element') );    },        /**     * Wrapper for Dom method.     * @method hasClass     * @param {String} className The className to add     * @return {Boolean} Whether or not the element has the class name     */    hasClass: function(className) {        return Dom.hasClass(this.get('element'), className); 

⌨️ 快捷键说明

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