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

📄 event.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 5 页
字号:
 * Returns the execution scope for this listener.  If override was set to true * the custom obj will be the scope.  If override is an object, that is the * scope, otherwise the default scope will be used. * @method getScope * @param {Object} defaultScope the scope to use if this listener does not *                              override it. */YAHOO.util.Subscriber.prototype.getScope = function(defaultScope) {    if (this.override) {        if (this.override === true) {            return this.obj;        } else {            return this.override;        }    }    return defaultScope;};/** * Returns true if the fn and obj match this objects properties. * Used by the unsubscribe method to match the right subscriber. * * @method contains * @param {Function} fn the function to execute * @param {Object} obj an object to be passed along when the event fires * @return {boolean} true if the supplied arguments match this  *                   subscriber's signature. */YAHOO.util.Subscriber.prototype.contains = function(fn, obj) {    if (obj) {        return (this.fn == fn && this.obj == obj);    } else {        return (this.fn == fn);    }};/** * @method toString */YAHOO.util.Subscriber.prototype.toString = function() {    return "Subscriber { obj: " + this.obj  +            ", override: " +  (this.override || "no") + " }";};/** * The Event Utility provides utilities for managing DOM Events and tools * for building event systems * * @module event * @title Event Utility * @namespace YAHOO.util * @requires yahoo */// The first instance of Event will win if it is loaded more than once.// @TODO this needs to be changed so that only the state data that needs to// be preserved is kept, while methods are overwritten/added as needed.// This means that the module pattern can't be used.if (!YAHOO.util.Event) {/** * The event utility provides functions to add and remove event listeners, * event cleansing.  It also tries to automatically remove listeners it * registers during the unload event. * * @class Event * @static */    YAHOO.util.Event = function() {        /**         * True after the onload event has fired         * @property loadComplete         * @type boolean         * @static         * @private         */        var loadComplete =  false;        /**         * Cache of wrapped listeners         * @property listeners         * @type array         * @static         * @private         */        var listeners = [];        /**         * User-defined unload function that will be fired before all events         * are detached         * @property unloadListeners         * @type array         * @static         * @private         */        var unloadListeners = [];        /**         * Cache of DOM0 event handlers to work around issues with DOM2 events         * in Safari         * @property legacyEvents         * @static         * @private         */        var legacyEvents = [];        /**         * Listener stack for DOM0 events         * @property legacyHandlers         * @static         * @private         */        var legacyHandlers = [];        /**         * The number of times to poll after window.onload.  This number is         * increased if additional late-bound handlers are requested after         * the page load.         * @property retryCount         * @static         * @private         */        var retryCount = 0;        /**         * onAvailable listeners         * @property onAvailStack         * @static         * @private         */        var onAvailStack = [];        /**         * Lookup table for legacy events         * @property legacyMap         * @static         * @private         */        var legacyMap = [];        /**         * Counter for auto id generation         * @property counter         * @static         * @private         */        var counter = 0;                /**         * Normalized keycodes for webkit/safari         * @property webkitKeymap         * @type {int: int}         * @private         * @static         * @final         */        var webkitKeymap = {            63232: 38, // up            63233: 40, // down            63234: 37, // left            63235: 39, // right            63276: 33, // page up            63277: 34, // page down            25: 9      // SHIFT-TAB (Safari provides a different key code in                       // this case, even though the shiftKey modifier is set)        };                // String constants used by the addFocusListener and removeFocusListener methods        var _FOCUS = YAHOO.env.ua.ie ? "focusin" : "focus";        var _BLUR = YAHOO.env.ua.ie ? "focusout" : "blur";              return {            /**             * The number of times we should look for elements that are not             * in the DOM at the time the event is requested after the document             * has been loaded.  The default is 2000@amp;20 ms, so it will poll             * for 40 seconds or until all outstanding handlers are bound             * (whichever comes first).             * @property POLL_RETRYS             * @type int             * @static             * @final             */            POLL_RETRYS: 2000,            /**             * The poll interval in milliseconds             * @property POLL_INTERVAL             * @type int             * @static             * @final             */            POLL_INTERVAL: 20,            /**             * Element to bind, int constant             * @property EL             * @type int             * @static             * @final             */            EL: 0,            /**             * Type of event, int constant             * @property TYPE             * @type int             * @static             * @final             */            TYPE: 1,            /**             * Function to execute, int constant             * @property FN             * @type int             * @static             * @final             */            FN: 2,            /**             * Function wrapped for scope correction and cleanup, int constant             * @property WFN             * @type int             * @static             * @final             */            WFN: 3,            /**             * Object passed in by the user that will be returned as a              * parameter to the callback, int constant.  Specific to             * unload listeners             * @property OBJ             * @type int             * @static             * @final             */            UNLOAD_OBJ: 3,            /**             * Adjusted scope, either the element we are registering the event             * on or the custom object passed in by the listener, int constant             * @property ADJ_SCOPE             * @type int             * @static             * @final             */            ADJ_SCOPE: 4,            /**             * The original obj passed into addListener             * @property OBJ             * @type int             * @static             * @final             */            OBJ: 5,            /**             * The original scope parameter passed into addListener             * @property OVERRIDE             * @type int             * @static             * @final             */            OVERRIDE: 6,            /**             * The original capture parameter passed into _addListener             * @property CAPTURE             * @type int             * @static             * @final             */            CAPTURE: 7,            /**             * addListener/removeListener can throw errors in unexpected scenarios.             * These errors are suppressed, the method returns false, and this property             * is set             * @property lastError             * @static             * @type Error             */            lastError: null,            /**             * Safari detection             * @property isSafari             * @private             * @static             * @deprecated use YAHOO.env.ua.webkit             */            isSafari: YAHOO.env.ua.webkit,                        /**             * webkit version             * @property webkit             * @type string             * @private             * @static             * @deprecated use YAHOO.env.ua.webkit             */            webkit: YAHOO.env.ua.webkit,                        /**             * IE detection              * @property isIE             * @private             * @static             * @deprecated use YAHOO.env.ua.ie             */            isIE: YAHOO.env.ua.ie,            /**             * poll handle             * @property _interval             * @static             * @private             */            _interval: null,            /**             * document readystate poll handle             * @property _dri             * @static             * @private             */             _dri: null,            /**             * True when the document is initially usable             * @property DOMReady             * @type boolean             * @static             */            DOMReady: false,            /**             * Errors thrown by subscribers of custom events are caught             * and the error message is written to the debug console.  If             * this property is set to true, it will also re-throw the             * error.             * @property throwErrors             * @type boolean             * @default false             */            throwErrors: false,            /**             * @method startInterval             * @static             * @private             */            startInterval: function() {                if (!this._interval) {                    var self = this;                    var callback = function() { self._tryPreloadAttach(); };                    this._interval = setInterval(callback, this.POLL_INTERVAL);                }            },

⌨️ 快捷键说明

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