?? event-debug.js
字號:
* @static * @private */ _tryPreloadAttach: function() { if (this.locked) { return false; } if (this.isIE) { // Hold off if DOMReady has not fired and check current // readyState to protect against the IE operation aborted // issue. //if (!DOMReady || "complete" !== document.readyState) { if (!DOMReady) { this.startInterval(); return false; } } 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); } // 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; // onAvailable for (i=0,len=onAvailStack.length; i<len; ++i) { item = onAvailStack[i]; if (item && !item.checkReady) { el = this.getEl(item.id); if (el) { executeItem(el, item); onAvailStack[i] = null; } else { notAvail.push(item); } } } // onContentReady for (i=0,len=onAvailStack.length; i<len; ++i) { item = onAvailStack[i]; if (item && item.checkReady) { el = this.getEl(item.id); if (el) { // The element is available, but not necessarily ready // @todo should we test parentNode.nextSibling? if (loadComplete || el.nextSibling) { executeItem(el, item); onAvailStack[i] = null; } } else { notAvail.push(item); } } } retryCount = (notAvail.length === 0) ? 0 : retryCount - 1; if (tryAgain) { // we may need to strip the nulled out items here this.startInterval(); } else { clearInterval(this._interval); this._interval = null; } this.locked = false; return true; }, /** * 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 elListeners = this.getListeners(el, sType); if (elListeners) { for (var i=0,len=elListeners.length; i<len ; ++i) { var l = elListeners[i]; // can't use the index on the changing collection this.removeListener(el, l.type, l.fn, l.index); //this.removeListener(el, l.type, l.fn); } } if (recurse && el && el.childNodes) { for (i=0,len=el.childNodes.length; i<len ; ++i) { this.purgeElement(el.childNodes[i], recurse, sType); } } }, /** * Returns all listeners attached to the given element via addListener. * Optionally, you can specify a specific type of event to return. * @method getListeners * @param el {HTMLElement} the element to inspect * @param sType {string} optional type of listener to return. If * left out, all listeners will be returned * @return {Object} the listener. Contains the following fields: * type: (string) the type of event * fn: (function) the callback supplied to addListener * obj: (object) the custom object supplied to addListener * adjust: (boolean) whether or not to adjust the default scope * index: (int) its position in the Event util listener cache * @static */ getListeners: function(el, sType) { var results=[], searchLists; if (!sType) { searchLists = [listeners, unloadListeners]; } else if (sType == "unload") { searchLists = [unloadListeners]; } else { searchLists = [listeners]; } for (var j=0;j<searchLists.length; ++j) { var searchList = searchLists[j]; if (searchList && searchList.length > 0) { for (var i=0,len=searchList.length; i<len ; ++i) { var l = searchList[i]; if ( l && l[this.EL] === el && (!sType || sType === l[this.TYPE]) ) { results.push({ type: l[this.TYPE], fn: l[this.FN], obj: l[this.OBJ], adjust: l[this.ADJ_SCOPE], index: i }); } } } } return (results.length) ? results : null; }, /** * Removes all listeners registered by pe.event. Called * automatically during the unload event. * @method _unload * @static * @private */ _unload: function(e) { var EU = YAHOO.util.Event, i, j, l, len, index; for (i=0,len=unloadListeners.length; i<len; ++i) { l = unloadListeners[i]; if (l) { var scope = window; if (l[EU.ADJ_SCOPE]) { if (l[EU.ADJ_SCOPE] === true) { scope = l[EU.OBJ]; } else { scope = l[EU.ADJ_SCOPE]; } } l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ] ); unloadListeners[i] = null; l=null; scope=null; } } unloadListeners = null; if (listeners && listeners.length > 0) { j = listeners.length; while (j) { index = j-1; l = listeners[index]; if (l) { EU.removeListener(l[EU.EL], l[EU.TYPE], l[EU.FN], index); } j = j - 1; } l=null; EU.clearCache(); } for (i=0,len=legacyEvents.length; i<len; ++i) { // dereference the element //delete legacyEvents[i][0]; legacyEvents[i][0] = null; // delete the array item //delete legacyEvents[i]; legacyEvents[i] = null; } legacyEvents = null; EU._simpleRemove(window, "unload", EU._unload); }, /** * Returns scrollLeft * @method _getScrollLeft * @static * @private */ _getScrollLeft: function() { return this._getScroll()[1]; }, /** * Returns scrollTop * @method _getScrollTop * @static * @private */ _getScrollTop: function() { return this._getScroll()[0]; }, /** * Returns the scrollTop and scrollLeft. Used to calculate the * pageX and pageY in Internet Explorer * @method _getScroll * @static * @private */ _getScroll: function() { var dd = document.documentElement, db = document.body; if (dd && (dd.scrollTop || dd.scrollLeft)) { return [dd.scrollTop, dd.scrollLeft]; } else if (db) { return [db.scrollTop, db.scrollLeft]; } else { return [0, 0]; } }, /** * Used by old versions of CustomEvent, restored for backwards * compatibility * @method regCE * @private * @static * @deprecated still here for backwards compatibility */ regCE: function() { // does nothing }, /** * Adds a DOM event directly without the caching, cleanup, scope adj, etc * * @method _simpleAdd * @param {HTMLElement} el the element to bind the handler to * @param {string} sType the type of event handler * @param {function} fn the callback to invoke * @param {boolen} capture capture or bubble phase * @static * @private */ _simpleAdd: function () { if (window.addEventListener) { return function(el, sType, fn, capture) { el.addEventListener(sType, fn, (capture)); }; } else if (window.attachEvent) { return function(el, sType, fn, capture) { el.attachEvent("on" + sType, fn); }; } else { return function(){}; } }(), /** * Basic remove listener * * @method _simpleRemove * @param {HTMLElement} el the element to bind the handler to * @param {string} sType the type of event handler * @param {function} fn the callback to invoke * @param {boolen} capture capture or bubble phase * @static * @private */ _simpleRemove: function() { if (window.removeEventListener) { return function (el, sType, fn, capture) { el.removeEventListener(sType, fn, (capture)); }; } else if (window.detachEvent) { return function (el, sType, fn) { el.detachEvent("on" + sType, fn); }; } else { return function(){}; } }() }; }(); (function() { var EU = YAHOO.util.Event; /** * YAHOO.util.Event.on is an alias for addListener * @method on * @see addListener * @static */ EU.on = EU.addListener; ///////////////////////////////////////////////////////////// // DOMReady // based on work by: Dean Edwards/John Resig/Matthias Miller // Internet Explorer: use the readyState of a defered script. // This isolates what appears to be a safe moment to manipulate // the DOM prior to when the document's readyState suggests // it is safe to do so. if (EU.isIE) { // Process onAvailable/onContentReady items when when the // DOM is ready. YAHOO.util.Event.onDOMReady( YAHOO.util.Event._tryPreloadAttach, YAHOO.util.Event, true); //YAHOO.log("-" + document.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -