📄 menu-debug.js
字号:
this._configureSubmenu(oGroupItem); if (nItemIndex === 0) { Dom.addClass(oGroupItem.element, _FIRST_OF_TYPE); } YAHOO.log("Item added." + " Text: " + oGroupItem.cfg.getProperty("text") + ", " + " Index: " + oGroupItem.index + ", " + " Group Index: " + oGroupItem.groupIndex, "info", this.toString()); this.itemAddedEvent.fire(oGroupItem); this.changeContentEvent.fire(); returnVal = oGroupItem; } } } return returnVal; },/*** @method _removeItemFromGroupByIndex* @description Removes a menu item from a group by index. Returns the menu * item that was removed.* @private* @param {Number} p_nGroupIndex Number indicating the group to which the menu * item belongs.* @param {Number} p_nItemIndex Number indicating the index of the menu item * to be removed.* @return {YAHOO.widget.MenuItem}*/_removeItemFromGroupByIndex: function (p_nGroupIndex, p_nItemIndex) { var nGroupIndex = Lang.isNumber(p_nGroupIndex) ? p_nGroupIndex : 0, aGroup = this._getItemGroup(nGroupIndex), aArray, oItem, oUL; if (aGroup) { aArray = aGroup.splice(p_nItemIndex, 1); oItem = aArray[0]; if (oItem) { // Update the index and className properties of each member this._updateItemProperties(nGroupIndex); if (aGroup.length === 0) { // Remove the UL oUL = this._aListElements[nGroupIndex]; if (this.body && oUL) { this.body.removeChild(oUL); } // Remove the group from the array of items this._aItemGroups.splice(nGroupIndex, 1); // Remove the UL from the array of ULs this._aListElements.splice(nGroupIndex, 1); /* Assign the "first-of-type" class to the new first UL in the collection */ oUL = this._aListElements[0]; if (oUL) { Dom.addClass(oUL, _FIRST_OF_TYPE); } } this.itemRemovedEvent.fire(oItem); this.changeContentEvent.fire(); } } // Return a reference to the item that was removed return oItem; },/*** @method _removeItemFromGroupByValue* @description Removes a menu item from a group by reference. Returns the * menu item that was removed.* @private* @param {Number} p_nGroupIndex Number indicating the group to which the* menu item belongs.* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem * instance to be removed.* @return {YAHOO.widget.MenuItem}*/ _removeItemFromGroupByValue: function (p_nGroupIndex, p_oItem) { var aGroup = this._getItemGroup(p_nGroupIndex), nItems, nItemIndex, returnVal, i; if (aGroup) { nItems = aGroup.length; nItemIndex = -1; if (nItems > 0) { i = nItems-1; do { if (aGroup[i] == p_oItem) { nItemIndex = i; break; } } while (i--); if (nItemIndex > -1) { returnVal = this._removeItemFromGroupByIndex(p_nGroupIndex, nItemIndex); } } } return returnVal;},/*** @method _updateItemProperties* @description Updates the "index," "groupindex," and "className" properties * of the menu items in the specified group. * @private* @param {Number} p_nGroupIndex Number indicating the group of items to update.*/_updateItemProperties: function (p_nGroupIndex) { var aGroup = this._getItemGroup(p_nGroupIndex), nItems = aGroup.length, oItem, oLI, i; if (nItems > 0) { i = nItems - 1; // Update the index and className properties of each member do { oItem = aGroup[i]; if (oItem) { oLI = oItem.element; oItem.index = i; oItem.groupIndex = p_nGroupIndex; oLI.setAttribute(_GROUP_INDEX, p_nGroupIndex); oLI.setAttribute(_INDEX, i); Dom.removeClass(oLI, _FIRST_OF_TYPE); } } while (i--); if (oLI) { Dom.addClass(oLI, _FIRST_OF_TYPE); } }},/*** @method _createItemGroup* @description Creates a new menu item group (array) and its associated * <code><ul></code> element. Returns an aray of menu item groups.* @private* @param {Number} p_nIndex Number indicating the group to create.* @return {Array}*/_createItemGroup: function (p_nIndex) { var oUL, returnVal; if (!this._aItemGroups[p_nIndex]) { this._aItemGroups[p_nIndex] = []; oUL = document.createElement(_UL_LOWERCASE); this._aListElements[p_nIndex] = oUL; returnVal = this._aItemGroups[p_nIndex]; } return returnVal;},/*** @method _getItemGroup* @description Returns the menu item group at the specified index.* @private* @param {Number} p_nIndex Number indicating the index of the menu item group * to be retrieved.* @return {Array}*/_getItemGroup: function (p_nIndex) { var nIndex = Lang.isNumber(p_nIndex) ? p_nIndex : 0, aGroups = this._aItemGroups, returnVal; if (nIndex in aGroups) { returnVal = aGroups[nIndex]; } return returnVal;},/*** @method _configureSubmenu* @description Subscribes the menu item's submenu to its parent menu's events.* @private* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem * instance with the submenu to be configured.*/_configureSubmenu: function (p_oItem) { var oSubmenu = p_oItem.cfg.getProperty(_SUBMENU); if (oSubmenu) { /* Listen for configuration changes to the parent menu so they they can be applied to the submenu. */ this.cfg.configChangedEvent.subscribe(this._onParentMenuConfigChange, oSubmenu, true); this.renderEvent.subscribe(this._onParentMenuRender, oSubmenu, true); }},/*** @method _subscribeToItemEvents* @description Subscribes a menu to a menu item's event.* @private* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem * instance whose events should be subscribed to.*/_subscribeToItemEvents: function (p_oItem) { p_oItem.destroyEvent.subscribe(this._onMenuItemDestroy, p_oItem, this); p_oItem.cfg.configChangedEvent.subscribe(this._onMenuItemConfigChange, p_oItem, this);},/*** @method _onVisibleChange* @description Change event handler for the the menu's "visible" configuration* property.* @private* @param {String} p_sType String representing the name of the event that * was fired.* @param {Array} p_aArgs Array of arguments sent when the event was fired.*/_onVisibleChange: function (p_sType, p_aArgs) { var bVisible = p_aArgs[0]; if (bVisible) { Dom.addClass(this.element, _VISIBLE); } else { Dom.removeClass(this.element, _VISIBLE); }},/*** @method _cancelHideDelay* @description Cancels the call to "hideMenu."* @private*/_cancelHideDelay: function () { var oTimer = this.getRoot()._hideDelayTimer; if (oTimer) { oTimer.cancel(); }},/*** @method _execHideDelay* @description Hides the menu after the number of milliseconds specified by * the "hidedelay" configuration property.* @private*/_execHideDelay: function () { this._cancelHideDelay(); var oRoot = this.getRoot(); oRoot._hideDelayTimer = Lang.later(oRoot.cfg.getProperty(_HIDE_DELAY), this, function () { if (oRoot.activeItem) { if (oRoot.hasFocus()) { oRoot.activeItem.focus(); } oRoot.clearActiveItem(); } if (oRoot == this && !(this instanceof YAHOO.widget.MenuBar) && this.cfg.getProperty(_POSITION) == _DYNAMIC) { this.hide(); } });},/*** @method _cancelShowDelay* @description Cancels the call to the "showMenu."* @private*/_cancelShowDelay: function () { var oTimer = this.getRoot()._showDelayTimer; if (oTimer) { oTimer.cancel(); }},/*** @method _execSubmenuHideDelay* @description Hides a submenu after the number of milliseconds specified by * the "submenuhidedelay" configuration property have ellapsed.* @private* @param {YAHOO.widget.Menu} p_oSubmenu Object specifying the submenu that * should be hidden.* @param {Number} p_nMouseX The x coordinate of the mouse when it left * the specified submenu's parent menu item.* @param {Number} p_nHideDelay The number of milliseconds that should ellapse* before the submenu is hidden.*/_execSubmenuHideDelay: function (p_oSubmenu, p_nMouseX, p_nHideDelay) { p_oSubmenu._submenuHideDelayTimer = Lang.later(50, this, function () { if (this._nCurrentMouseX > (p_nMouseX + 10)) { p_oSubmenu._submenuHideDelayTimer = Lang.later(p_nHideDelay, p_oSubmenu, function () { this.hide(); }); } else { p_oSubmenu.hide(); } });},// Protected methods/*** @method _disableScrollHeader* @description Disables the header used for scrolling the body of the menu.* @protected*/_disableScrollHeader: function () { if (!this._bHeaderDisabled) { Dom.addClass(this.header, _TOP_SCROLLBAR_DISABLED); this._bHeaderDisabled = true; }},/*** @method _disableScrollFooter* @description Disables the footer used for scrolling the body of the menu.* @protected*/_disableScrollFooter: function () { if (!this._bFooterDisabled) { Dom.addClass(this.footer, _BOTTOM_SCROLLBAR_DISABLED); this._bFooterDisabled = true; }},/*** @method _enableScrollHeader* @description Enables the header used for scrolling the body of the menu.* @protected*/_enableScrollHeader: function () { if (this._bHeaderDisabled) { Dom.removeClass(this.header, _TOP_SCROLLBAR_DISABLED); this._bHeaderDisabled = false; }},/*** @method _enableScro
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -