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

📄 event.js

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JS
📖 第 1 页 / 共 5 页
字号:
                        return false;                    }                }                // removed the wrapped handler                delete listeners[index][this.WFN];                delete listeners[index][this.FN];                //listeners.splice(index, 1);                listeners[index]=null;                return true;            },            /**             * Returns the event's target element.  Safari sometimes provides             * a text node, and this is automatically resolved to the text             * node's parent so that it behaves like other browsers.             * @method getTarget             * @param {Event} ev the event             * @param {boolean} resolveTextNode when set to true the target's             *                  parent will be returned if the target is a              *                  text node.  @deprecated, the text node is             *                  now resolved automatically             * @return {HTMLElement} the event's target             * @static             */            getTarget: function(ev, resolveTextNode) {                var t = ev.target || ev.srcElement;                return this.resolveTextNode(t);            },            /**             * In some cases, some browsers will return a text node inside             * the actual element that was targeted.  This normalizes the             * return value for getTarget and getRelatedTarget.             * @method resolveTextNode             * @param {HTMLElement} node node to resolve             * @return {HTMLElement} the normized node             * @static             */            resolveTextNode: function(node) {                if (node && 3 == node.nodeType) {                    return node.parentNode;                } else {                    return node;                }            },            /**             * Returns the event's pageX             * @method getPageX             * @param {Event} ev the event             * @return {int} the event's pageX             * @static             */            getPageX: function(ev) {                var x = ev.pageX;                if (!x && 0 !== x) {                    x = ev.clientX || 0;                    if ( this.isIE ) {                        x += this._getScrollLeft();                    }                }                return x;            },            /**             * Returns the event's pageY             * @method getPageY             * @param {Event} ev the event             * @return {int} the event's pageY             * @static             */            getPageY: function(ev) {                var y = ev.pageY;                if (!y && 0 !== y) {                    y = ev.clientY || 0;                    if ( this.isIE ) {                        y += this._getScrollTop();                    }                }                return y;            },            /**             * Returns the pageX and pageY properties as an indexed array.             * @method getXY             * @param {Event} ev the event             * @return {[x, y]} the pageX and pageY properties of the event             * @static             */            getXY: function(ev) {                return [this.getPageX(ev), this.getPageY(ev)];            },            /**             * Returns the event's related target              * @method getRelatedTarget             * @param {Event} ev the event             * @return {HTMLElement} the event's relatedTarget             * @static             */            getRelatedTarget: function(ev) {                var t = ev.relatedTarget;                if (!t) {                    if (ev.type == "mouseout") {                        t = ev.toElement;                    } else if (ev.type == "mouseover") {                        t = ev.fromElement;                    }                }                return this.resolveTextNode(t);            },            /**             * Returns the time of the event.  If the time is not included, the             * event is modified using the current time.             * @method getTime             * @param {Event} ev the event             * @return {Date} the time of the event             * @static             */            getTime: function(ev) {                if (!ev.time) {                    var t = new Date().getTime();                    try {                        ev.time = t;                    } catch(ex) {                         this.lastError = ex;                        return t;                    }                }                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;                    }                }                // IE events that target non-browser objects (e.g., VML                // canvas) will sometimes throw errors when you try to                // inspect the properties of the event target.  We try to                // detect this condition, and provide a dummy target (the bound                // element) to eliminate spurious errors.                  // the implementation caused unexpected results in some                 // implementations, so this has been rolled back for now                /*                 if (ev && this.isIE) {                    try {                        var el = ev.srcElement;                    } catch(ex) {                                                 ev.target = boundEl;                    }                }                */                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 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,len=listeners.length; i<len; ++i) {                    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) {                    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

⌨️ 快捷键说明

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