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

📄 event.js

📁 目录树,在脚本中可以直接调用后台java代码,动态加载数据至页面显示.
💻 JS
📖 第 1 页 / 共 5 页
字号:
    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;        /**         * True when the document is initially usable         * @property DOMReady         * @type boolean         * @static         * @private         */        var DOMReady = 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        };        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 4000@amp;10 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: 4000,            /**             * The poll interval in milliseconds             * @property POLL_INTERVAL             * @type int             * @static             * @final             */            POLL_INTERVAL: 10,            /**             * 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             * @property OBJ             * @type int             * @static             * @final             */            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,            /**             * 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,            /**             * @method startInterval             * @static             * @private             */            startInterval: function() {                if (!this._interval) {                    var self = this;                    var callback = function() { self._tryPreloadAttach(); };                    this._interval = setInterval(callback, this.POLL_INTERVAL);                }            },            /**             * Executes the supplied callback when the item with the supplied             * id is found.  This is meant to be used to execute behavior as             * soon as possible as the page loads.  If you use this after the             * initial page load it will poll for a fixed time for the element.             * The number of times it will poll and the frequency are             * configurable.  By default it will poll for 10 seconds.             *             * <p>The callback is executed with a single parameter:             * the custom object parameter, if provided.</p>             *             * @method onAvailable             *             * @param {string}   p_id the id of the element to look for.             * @param {function} p_fn what to execute when the element is found.             * @param {object}   p_obj an optional object to be passed back as             *                   a parameter to p_fn.             * @param {boolean|object}  p_override If set to true, p_fn will execute             *                   in the scope of p_obj, if set to an object it             *                   will execute in the scope of that object             *             * @static             */            onAvailable: function(p_id, p_fn, p_obj, p_override) {                onAvailStack.push( { id:         p_id,                                      fn:         p_fn,                                      obj:        p_obj,                                      override:   p_override,                                      checkReady: false    } );                retryCount = this.POLL_RETRYS;                this.startInterval();            },            /**             * Executes the supplied callback when the DOM is first usable.  This             * will execute immediately if called after the DOMReady event has             * fired.   @todo the DOMContentReady event does not fire when the             * script is dynamically injected into the page.  This means the             * DOMReady custom event will never fire in FireFox or Opera when the             * library is injected.  It _will_ fire in Safari, and the IE              * implementation would allow for us to fire it if the defered script             * is not available.  We want this to behave the same in all browsers.             * Is there a way to identify when the script has been injected              * instead of included inline?  Is there a way to know whether the              * window onload event has fired without having had a listener attached              * to it when it did so?             *             * <p>The callback is a CustomEvent, so the signature is:</p>             * <p>type <string>, args <array>, customobject <object></p>             * <p>For DOMReady events, there are no fire argments, so the             * signature is:</p>             * <p>"DOMReady", [], obj</p>             *             *             * @method onDOMReady             *             * @param {function} p_fn what to execute when the element is found.             * @param {object}   p_obj an optional object to be passed back as             *                   a parameter to p_fn.             * @param {boolean|object}  p_scope If set to true, p_fn will execute             *                   in the scope of p_obj, if set to an object it             *                   will execute in the scope of that object             *             * @static             */            onDOMReady: function(p_fn, p_obj, p_override) {                if (DOMReady) {                    setTimeout(function() {                        var s = window;                        if (p_override) {                            if (p_override === true) {                                s = p_obj;                            } else {                                s = p_override;                            }                        }                        p_fn.call(s, "DOMReady", [], p_obj);                    }, 0);                } else {                    this.DOMReadyEvent.subscribe(p_fn, p_obj, p_override);                }            },            /**             * Works the same way as onAvailable, but additionally checks the             * state of sibling elements to determine if the content of the             * available element is safe to modify.             *             * <p>The callback is executed with a single parameter:             * the custom object parameter, if provided.</p>             *

⌨️ 快捷键说明

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