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

📄 event-debug.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 5 页
字号:
                }                return ev.time;            },            /**             * Convenience method for stopPropagation + preventDefault             * @method stopEvent             * @param {Event} ev the event             * @static             */            stopEvent: function(ev) {                this.stopPropagation(ev);                this.preventDefault(ev);            },            /**             * Stops event propagation             * @method stopPropagation             * @param {Event} ev the event             * @static             */            stopPropagation: function(ev) {                if (ev.stopPropagation) {                    ev.stopPropagation();                } else {                    ev.cancelBubble = true;                }            },            /**             * Prevents the default behavior of the event             * @method preventDefault             * @param {Event} ev the event             * @static             */            preventDefault: function(ev) {                if (ev.preventDefault) {                    ev.preventDefault();                } else {                    ev.returnValue = false;                }            },                         /**             * Finds the event in the window object, the caller's arguments, or             * in the arguments of another method in the callstack.  This is             * executed automatically for events registered through the event             * manager, so the implementer should not normally need to execute             * this function at all.             * @method getEvent             * @param {Event} e the event parameter from the handler             * @param {HTMLElement} boundEl the element the listener is attached to             * @return {Event} the event              * @static             */            getEvent: function(e, boundEl) {                var ev = e || window.event;                if (!ev) {                    var c = this.getEvent.caller;                    while (c) {                        ev = c.arguments[0];                        if (ev && Event == ev.constructor) {                            break;                        }                        c = c.caller;                    }                }                return ev;            },            /**             * Returns the charcode for an event             * @method getCharCode             * @param {Event} ev the event             * @return {int} the event's charCode             * @static             */            getCharCode: function(ev) {                var code = ev.keyCode || ev.charCode || 0;                // webkit key normalization                if (YAHOO.env.ua.webkit && (code in webkitKeymap)) {                    code = webkitKeymap[code];                }                return code;            },            /**             * Locating the saved event handler data by function ref             *             * @method _getCacheIndex             * @static             * @private             */            _getCacheIndex: function(el, sType, fn) {                for (var i=0, l=listeners.length; i<l; i=i+1) {                    var li = listeners[i];                    if ( li                 &&                          li[this.FN] == fn  &&                          li[this.EL] == el  &&                          li[this.TYPE] == sType ) {                        return i;                    }                }                return -1;            },            /**             * Generates an unique ID for the element if it does not already              * have one.             * @method generateId             * @param el the element to create the id for             * @return {string} the resulting id of the element             * @static             */            generateId: function(el) {                var id = el.id;                if (!id) {                    id = "yuievtautoid-" + counter;                    ++counter;                    el.id = id;                }                return id;            },            /**             * We want to be able to use getElementsByTagName as a collection             * to attach a group of events to.  Unfortunately, different              * browsers return different types of collections.  This function             * tests to determine if the object is array-like.  It will also              * fail if the object is an array, but is empty.             * @method _isValidCollection             * @param o the object to test             * @return {boolean} true if the object is array-like and populated             * @static             * @private             */            _isValidCollection: function(o) {                try {                    return ( o                     && // o is something                             typeof o !== "string" && // o is not a string                             o.length              && // o is indexed                             !o.tagName            && // o is not an HTML element                             !o.alert              && // o is not a window                             typeof o[0] !== "undefined" );                } catch(ex) {                    YAHOO.log("node access error (xframe?)", "warn");                    return false;                }            },            /**             * @private             * @property elCache             * DOM element cache             * @static             * @deprecated Elements are not cached due to issues that arise when             * elements are removed and re-added             */            elCache: {},            /**             * We cache elements bound by id because when the unload event              * fires, we can no longer use document.getElementById             * @method getEl             * @static             * @private             * @deprecated Elements are not cached any longer             */            getEl: function(id) {                return (typeof id === "string") ? document.getElementById(id) : id;            },            /**             * Clears the element cache             * @deprecated Elements are not cached any longer             * @method clearCache             * @static             * @private             */            clearCache: function() { },            /**             * Custom event the fires when the dom is initially usable             * @event DOMReadyEvent             */            DOMReadyEvent: new YAHOO.util.CustomEvent("DOMReady", this),            /**             * hook up any deferred listeners             * @method _load             * @static             * @private             */            _load: function(e) {                if (!loadComplete) {                    loadComplete = true;                    var EU = YAHOO.util.Event;                    // Just in case DOMReady did not go off for some reason                    EU._ready();                    // Available elements may not have been detected before the                    // window load event fires. Try to find them now so that the                    // the user is more likely to get the onAvailable notifications                    // before the window load notification                    EU._tryPreloadAttach();                }            },            /**             * Fires the DOMReady event listeners the first time the document is             * usable.             * @method _ready             * @static             * @private             */            _ready: function(e) {                var EU = YAHOO.util.Event;                if (!EU.DOMReady) {                    EU.DOMReady=true;                    // Fire the content ready custom event                    EU.DOMReadyEvent.fire();                    // Remove the DOMContentLoaded (FF/Opera)                    EU._simpleRemove(document, "DOMContentLoaded", EU._ready);                }            },            /**             * Polling function that runs before the onload event fires,              * attempting to attach to DOM Nodes as soon as they are              * available             * @method _tryPreloadAttach             * @static             * @private             */            _tryPreloadAttach: function() {                if (onAvailStack.length === 0) {                    retryCount = 0;                    clearInterval(this._interval);                    this._interval = null;                    return;                }                if (this.locked) {                    return;                }                if (this.isIE) {                    // Hold off if DOMReady has not fired and check current                    // readyState to protect against the IE operation aborted                    // issue.                    if (!this.DOMReady) {                        this.startInterval();                        return;                    }                }                this.locked = true;                // this.logger.debug("tryPreloadAttach");                // keep trying until after the page is loaded.  We need to                 // check the page load state prior to trying to bind the                 // elements so that we can be certain all elements have been                 // tested appropriately                var tryAgain = !loadComplete;                if (!tryAgain) {                    tryAgain = (retryCount > 0 && onAvailStack.length > 0);                }                // onAvailable                var notAvail = [];                var executeItem = function (el, item) {                    var scope = el;                    if (item.override) {                        if (item.override === true) {                            scope = item.obj;                        } else {                            scope = item.override;                        }                    }                    item.fn.call(scope, item.obj);                };                var i, len, item, el, ready=[];                // onAvailable onContentReady                for (i=0, len=onAvailStack.length; i<len; i=i+1) {                    item = onAvailStack[i];                    if (item) {                        el = this.getEl(item.id);                        if (el) {                            if (item.checkReady) {                                if (loadComplete || el.nextSibling || !tryAgain) {                                    ready.push(item);                                    onAvailStack[i] = null;                                }                            } else {                                executeItem(el, item);                                onAvailStack[i] = null;                            }                        } else {                            notAvail.push(item);                        }                    }                }                                // make sure onContentReady fires after onAvailable                for (i=0, len=ready.length; i<len; i=i+1) {                    item = ready[i];                    executeItem(this.getEl(item.id), item);                }                retryCount--;                if (tryAgain) {                    for (i=onAvailStack.length-1; i>-1; i--) {                        item = onAvailStack[i];                        if (!item || !item.id) {                            onAvailStack.splice(i, 1);                        }                    }                    this.startInterval();                } else {                    clearInterval(this._interval);                    this._interval = null;                }                this.locked = false;            },            /**             * Removes all listeners attached to the given element via addListener.             * Optionally, the node's children can also be purged.             * Optionally, you can specify a specific type of event to remove.             * @method purgeElement             * @param {HTMLElement} el the element to purge             * @param {boolean} recurse recursively purge this element's children             * as well.  Use with caution.             * @param {string} sType optional type of listener to purge. If             * left out, all listeners will be removed             * @static             */            purgeElement: function(el, recurse, sType) {                var oEl = (YAHOO.lang.isString(el)) ? this

⌨️ 快捷键说明

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