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

📄 menu-debug.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 5 页
字号:
                YAHOO.log(p_oMenuItem + " successfully unregistered.", "info", _MENUMANAGER);                }        }                /**        * @method onItemAdded        * @description "itemadded" event handler for a Menu instance.        * @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.        */        function onItemAdded(p_sType, p_aArgs) {                var oItem = p_aArgs[0],                sId;                if (oItem instanceof YAHOO.widget.MenuItem) {                     sId = oItem.id;                        if (!m_oItems[sId]) {                                m_oItems[sId] = oItem;                            oItem.destroyEvent.subscribe(onItemDestroy);                            YAHOO.log(oItem + " successfully registered.", "info", _MENUMANAGER);                        }                }                }                return {                // Privileged methods                    /**            * @method addMenu            * @description Adds a menu to the collection of known menus.            * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu              * instance to be added.            */            addMenu: function (p_oMenu) {                    var oDoc;                    if (p_oMenu instanceof YAHOO.widget.Menu && p_oMenu.id &&                     !m_oMenus[p_oMenu.id]) {                            m_oMenus[p_oMenu.id] = p_oMenu;                                                if (!m_bInitializedEventHandlers) {                                    oDoc = document;                                        Event.on(oDoc, _MOUSEOVER, onDOMEvent, this, true);                        Event.on(oDoc, _MOUSEOUT, onDOMEvent, this, true);                        Event.on(oDoc, _MOUSEDOWN, onDOMEvent, this, true);                        Event.on(oDoc, _MOUSEUP, onDOMEvent, this, true);                        Event.on(oDoc, _CLICK, onDOMEvent, this, true);                        Event.on(oDoc, _KEYDOWN, onDOMEvent, this, true);                        Event.on(oDoc, _KEYUP, onDOMEvent, this, true);                        Event.on(oDoc, _KEYPRESS, onDOMEvent, this, true);    						Event.onFocus(oDoc, onDOMEvent, this, true);						Event.onBlur(oDoc, onDOMEvent, this, true);						                            m_bInitializedEventHandlers = true;                                                YAHOO.log("DOM event handlers initialized.", "info", _MENUMANAGER);                                }                                p_oMenu.cfg.subscribeToConfigEvent(_VISIBLE, onMenuVisibleConfigChange);                    p_oMenu.destroyEvent.subscribe(onMenuDestroy, p_oMenu, this);                    p_oMenu.itemAddedEvent.subscribe(onItemAdded);                    p_oMenu.focusEvent.subscribe(onMenuFocus);                    p_oMenu.blurEvent.subscribe(onMenuBlur);                    p_oMenu.showEvent.subscribe(onMenuShow);                            YAHOO.log(p_oMenu + " successfully registered.", "info", _MENUMANAGER);                        }                    },                        /**            * @method removeMenu            * @description Removes a menu from the collection of known menus.            * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu              * instance to be removed.            */            removeMenu: function (p_oMenu) {                    var sId,                    aItems,                    i;                        if (p_oMenu) {                        sId = p_oMenu.id;                            if ((sId in m_oMenus) && (m_oMenus[sId] == p_oMenu)) {                        // Unregister each menu item                        aItems = p_oMenu.getItems();                        if (aItems && aItems.length > 0) {                            i = aItems.length - 1;                            do {                                removeItem(aItems[i]);                            }                            while (i--);                        }                        // Unregister the menu                        delete m_oMenus[sId];                                    YAHOO.log(p_oMenu + " successfully unregistered.", "info", _MENUMANAGER);                                /*                             Unregister the menu from the collection of                              visible menus                        */                        if ((sId in m_oVisibleMenus) && (m_oVisibleMenus[sId] == p_oMenu)) {                                        delete m_oVisibleMenus[sId];                                                        YAHOO.log(p_oMenu + " unregistered from the" +                                         " collection of visible menus.", "info", _MENUMANAGER);                               }                        // Unsubscribe event listeners                        if (p_oMenu.cfg) {                            p_oMenu.cfg.unsubscribeFromConfigEvent(_VISIBLE,                                 onMenuVisibleConfigChange);                                                    }                        p_oMenu.destroyEvent.unsubscribe(onMenuDestroy,                             p_oMenu);                                        p_oMenu.itemAddedEvent.unsubscribe(onItemAdded);                        p_oMenu.focusEvent.unsubscribe(onMenuFocus);                        p_oMenu.blurEvent.unsubscribe(onMenuBlur);                    }                                }                },                            /**            * @method hideVisible            * @description Hides all visible, dynamically positioned menus             * (excluding instances of YAHOO.widget.MenuBar).            */            hideVisible: function () {                        var oMenu;                        for (var i in m_oVisibleMenus) {                            if (Lang.hasOwnProperty(m_oVisibleMenus, i)) {                                oMenu = m_oVisibleMenus[i];                                if (!(oMenu instanceof YAHOO.widget.MenuBar) &&                             oMenu.cfg.getProperty(_POSITION) == _DYNAMIC) {                                    oMenu.hide();                                }                            }                        }                        },            /**            * @method getVisible            * @description Returns a collection of all visible menus registered            * with the menu manger.            * @return {Object}            */            getVisible: function () {                            return m_oVisibleMenus;                        },                /**            * @method getMenus            * @description Returns a collection of all menus registered with the             * menu manger.            * @return {Object}            */            getMenus: function () {                    return m_oMenus;                        },                    /**            * @method getMenu            * @description Returns a menu with the specified id.            * @param {String} p_sId String specifying the id of the             * <code>&#60;div&#62;</code> element representing the menu to            * be retrieved.            * @return {YAHOO.widget.Menu}            */            getMenu: function (p_sId) {                                var returnVal;                                if (p_sId in m_oMenus) {                					returnVal = m_oMenus[p_sId];								}                        	return returnVal;                        },                    /**            * @method getMenuItem            * @description Returns a menu item with the specified id.            * @param {String} p_sId String specifying the id of the             * <code>&#60;li&#62;</code> element representing the menu item to            * be retrieved.            * @return {YAHOO.widget.MenuItem}            */            getMenuItem: function (p_sId) {        			var returnVal;        			if (p_sId in m_oItems) {    					returnVal = m_oItems[p_sId];								}								return returnVal;                        },            /**            * @method getMenuItemGroup            * @description Returns an array of menu item instances whose             * corresponding <code>&#60;li&#62;</code> elements are child             * nodes of the <code>&#60;ul&#62;</code> element with the             * specified id.            * @param {String} p_sId String specifying the id of the             * <code>&#60;ul&#62;</code> element representing the group of             * menu items to be retrieved.            * @return {Array}            */            getMenuItemGroup: function (p_sId) {                var oUL = Dom.get(p_sId),                    aItems,                    oNode,                    oItem,                    sId,                    returnVal;                    if (oUL && oUL.tagName && oUL.tagName.toUpperCase() == _UL) {                    oNode = oUL.firstChild;                    if (oNode) {                        aItems = [];                                                do {                            sId = oNode.id;                            if (sId) {                                                            oItem = this.getMenuItem(sId);                                                                if (oItem) {                                                                    aItems[aItems.length] = oItem;                                                                }                                                        }                                                }                        while ((oNode = oNode.nextSibling));                        if (aItems.length > 0) {                            returnVal = aItems;                                                }                    }                                }				return returnVal;                        },                /**            * @method getFocusedMenuItem            * @description Returns a reference to the menu item that currently             * has focus.            * @return {YAHOO.widget.MenuItem}            */            getFocusedMenuItem: function () {                    return m_oFocusedMenuItem;                },                    /**            * @method getFocusedMenu            * @description Returns a reference to the menu that currently             * has focus.            * @return {YAHOO.widget.Menu}            */            getFocusedMenu: function () {				var returnVal;                    if (m_oFocusedMenuItem) {                        returnVal = m_oFocusedMenuItem.parent.getRoot();                                }        			return returnVal;                },                        /**            * @method toString            * @description Returns a string representing the menu manager.            * @return {String}            */            toString: function () {                            return _MENUMANAGER;                        }            };        }();})();(function () {	var Lang = YAHOO.lang,	// String constants			_MENU = "Menu",		_DIV_UPPERCASE = "DIV",		_DIV_LOWERCASE = "div",		_ID = "id",		_SELECT = "SELECT",		_XY = "xy",		_Y = "y",		_UL_UPPERCASE = "UL",		_UL_LOWERCASE = "ul",		_FIRST_OF_TYPE = "first-of-type",		_LI = "LI",		_OPTGROUP = "OPTGROUP",		_OPTION = "OPTION",		_DISABLED = "disabled",		_NONE = "none",		_SELECTED = "selected",		_GROUP_INDEX = "groupindex",		_INDEX = "index",		_SUBMENU = "submenu",		_VISIBLE = "visible",		_HIDE_DELAY = "hidedelay",		_POSITION = "position",		_DYNAMIC = "dynamic",		_STATIC = "static",		_DYNAMIC_STATIC = _DYNAMIC + "," + _STATIC,		_WINDOWS = "windows",		_URL = "url",		_HASH = "#",		_TARGET = "target",		_MAX_HEIGHT = "maxheight",        _TOP_SCROLLBAR = "topscrollbar",        _BOTTOM_SCROLLBAR = "bottomscrollbar",        _UNDERSCORE = "_",		_TOP_SCROLLBAR_DISABLED = _TOP_SCROLLBAR + _UNDERSCORE + _DISABLED,		_BOTTOM_SCROLLBAR_DISABLED = _BOTTOM_SCROLLBAR + _UNDERSCORE + _DISABLED,		_MOUSEMOVE = "mousemove",		_SHOW_DELAY = "showdelay",		_SUBMENU_HIDE_DELAY = "submenuhidedelay",		_IFRAME = "iframe",		_CONSTRAIN_TO_VIEWPORT = "constraintoviewport",		_PREVENT_CONTEXT_OVERLAP = "preventcontextoverlap",		_SUBMENU_ALIGNMENT = "submenualignment",		_AUTO_SUBMENU_DISPLAY = "autosubmenudisplay",		_CLICK_TO_HIDE = "clicktohide",		_CONTAINER = "container",		_SCROLL_INCREMENT = "scrollincrement",		_MIN_SCROLL_HEIGHT = "minscrollheight",		_CLASSNAME = "classname",		_SHADOW = "shadow",		_KEEP_OPEN = "keepopen",		_HD = "hd",		_HAS_TITLE = "hastitle",		_CONTEXT = "context",		_EMPTY_STRING = "",		_MOUSEDOWN = "mousedown",		_KEYDOWN = "keydown",		_HEIGHT = "height",		_WIDTH = "width",		_PX = "px",		_EFFECT = "effect",		_MONITOR_RESIZE = "monitorresize",		_DISPLAY = "display",		_BLOCK = "block",		_VISIBILITY = "visibility",		_ABSOLUTE = "absolute",		_ZINDEX = "zindex",		_YUI_MENU_BODY_SCROLLED = "yui-menu-body-scrolled",		_NON_BREAKING_SPACE = "&#32;",		_SPACE = " ",		_MOUSEOVER = "mouseover",		_MOUSEOUT = "mouseout",        _ITEM_ADDED = "itemAdded",        _ITEM_REMOVED = "itemRemoved",        _HIDDEN = "hidden",        _YUI_MENU_SHADOW = "yui-menu-shadow",        _YUI_MENU_SHADOW_VISIBLE = _YUI_MENU_SHADOW + "-visible",        _YUI_MENU_SHADOW_YUI_MENU_SHADOW_VISIBLE = _YUI_MENU_SHADOW + _SPACE + _YUI_MENU_SHADOW_VISIBLE;/*** The Menu class creates a container that holds a vertical list representing * a set of options or commands.  Menu is the base class for all * menu containers. * @param {String} p_oElement String specifying the id attribute of the * <code>&#60;div&#62;</code> element of the menu.* @param {String} p_oElement String specifying the id attribute of the * <code>&#60;select&#62;</code> element to be used as the data source * for the menu.* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/* level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object * specifying the <code>&#60;div&#62;</code> element of the menu.* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/* level-one-html.html#ID-94282980">HTMLSelectElement</a>} p_oElement * Object specifying the <code>&#60;select&#62;</code> element to be used as * the data source for the menu.* @param {Object} p_oConfig Optional. Object literal specifying the * configuration for the menu. See configuration class documentation for * more details.* @namespace YAHOO.widget* @class Menu* @constructor* @extends YAHOO.widget.Overlay*/YAHOO.widget.Menu = function (p_oElement, p_oConfig) {    if (p_oConfig) {        this.parent = p_oConfig.parent;        this.lazyLoad = p_oConfig.lazyLoad || p_oConfig.lazyload;        this.itemData = p_oConfig.itemData || p_oConfig.itemdata;    }    YAHOO.widget.Menu.superclass.constructor.call(this, p_oElement, p_oConfig);

⌨️ 快捷键说明

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