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

📄 menu.js

📁 原名JSPackager
💻 JS
📖 第 1 页 / 共 4 页
字号:
this.clearActiveItem();}this.activeItem = oItem;oItem.cfg.setProperty("selected", true);oSubmenu.show();}} else {if (oTarget.tagName != "A" && !bCurrentPageURL) {document.location = sURL;}}}switch (oTarget.tagName) {case "A":if (bCurrentPageURL) {Event.preventDefault(p_oEvent);} else {break;}default:Event.stopPropagation(p_oEvent);break;}this.clickEvent.fire(p_oEvent);};YAHOO.widget.MenuModule.prototype._onBeforeRender = function (p_sType, p_aArgs, p_oMenuModule) {var Dom = this._oDom;var oConfig = this.cfg;var oEl = this.element;var nListElements = this._aListElements.length;if (oConfig.getProperty("position") == "static") {oConfig.queueProperty("iframe", false);oConfig.queueProperty("visible", true);}if (nListElements > 0) {var i = 0;var bFirstList = true;var oUL;var oGroupTitle;do {oUL = this._aListElements[i];if (oUL) {if (bFirstList) {Dom.addClass(oUL, "first-of-type");bFirstList = false;}if (!Dom.isAncestor(oEl, oUL)) {this.appendToBody(oUL);}oGroupTitle = this._aGroupTitleElements[i];if (oGroupTitle) {if (!Dom.isAncestor(oEl, oGroupTitle)) {oUL.parentNode.insertBefore(oGroupTitle, oUL);}Dom.addClass(oUL, "hastitle");}}i++;} while (i < nListElements);}};YAHOO.widget.MenuModule.prototype._onRender = function (p_sType, p_aArgs, p_oMenuModule) {if (this.cfg.getProperty("position") == "dynamic") {var sWidth = this.element.parentNode.tagName == "BODY" ? this.element.offsetWidth : this._getOffsetWidth();this.cfg.setProperty("width", (sWidth + "px"));}};YAHOO.widget.MenuModule.prototype._onShow = function (p_sType, p_aArgs, p_oMenuModule) {this.setInitialFocus();};YAHOO.widget.MenuModule.prototype._onBeforeHide = function (p_sType, p_aArgs, p_oMenuModule) {var oActiveItem = this.activeItem;if (oActiveItem) {oActiveItem.blur();if (oActiveItem.cfg.getProperty("selected")) {oActiveItem.cfg.setProperty("selected", false);}var oSubmenu = oActiveItem.cfg.getProperty("submenu");if (oSubmenu && oSubmenu.cfg.getProperty("visible")) {oSubmenu.hide();}}};YAHOO.widget.MenuModule.prototype._onParentMenuModuleConfigChange = function (p_sType, p_aArgs, p_oSubmenu) {var sPropertyName = p_aArgs[0][0];var oPropertyValue = p_aArgs[0][1];switch (sPropertyName) {case "iframe":case "constraintoviewport":p_oSubmenu.cfg.setProperty(sPropertyName, oPropertyValue);break;}};YAHOO.widget.MenuModule.prototype._onParentMenuModuleRender = function (p_sType, p_aArgs, p_oSubmenu) {var oParentMenu = p_oSubmenu.parent.parent;p_oSubmenu.cfg.applyConfig({constraintoviewport:oParentMenu.cfg.getProperty("constraintoviewport"), xy:[0, 0], iframe:oParentMenu.cfg.getProperty("iframe")});if (this._oDom.inDocument(this.element)) {this.render();} else {this.render(this.parent.element);}};YAHOO.widget.MenuModule.prototype._onSubmenuBeforeShow = function (p_sType, p_aArgs, p_oSubmenu) {var oParent = this.parent;var aAlignment = oParent.parent.cfg.getProperty("submenualignment");this.cfg.setProperty("context", [oParent.element, aAlignment[0], aAlignment[1]]);oParent.submenuIndicator.alt = oParent.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;};YAHOO.widget.MenuModule.prototype._onSubmenuShow = function (p_sType, p_aArgs, p_oSubmenu) {var oParent = this.parent;oParent.submenuIndicator.alt = oParent.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;};YAHOO.widget.MenuModule.prototype._onSubmenuHide = function (p_sType, p_aArgs, p_oSubmenu) {var oParent = this.parent;if (oParent.parent.cfg.getProperty("visible")) {oParent.cfg.setProperty("selected", false);oParent.focus();}oParent.submenuIndicator.alt = oParent.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;};YAHOO.widget.MenuModule.prototype._onItemFocus = function (p_sType, p_aArgs, p_aObjects) {var me = p_aObjects[0];var oItem = p_aObjects[1];me.activeItem = oItem;};YAHOO.widget.MenuModule.prototype._onItemBlur = function (p_sType, p_aArgs, p_aObjects) {var me = p_aObjects[0];var oItem = p_aObjects[1];var oSubmenu = oItem.cfg.getProperty("submenu");if (!oSubmenu || (oSubmenu && !oSubmenu.cfg.getProperty("visible"))) {me.activeItem = null;}};YAHOO.widget.MenuModule.prototype._onItemConfigChange = function (p_sType, p_aArgs, p_aObjects) {var me = p_aObjects[0];var sProperty = p_aArgs[0][0];var oItem = p_aObjects[1];switch (sProperty) {case "submenu":var oSubmenu = p_aArgs[0][1];if (oSubmenu) {me._configureItemSubmenuModule(oItem);}break;case "text":case "helptext":if (me.element.style.width) {var sWidth = me._getOffsetWidth() + "px";me._oDom.setStyle(me.element, "width", sWidth);}break;}};YAHOO.widget.MenuModule.prototype.enforceConstraints = function (type, args, obj) {var Dom = this._oDom;var oConfig = this.cfg;var pos = args[0];var x = pos[0];var y = pos[1];var bod = document.getElementsByTagName("body")[0];var htm = document.getElementsByTagName("html")[0];var bodyOverflow = Dom.getStyle(bod, "overflow");var htmOverflow = Dom.getStyle(htm, "overflow");var offsetHeight = this.element.offsetHeight;var offsetWidth = this.element.offsetWidth;var viewPortWidth = Dom.getClientWidth();var viewPortHeight = Dom.getClientHeight();var scrollX = window.scrollX || document.body.scrollLeft;var scrollY = window.scrollY || document.body.scrollTop;var topConstraint = scrollY + 10;var leftConstraint = scrollX + 10;var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;var aContext = oConfig.getProperty("context");var oContextElement = aContext ? aContext[0] : null;if (x < 10) {x = leftConstraint;} else {if ((x + offsetWidth) > viewPortWidth) {if (oContextElement && ((x - oContextElement.offsetWidth) > offsetWidth)) {x = (x - (oContextElement.offsetWidth + offsetWidth));} else {x = rightConstraint;}}}if (y < 10) {y = topConstraint;} else {if (y > bottomConstraint) {if (oContextElement && (y > offsetHeight)) {y = ((y + oContextElement.offsetHeight) - offsetHeight);} else {y = bottomConstraint;}}}oConfig.setProperty("x", x, true);oConfig.setProperty("y", y, true);};YAHOO.widget.MenuModule.prototype.configPosition = function (p_sType, p_aArgs, p_oMenuModule) {var sCSSPosition = p_aArgs[0] == "static" ? "static" : "absolute";this._oDom.setStyle(this.element, "position", sCSSPosition);};YAHOO.widget.MenuModule.prototype.toString = function () {return ("Menu " + this.id);};YAHOO.widget.MenuModule.prototype.setItemGroupTitle = function (p_sGroupTitle, p_nGroupIndex) {if (typeof p_sGroupTitle == "string" && p_sGroupTitle.length > 0) {var Dom = this._oDom;var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0;var oTitle = this._aGroupTitleElements[nGroupIndex];if (oTitle) {oTitle.innerHTML = p_sGroupTitle;} else {oTitle = document.createElement(this.GROUP_TITLE_TAG_NAME);oTitle.innerHTML = p_sGroupTitle;this._aGroupTitleElements[nGroupIndex] = oTitle;}var i = this._aGroupTitleElements.length - 1;var nFirstIndex;do {if (this._aGroupTitleElements[i]) {Dom.removeClass(this._aGroupTitleElements[i], "first-of-type");nFirstIndex = i;}} while (i--);if (nFirstIndex !== null) {Dom.addClass(this._aGroupTitleElements[nFirstIndex], "first-of-type");}}};YAHOO.widget.MenuModule.prototype.addItem = function (p_oItem, p_nGroupIndex) {if (p_oItem) {return this._addItemToGroup(p_nGroupIndex, p_oItem);}};YAHOO.widget.MenuModule.prototype.insertItem = function (p_oItem, p_nItemIndex, p_nGroupIndex) {if (p_oItem) {return this._addItemToGroup(p_nGroupIndex, p_oItem, p_nItemIndex);}};YAHOO.widget.MenuModule.prototype.removeItem = function (p_oObject, p_nGroupIndex) {if (typeof p_oObject != "undefined") {var oItem;if (p_oObject instanceof YAHOO.widget.MenuModuleItem) {oItem = this._removeItemFromGroupByValue(p_nGroupIndex, p_oObject);} else {if (typeof p_oObject == "number") {oItem = this._removeItemFromGroupByIndex(p_nGroupIndex, p_oObject);}}if (oItem) {oItem.destroy();return oItem;}}};YAHOO.widget.MenuModule.prototype.getItemGroups = function () {return this._aItemGroups;};YAHOO.widget.MenuModule.prototype.getItem = function (p_nItemIndex, p_nGroupIndex) {if (typeof p_nItemIndex == "number") {var aGroup = this._getItemGroup(p_nGroupIndex);if (aGroup) {return aGroup[p_nItemIndex];}}};YAHOO.widget.MenuModule.prototype.destroy = function () {this._oEventUtil.purgeElement(this.element);this.mouseOverEvent.unsubscribeAll();this.mouseOutEvent.unsubscribeAll();this.mouseDownEvent.unsubscribeAll();this.mouseUpEvent.unsubscribeAll();this.clickEvent.unsubscribeAll();this.keyPressEvent.unsubscribeAll();this.keyDownEvent.unsubscribeAll();this.keyUpEvent.unsubscribeAll();this.beforeMoveEvent.unsubscribeAll();var nItemGroups = this._aItemGroups.length;var nItems;var oItemGroup;var oItem;var i;var n;if (nItemGroups > 0) {i = nItemGroups - 1;do {oItemGroup = this._aItemGroups[i];if (oItemGroup) {nItems = oItemGroup.length;if (nItems > 0) {n = nItems - 1;do {oItem = this._aItemGroups[i][n];if (oItem) {oItem.destroy();}} while (n--);}}} while (i--);}YAHOO.widget.MenuModule.superclass.destroy.call(this);};YAHOO.widget.MenuModule.prototype.setInitialFocus = function () {var oItem = this._getFirstEnabledItem();if (oItem) {oItem.focus();}};YAHOO.widget.MenuModule.prototype.setInitialSelection = function () {var oItem = this._getFirstEnabledItem();if (oItem) {oItem.cfg.setProperty("selected", true);}};YAHOO.widget.MenuModule.prototype.clearActiveItem = function () {if (this.activeItem) {var oConfig = this.activeItem.cfg;oConfig.setProperty("selected", false);var oSubmenu = oConfig.getProperty("submenu");if (oSubmenu) {oSubmenu.hide();}}};YAHOO.widget.MenuModule.prototype.initDefaultConfig = function () {YAHOO.widget.MenuModule.superclass.initDefaultConfig.call(this);var oConfig = this.cfg;oConfig.addProperty("position", {value:"dynamic", handler:this.configPosition, validator:this._checkPosition});oConfig.refireEvent("position");oConfig.addProperty("submenualignment", {value:["tl", "tr"]});};YAHOO.widget.MenuModuleItem = function (p_oObject, p_oConfig) {if (p_oObject) {this.init(p_oObject, p_oConfig);}};YAHOO.widget.MenuModuleItem.prototype = {SUBMENU_INDICATOR_IMAGE_PATH:"nt/ic/ut/alt1/menuarorght8_nrm_1.gif", SELECTED_SUBMENU_INDICATOR_IMAGE_PATH:"nt/ic/ut/alt1/menuarorght8_hov_1.gif", DISABLED_SUBMENU_INDICATOR_IMAGE_PATH:"nt/ic/ut/alt1/menuarorght8_dim_1.gif", COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT:"Collapsed.  Click to expand.", EXPANDED_SUBMENU_INDICATOR_ALT_TEXT:"Expanded.  Click to collapse.", DISABLED_SUBMENU_INDICATOR_ALT_TEXT:"Disabled.", CSS_CLASS_NAME:"yuimenuitem", SUBMENU_TYPE:null, SUBMENU_ITEM_TYPE:null, IMG_ROOT:"http://us.i1.yimg.com/us.yimg.com/i/", IMG_ROOT_SSL:"https://a248.e.akamai.net/sec.yimg.com/i/", _oAnchor:null, _oText:null, _oHelpTextEM:null, _oSubmenu:null, _oDom:YAHOO.util.Dom, constructor:YAHOO.widget.MenuModuleItem, imageRoot:null, isSecure:YAHOO.widget.Module.prototype.isSecure, index:null, groupIndex:null, parent:null, element:null, srcElement:null, value:null, submenuIndicator:null, browser:YAHOO.widget.Module.prototype.browser, destroyEvent:null, mouseOverEvent:null, mouseOutEvent:null, mouseDownEvent:null, mouseUpEvent:null, clickEvent:null, keyPressEvent:null, keyDownEvent:null, keyUpEvent:null, focusEvent:null, blurEvent:null, init:function (p_oObject, p_oConfig) {this.imageRoot = (this.isSecure) ? this.IMG_ROOT_SSL : this.IMG_ROOT;if (!this.SUBMENU_TYPE) {this.SUBMENU_TYPE = YAHOO.widget.MenuModule;}if (!this.SUBMENU_ITEM_TYPE) {this.SUBMENU_ITEM_TYPE = YAHOO.widget.MenuModuleItem;}this.cfg = new YAHOO.util.Config(this);this.initDefaultConfig();var oConfig = this.cfg;if (this._checkString(p_oObject)) {this._createRootNodeStructure();oConfig.setProperty("text", p_oObject);} else {if (this._checkDOMNode(p_oObject)) {switch (p_oObject.tagName) {case "OPTION":this._createRootNodeStructure();oConfig.setProperty("text", p_oObject.text);this.srcElement = p_oObject;break;case "OPTGROUP":this._createRootNodeStructure();oConfig.setProperty("text", p_oObject.label);this.srcElement = p_oObject;this._initSubTree();break;case "LI":var oAnchor = this._getFirstElement(p_oObject, "A");var sURL = "#";var sText = null;if (oAnchor) {sURL = oAnchor.getAttribute("href");if (oAnchor.innerText) {sText = oAnchor.innerText;} else {var oRange = oAnchor.ownerDocument.createRange();oRange.selectNodeContents(oAnchor);sText = oRange.toString();}} else {var oText = p_oObject.firstChild;sText = oText.nodeValue;oAnchor = document.createElement("a");oAnchor.setAttribute("href", sURL);p_oObject.replaceChild(oAnchor, oText);oAnchor.appendChild(oText);}this.srcElement = p_oObject;this.element = p_oObject;this._oAnchor = oAnchor;var oEmphasisNode = this._getFirstElement(oAnchor);var bEmphasis = false;var bStrongEmphasis = false;if (oEmphasisNode) {this._oText = oEmphasisNode.firstChild;switch (oEmphasisNode.tagName) {case "EM":bEmphasis = true;break;case "STRONG":bStrongEmphasis = true;break;}} else {this._oText = oAnchor.firstChild;}oConfig.setProperty("text", sText, true);oConfig.setProperty("url", sURL, true);oConfig.setProperty("emphasis", bEmphasis, true);oConfig.setProperty("strongemphasis", bStrongEmphasis, true);this._initSubTree();break;}}}if (this.element) {this._oDom.addClass(this.element, this.CSS_CLASS_NAME);var CustomEvent = YAHOO.util.CustomEvent;this.destroyEvent = new CustomEvent("destroyEvent", this);

⌨️ 快捷键说明

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