fixed the resizable text area with IE problem fixed the ad space with IE problem merged the 7.2.0 and 7.1.4 change logs
2624 lines
93 KiB
HTML
2624 lines
93 KiB
HTML
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>JavaScript Documentation - menumodule.js</title>
|
|
|
|
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="header">
|
|
|
|
<h1>JavaScript Documentation</h1>
|
|
|
|
<h3><a href="./index.html">Yahoo! Menuing Library</a></h3>
|
|
|
|
|
|
|
|
<div class="breadcrumbs">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a href="./index.html">Yahoo! Menuing Library</a>
|
|
|
|
>
|
|
|
|
<strong>menumodule.js</strong>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="body">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="nav">
|
|
|
|
<div class="module resources">
|
|
|
|
<ul class="content">
|
|
|
|
<li><a href="overview-tree.html">Tree View</a></li>
|
|
|
|
<li><a href="index-all.html">Element Index</a></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="module">
|
|
|
|
<h4><a href="./allclasses-noframe.html">Classes</a></h4>
|
|
|
|
<ul class="content">
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.ContextMenu.html">
|
|
|
|
YAHOO.widget.ContextMenu</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.ContextMenuItem.html">
|
|
|
|
YAHOO.widget.ContextMenuItem</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.Menu.html">
|
|
|
|
YAHOO.widget.Menu</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.MenuBar.html">
|
|
|
|
YAHOO.widget.MenuBar</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.MenuBarItem.html">
|
|
|
|
YAHOO.widget.MenuBarItem</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.MenuItem.html">
|
|
|
|
YAHOO.widget.MenuItem</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.MenuModule.html">
|
|
|
|
YAHOO.widget.MenuModule</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.MenuModuleItem.html">
|
|
|
|
YAHOO.widget.MenuModuleItem</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="module">
|
|
|
|
<h4><a href="./overview-summary.html">Files</a></h4>
|
|
|
|
<ul class="content">
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="overview-summary-contextmenu.js.html">
|
|
|
|
contextmenu.js</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="overview-summary-contextmenuitem.js.html">
|
|
|
|
contextmenuitem.js</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="overview-summary-menu.js.html">
|
|
|
|
menu.js</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="overview-summary-menubar.js.html">
|
|
|
|
menubar.js</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="overview-summary-menubaritem.js.html">
|
|
|
|
menubaritem.js</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="overview-summary-menuitem.js.html">
|
|
|
|
menuitem.js</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="overview-summary-menumodule.js.html">
|
|
|
|
menumodule.js</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="overview-summary-menumoduleitem.js.html">
|
|
|
|
menumoduleitem.js</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="main">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>menumodule.js</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="meta">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="quick-links">
|
|
|
|
<strong>Quick Links:</strong>
|
|
|
|
|
|
|
|
<a href="#classSummary">Class Summary</a> |
|
|
|
|
|
|
|
|
<a href="#source">Source Code</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="section class summaries">
|
|
|
|
<h3><a name="classSummary">Class Summary</a> <span class="top">[<a href="#top">top</a>]</span></h3>
|
|
|
|
|
|
|
|
<div class="content">
|
|
|
|
<table border="1" cellpadding="3" cellspacing="0">
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="name">
|
|
|
|
<a href="YAHOO.widget.MenuModule.html">YAHOO.widget.MenuModule</a>
|
|
|
|
</td>
|
|
|
|
<td class="overview">The superclass of all menu containers.</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="section source">
|
|
|
|
<h3><a name="source">Souce Code</a> <span class="top">[<a href="#top">top</a>]</span></h3>
|
|
|
|
<pre class="sourceview"><span class="comment">/**
|
|
* <span class="attrib">@class</span> The superclass of all menu containers.
|
|
* <span class="attrib">@constructor</span>
|
|
* <span class="attrib">@extends</span> YAHOO.widget.Overlay
|
|
* <span class="attrib">@base</span> YAHOO.widget.Overlay
|
|
* <span class="attrib">@param</span> {String or HTMLElement} p_oElement String id or HTMLElement
|
|
* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
|
|
* <span class="attrib">@param</span> {Object} p_oConfig Optional. The configuration object literal
|
|
* containing the configuration for a MenuModule instance. See
|
|
* configuration class documentation for more details.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule = <span class="reserved">function</span>(p_oElement, p_oConfig) {
|
|
|
|
YAHOO.widget.MenuModule.superclass.constructor.call(
|
|
<span class="reserved">this</span>,
|
|
p_oElement,
|
|
p_oConfig
|
|
);
|
|
|
|
};
|
|
|
|
YAHOO.extend(YAHOO.widget.MenuModule, YAHOO.widget.Overlay);
|
|
<span class="comment">
|
|
|
|
// Private globals</span>
|
|
|
|
<span class="comment">/**
|
|
* Private global flag indicating if the DOM event handlers have been attached
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {Boolean}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule._initEventHandlers = true;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Private global collection of menus
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {Object}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule._menus = {};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Private global collection of menu items
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {Object}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule._menuItems = {};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Generic, global event handler for all of a menu's DOM-based events. This
|
|
* listens for events against the document object. If the target of a given
|
|
* event is a member of a menu or menu item's DOM, the instance's corresponding
|
|
* Custom Event is fired.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {Event} p_oEvent Event object passed back by the event
|
|
* utility (YAHOO.util.Event).
|
|
*/</span>
|
|
YAHOO.widget.MenuModule._onDOMEvent = <span class="reserved">function</span>(p_oEvent) {
|
|
<span class="comment">
|
|
|
|
// Create references to the DOM and Event utilities</span>
|
|
|
|
var Dom = YAHOO.util.Dom;
|
|
var Event = YAHOO.util.Event;
|
|
<span class="comment">
|
|
|
|
// The target node of the DOM event</span>
|
|
|
|
var oTarget = Event.getTarget(p_oEvent);
|
|
<span class="comment">
|
|
|
|
// A reference to the root LI node of a menu item</span>
|
|
|
|
var oMenuItemRootElement;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Finds the root DIV node of a menu and the root LI node of a menu item
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {HTMLElement} p_oElement An HTML element
|
|
*/</span>
|
|
<span class="reserved">function</span> getMenuRootElement(p_oElement) {
|
|
|
|
var oParentNode;
|
|
|
|
switch(p_oElement.tagName) {
|
|
|
|
case <span class="literal">"DIV"</span>:
|
|
|
|
oParentNode = p_oElement.parentNode;
|
|
<span class="comment">
|
|
// Check if the DIV is the inner "body" node of a menu</span>
|
|
<span class="reserved">if</span>(
|
|
Dom.hasClass(p_oElement, <span class="literal">"bd"</span>) &&
|
|
oParentNode &&
|
|
oParentNode.tagName == <span class="literal">"DIV"</span>
|
|
) {
|
|
|
|
<span class="reserved">return</span> oParentNode;
|
|
|
|
}
|
|
<span class="reserved">else</span> {
|
|
|
|
<span class="reserved">return</span> p_oElement;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case <span class="literal">"LI"</span>:
|
|
|
|
<span class="comment">/*
|
|
Capture the root LI node of the menu item and allow
|
|
fall through to keep climbing up to find the item's parent
|
|
root DIV
|
|
*/</span>
|
|
|
|
oMenuItemRootElement = p_oElement;
|
|
|
|
default:
|
|
|
|
oParentNode = p_oElement.parentNode;
|
|
|
|
<span class="reserved">if</span>(oParentNode) {
|
|
|
|
<span class="reserved">return</span> getMenuRootElement(oParentNode);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
<span class="comment">
|
|
|
|
// The root DIV node of a menu</span>
|
|
|
|
var oMenuRootElement = getMenuRootElement(oTarget);
|
|
|
|
|
|
<span class="reserved">if</span>(oMenuRootElement && oMenuRootElement.id) {
|
|
|
|
var oMenuItem;
|
|
var oMenu = YAHOO.widget.MenuModule._menus[oMenuRootElement.id];
|
|
|
|
<span class="reserved">if</span>(oMenuItemRootElement) {
|
|
|
|
var sYUIId = oMenuItemRootElement.getAttribute(<span class="literal">"yuiid"</span>);
|
|
|
|
<span class="reserved">if</span>(sYUIId) {
|
|
|
|
oMenuItem = YAHOO.widget.MenuModule._menuItems[sYUIId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
<span class="reserved">if</span>(oMenu) {
|
|
<span class="comment">
|
|
// Map of DOM event names to CustomEvent names</span>
|
|
|
|
var oEventTypes = {
|
|
<span class="literal">"click"</span>: <span class="literal">"clickEvent"</span>,
|
|
<span class="literal">"mousedown"</span>: <span class="literal">"mouseDownEvent"</span>,
|
|
<span class="literal">"mouseup"</span>: <span class="literal">"mouseUpEvent"</span>,
|
|
<span class="literal">"mouseover"</span>: <span class="literal">"mouseOverEvent"</span>,
|
|
<span class="literal">"mouseout"</span>: <span class="literal">"mouseOutEvent"</span>,
|
|
<span class="literal">"keydown"</span>: <span class="literal">"keyDownEvent"</span>,
|
|
<span class="literal">"keyup"</span>: <span class="literal">"keyUpEvent"</span>,
|
|
<span class="literal">"keypress"</span>: <span class="literal">"keyPressEvent"</span>
|
|
};
|
|
|
|
var sCustomEventType = oEventTypes[p_oEvent.type];
|
|
|
|
switch(p_oEvent.type) {
|
|
|
|
case <span class="literal">"mouseover"</span>:
|
|
|
|
<span class="reserved">if</span>(
|
|
!oMenu._bFiredMouseOverEvent &&
|
|
(
|
|
oTarget == oMenu.element ||
|
|
Dom.isAncestor(oMenu.element, oTarget)
|
|
)
|
|
) {
|
|
|
|
oMenu.mouseOverEvent.fire(p_oEvent);
|
|
|
|
oMenu._bFiredMouseOverEvent = true;
|
|
oMenu._bFiredMouseOutEvent = false;
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">if</span>(
|
|
oMenuItem &&
|
|
!oMenuItem._bFiredMouseOverEvent &&
|
|
(
|
|
oTarget == oMenuItem.element ||
|
|
Dom.isAncestor(oMenuItem.element, oTarget)
|
|
) &&
|
|
!oMenuItem.cfg.getProperty(<span class="literal">"disabled"</span>)
|
|
) {
|
|
|
|
oMenuItem.mouseOverEvent.fire(p_oEvent);
|
|
|
|
oMenuItem._bFiredMouseOverEvent = true;
|
|
oMenuItem._bFiredMouseOutEvent = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case <span class="literal">"mouseout"</span>:
|
|
|
|
var oRelatedTarget = Event.getRelatedTarget(p_oEvent);
|
|
var bMovingToSubmenu = false;
|
|
|
|
<span class="reserved">if</span>(oMenuItem) {
|
|
|
|
var oSubmenu = oMenuItem.cfg.getProperty(<span class="literal">"submenu"</span>);
|
|
|
|
<span class="reserved">if</span>(
|
|
oSubmenu &&
|
|
(
|
|
oRelatedTarget == oSubmenu.element ||
|
|
Dom.isAncestor(oSubmenu.element, oRelatedTarget)
|
|
)
|
|
) {
|
|
|
|
bMovingToSubmenu = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">if</span>(
|
|
oMenuItem &&
|
|
!oMenuItem._bFiredMouseOutEvent &&
|
|
(
|
|
(
|
|
oRelatedTarget != oMenuItem.element &&
|
|
!Dom.isAncestor(
|
|
oMenuItem.element,
|
|
oRelatedTarget
|
|
)
|
|
) || bMovingToSubmenu
|
|
) &&
|
|
!oMenuItem.cfg.getProperty(<span class="literal">"disabled"</span>)
|
|
) {
|
|
<span class="comment">
|
|
// Fire the "mouseout" Custom Event for the item</span>
|
|
|
|
oMenuItem.mouseOutEvent.fire(p_oEvent);
|
|
|
|
oMenuItem._bFiredMouseOutEvent = true;
|
|
oMenuItem._bFiredMouseOverEvent = false;
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">if</span>(
|
|
!oMenu._bFiredMouseOutEvent &&
|
|
(
|
|
(
|
|
oRelatedTarget != oMenu.element &&
|
|
!Dom.isAncestor(oMenu.element, oRelatedTarget)
|
|
)
|
|
|| bMovingToSubmenu
|
|
)
|
|
) {
|
|
|
|
oMenu.mouseOutEvent.fire(p_oEvent);
|
|
|
|
oMenu._bFiredMouseOutEvent = true;
|
|
oMenu._bFiredMouseOverEvent = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
<span class="reserved">if</span>(oMenuItem && !oMenuItem.cfg.getProperty(<span class="literal">"disabled"</span>)) {
|
|
|
|
oMenuItem[sCustomEventType].fire(p_oEvent);
|
|
|
|
}
|
|
|
|
oMenu[sCustomEventType].fire(p_oEvent);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
<span class="comment">
|
|
|
|
|
|
// Constants</span>
|
|
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the CSS class(es) to be applied to the root
|
|
* HTMLDivElement of the MenuModule instance.
|
|
* <span class="attrib">@final</span>
|
|
* <span class="attrib">@type</span> String
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.CSS_CLASS_NAME = <span class="literal">"yuimenu"</span>;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the type of item to instantiate and add when parsing
|
|
* the child nodes (either HTMLLIElement, HTMLOptGroupElement or
|
|
* HTMLOptionElement) of a menu's DOM. The default
|
|
* is YAHOO.widget.MenuModuleItem.
|
|
* <span class="attrib">@final</span>
|
|
* <span class="attrib">@type</span> YAHOO.widget.MenuModuleItem
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.ITEM_TYPE = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the tagname of the HTMLElement used to title
|
|
* a group of items.
|
|
* <span class="attrib">@final</span>
|
|
* <span class="attrib">@type</span> String
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.GROUP_TITLE_TAG_NAME = <span class="literal">"H6"</span>;
|
|
<span class="comment">
|
|
|
|
|
|
// Private properties</span>
|
|
|
|
|
|
<span class="comment">/**
|
|
* The current state of a MenuModule instance's "mouseover" event
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {Boolean}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._bFiredMouseOverEvent = false;
|
|
|
|
|
|
<span class="comment">/**
|
|
* The current state of a MenuModule instance's "mouseout" event
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {Boolean}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._bFiredMouseOutEvent = false;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Array of HTMLElements used to title groups of items.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {Array}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._aGroupTitleElements = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Multi-dimensional array of items.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {Array}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._aItemGroups = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* An array of HTMLUListElements, each of which is the parent node of each
|
|
* items's HTMLLIElement node.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {Array}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._aListElements = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Reference to the Event utility singleton.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {YAHOO.util.Event}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._oEventUtil = YAHOO.util.Event;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Reference to the Dom utility singleton.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {YAHOO.util.Dom}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._oDom = YAHOO.util.Dom;
|
|
<span class="comment">
|
|
|
|
|
|
// Public properties</span>
|
|
|
|
<span class="comment">/**
|
|
* Reference to the item that has focus.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@type</span> {YAHOO.widget.MenuModuleItem}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.activeItem = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Returns a MenuModule instance's parent object.
|
|
* <span class="attrib">@type</span> {YAHOO.widget.MenuModuleItem}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.parent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Returns the HTMLElement (either HTMLSelectElement or HTMLDivElement)
|
|
* used create the MenuModule instance.
|
|
* <span class="attrib">@type</span> {HTMLSelectElement/HTMLDivElement}
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.srcElement = null;
|
|
<span class="comment">
|
|
|
|
|
|
// Events</span>
|
|
|
|
<span class="comment">/**
|
|
* Fires when the mouse has entered a MenuModule instance. Passes back the
|
|
* DOM Event object as an argument.
|
|
* <span class="attrib">@type</span> {YAHOO.util.CustomEvent}
|
|
* <span class="attrib">@see</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.mouseOverEvent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Fires when the mouse has left a MenuModule instance. Passes back the DOM
|
|
* Event object as an argument.
|
|
* <span class="attrib">@type</span> {YAHOO.util.CustomEvent}
|
|
* <span class="attrib">@see</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.mouseOutEvent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Fires when the user mouses down on a MenuModule instance. Passes back the
|
|
* DOM Event object as an argument.
|
|
* <span class="attrib">@type</span> {YAHOO.util.CustomEvent}
|
|
* <span class="attrib">@see</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.mouseDownEvent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Fires when the user releases a mouse button while the mouse is over
|
|
* a MenuModule instance. Passes back the DOM Event object as an argument.
|
|
* <span class="attrib">@type</span> {YAHOO.util.CustomEvent}
|
|
* <span class="attrib">@see</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.mouseUpEvent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Fires when the user clicks the on a MenuModule instance. Passes back the
|
|
* DOM Event object as an argument.
|
|
* <span class="attrib">@type</span> {YAHOO.util.CustomEvent}
|
|
* <span class="attrib">@see</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.clickEvent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Fires when the user presses an alphanumeric key. Passes back the
|
|
* DOM Event object as an argument.
|
|
* <span class="attrib">@type</span> {YAHOO.util.CustomEvent}
|
|
* <span class="attrib">@see</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.keyPressEvent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Fires when the user presses a key. Passes back the DOM Event
|
|
* object as an argument.
|
|
* <span class="attrib">@type</span> {YAHOO.util.CustomEvent}
|
|
* <span class="attrib">@see</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.keyDownEvent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Fires when the user releases a key. Passes back the DOM Event
|
|
* object as an argument.
|
|
* <span class="attrib">@type</span> {YAHOO.util.CustomEvent}
|
|
* <span class="attrib">@see</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.keyUpEvent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* The MenuModule class's initialization method. This method is automatically
|
|
* called by the constructor, and sets up all DOM references for
|
|
* pre-existing markup, and creates required markup if it is not already present.
|
|
* <span class="attrib">@param</span> {String or HTMLElement} p_oElement String id or HTMLElement
|
|
* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
|
|
* <span class="attrib">@param</span> {Object} p_oConfig Optional. The configuration object literal
|
|
* containing the configuration for a MenuModule instance. See
|
|
* configuration class documentation for more details.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.init = <span class="reserved">function</span>(p_oElement, p_oConfig) {
|
|
|
|
var Dom = <span class="reserved">this</span>._oDom;
|
|
var Event = <span class="reserved">this</span>._oEventUtil;
|
|
|
|
|
|
<span class="reserved">if</span>(!<span class="reserved">this</span>.ITEM_TYPE) {
|
|
|
|
<span class="reserved">this</span>.ITEM_TYPE = YAHOO.widget.MenuModuleItem;
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">this</span>._aItemGroups = [];
|
|
<span class="reserved">this</span>._aListElements = [];
|
|
<span class="reserved">this</span>._aGroupTitleElements = [];
|
|
|
|
|
|
var oElement;
|
|
|
|
<span class="reserved">if</span>(typeof p_oElement == <span class="literal">"string"</span>) {
|
|
|
|
oElement = document.getElementById(p_oElement);
|
|
|
|
}
|
|
<span class="reserved">else</span> <span class="reserved">if</span>(p_oElement.tagName) {
|
|
|
|
oElement = p_oElement;
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">if</span>(oElement) {
|
|
|
|
switch(oElement.tagName) {
|
|
|
|
case <span class="literal">"DIV"</span>:
|
|
|
|
<span class="reserved">this</span>.srcElement = oElement;
|
|
|
|
<span class="comment">/*
|
|
Note: we don't pass the user config in here yet
|
|
because we only want it executed once, at the lowest
|
|
subclass level.
|
|
*/</span>
|
|
|
|
YAHOO.widget.MenuModule.superclass.init.call(<span class="reserved">this</span>, oElement);
|
|
|
|
<span class="reserved">this</span>.beforeInitEvent.fire(YAHOO.widget.MenuModule);
|
|
|
|
|
|
<span class="comment">/*
|
|
Populate the collection of item groups and item
|
|
group titles
|
|
*/</span>
|
|
|
|
var oNode = <span class="reserved">this</span>.body.firstChild;
|
|
var i = 0;
|
|
|
|
do {
|
|
|
|
switch(oNode.tagName) {
|
|
|
|
case <span class="reserved">this</span>.GROUP_TITLE_TAG_NAME:
|
|
|
|
<span class="reserved">this</span>._aGroupTitleElements[i] = oNode;
|
|
|
|
break;
|
|
|
|
case <span class="literal">"UL"</span>:
|
|
|
|
<span class="reserved">this</span>._aListElements[i] = oNode;
|
|
<span class="reserved">this</span>._aItemGroups[i] = [];
|
|
i++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
<span class="reserved">while</span>((oNode = oNode.nextSibling));
|
|
|
|
|
|
<span class="comment">/*
|
|
Apply the "first-of-type" class to the first UL to mimic
|
|
the "first-of-type" CSS3 psuedo class.
|
|
*/</span>
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>._aListElements[0]) {
|
|
|
|
Dom.addClass(<span class="reserved">this</span>._aListElements[0], <span class="literal">"first-of-type"</span>);
|
|
|
|
}
|
|
|
|
<span class="reserved">this</span>.logger = new YAHOO.widget.LogWriter(<span class="reserved">this</span>.toString());
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Source element: "</span> + <span class="reserved">this</span>.srcElement.tagName);
|
|
|
|
break;
|
|
|
|
case <span class="literal">"SELECT"</span>:
|
|
|
|
<span class="reserved">this</span>.srcElement = oElement;
|
|
|
|
|
|
<span class="comment">/*
|
|
The source element is not something that we can use
|
|
outright, so we need to create a new Overlay
|
|
*/</span>
|
|
|
|
var sId = Dom.generateId();
|
|
|
|
<span class="comment">/*
|
|
Note: we don't pass the user config in here yet
|
|
because we only want it executed once, at the lowest
|
|
subclass level.
|
|
*/</span>
|
|
|
|
YAHOO.widget.MenuModule.superclass.init.call(<span class="reserved">this</span>, sId);
|
|
|
|
<span class="reserved">this</span>.beforeInitEvent.fire(YAHOO.widget.MenuModule);
|
|
|
|
<span class="reserved">this</span>.logger = new YAHOO.widget.LogWriter(<span class="reserved">this</span>.toString());
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Source element: "</span> + <span class="reserved">this</span>.srcElement.tagName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
<span class="reserved">else</span> {
|
|
|
|
<span class="comment">/*
|
|
Note: we don't pass the user config in here yet
|
|
because we only want it executed once, at the lowest
|
|
subclass level.
|
|
*/</span>
|
|
|
|
YAHOO.widget.MenuModule.superclass.init.call(<span class="reserved">this</span>, p_oElement);
|
|
|
|
<span class="reserved">this</span>.beforeInitEvent.fire(YAHOO.widget.MenuModule);
|
|
|
|
<span class="reserved">this</span>.logger = new YAHOO.widget.LogWriter(<span class="reserved">this</span>.toString());
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"No source element found. "</span> +
|
|
<span class="literal">"Created element with id: "</span> + <span class="reserved">this</span>.id);
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.element) {
|
|
|
|
var oEl = <span class="reserved">this</span>.element;
|
|
var CustomEvent = YAHOO.util.CustomEvent;
|
|
|
|
Dom.addClass(oEl, <span class="reserved">this</span>.CSS_CLASS_NAME);
|
|
<span class="comment">
|
|
// Assign DOM event handlers</span>
|
|
|
|
<span class="reserved">if</span>(YAHOO.widget.MenuModule._initEventHandlers) {
|
|
|
|
var oDoc = document;
|
|
var onDOMEvent = YAHOO.widget.MenuModule._onDOMEvent;
|
|
|
|
Event.addListener(oDoc, <span class="literal">"mouseover"</span>, onDOMEvent);
|
|
Event.addListener(oDoc, <span class="literal">"mouseout"</span>, onDOMEvent);
|
|
Event.addListener(oDoc, <span class="literal">"mousedown"</span>, onDOMEvent);
|
|
Event.addListener(oDoc, <span class="literal">"mouseup"</span>, onDOMEvent);
|
|
Event.addListener(oDoc, <span class="literal">"click"</span>, onDOMEvent);
|
|
Event.addListener(oDoc, <span class="literal">"keydown"</span>, onDOMEvent);
|
|
Event.addListener(oDoc, <span class="literal">"keyup"</span>, onDOMEvent);
|
|
Event.addListener(oDoc, <span class="literal">"keypress"</span>, onDOMEvent);
|
|
|
|
YAHOO.widget.MenuModule._initEventHandlers = false;
|
|
|
|
}
|
|
<span class="comment">
|
|
|
|
// Create custom events</span>
|
|
|
|
<span class="reserved">this</span>.mouseOverEvent = new CustomEvent(<span class="literal">"mouseOverEvent"</span>, <span class="reserved">this</span>);
|
|
<span class="reserved">this</span>.mouseOutEvent = new CustomEvent(<span class="literal">"mouseOutEvent"</span>, <span class="reserved">this</span>);
|
|
<span class="reserved">this</span>.mouseDownEvent = new CustomEvent(<span class="literal">"mouseDownEvent"</span>, <span class="reserved">this</span>);
|
|
<span class="reserved">this</span>.mouseUpEvent = new CustomEvent(<span class="literal">"mouseUpEvent"</span>, <span class="reserved">this</span>);
|
|
<span class="reserved">this</span>.clickEvent = new CustomEvent(<span class="literal">"clickEvent"</span>, <span class="reserved">this</span>);
|
|
<span class="reserved">this</span>.keyPressEvent = new CustomEvent(<span class="literal">"keyPressEvent"</span>, <span class="reserved">this</span>);
|
|
<span class="reserved">this</span>.keyDownEvent = new CustomEvent(<span class="literal">"keyDownEvent"</span>, <span class="reserved">this</span>);
|
|
<span class="reserved">this</span>.keyUpEvent = new CustomEvent(<span class="literal">"keyUpEvent"</span>, <span class="reserved">this</span>);
|
|
<span class="comment">
|
|
|
|
// Subscribe to Custom Events</span>
|
|
|
|
<span class="reserved">this</span>.initEvent.subscribe(<span class="reserved">this</span>._onInit, <span class="reserved">this</span>, true);
|
|
<span class="reserved">this</span>.beforeRenderEvent.subscribe(<span class="reserved">this</span>._onBeforeRender, <span class="reserved">this</span>, true);
|
|
<span class="reserved">this</span>.renderEvent.subscribe(<span class="reserved">this</span>._onRender, <span class="reserved">this</span>, true);
|
|
<span class="reserved">this</span>.showEvent.subscribe(<span class="reserved">this</span>._onShow, <span class="reserved">this</span>, true);
|
|
<span class="reserved">this</span>.beforeHideEvent.subscribe(<span class="reserved">this</span>._onBeforeHide, <span class="reserved">this</span>, true);
|
|
|
|
|
|
<span class="reserved">if</span>(p_oConfig) {
|
|
|
|
<span class="reserved">this</span>.cfg.applyConfig(p_oConfig, true);
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">this</span>.cfg.queueProperty(<span class="literal">"visible"</span>, false);
|
|
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.srcElement) {
|
|
|
|
<span class="reserved">this</span>._initSubTree();
|
|
|
|
}
|
|
|
|
YAHOO.widget.MenuModule._menus[oEl.id] = <span class="reserved">this</span>;
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">this</span>.initEvent.fire(YAHOO.widget.MenuModule);
|
|
|
|
};
|
|
<span class="comment">
|
|
|
|
// Private methods</span>
|
|
|
|
<span class="comment">/**
|
|
* Iterates the source element's childNodes collection and uses the child
|
|
* nodes to instantiate MenuModule and MenuModuleItem instances.
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._initSubTree = <span class="reserved">function</span>() {
|
|
|
|
var oNode;
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Searching DOM for items to initialize."</span>);
|
|
|
|
switch(<span class="reserved">this</span>.srcElement.tagName) {
|
|
|
|
case <span class="literal">"DIV"</span>:
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>._aListElements.length > 0) {
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Found "</span> +
|
|
<span class="reserved">this</span>._aListElements.length + <span class="literal">" item groups to initialize."</span>);
|
|
|
|
var i = <span class="reserved">this</span>._aListElements.length - 1;
|
|
|
|
do {
|
|
|
|
oNode = <span class="reserved">this</span>._aListElements[i].firstChild;
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Scanning "</span> +
|
|
<span class="reserved">this</span>._aListElements[i].childNodes.length +
|
|
<span class="literal">" child nodes for items to initialize."</span>);
|
|
|
|
do {
|
|
|
|
switch(oNode.tagName) {
|
|
|
|
case <span class="literal">"LI"</span>:
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Initializing "</span> +
|
|
oNode.tagName + <span class="literal">" node."</span>);
|
|
|
|
<span class="reserved">this</span>.addItem(new <span class="reserved">this</span>.ITEM_TYPE(oNode), i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
<span class="reserved">while</span>((oNode = oNode.nextSibling));
|
|
|
|
}
|
|
<span class="reserved">while</span>(i--);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case <span class="literal">"SELECT"</span>:
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Scanning "</span> + <span class="reserved">this</span>.srcElement.childNodes.length +
|
|
<span class="literal">" child nodes for items to initialize."</span>);
|
|
|
|
oNode = <span class="reserved">this</span>.srcElement.firstChild;
|
|
|
|
do {
|
|
|
|
switch(oNode.tagName) {
|
|
|
|
case <span class="literal">"OPTGROUP"</span>:
|
|
case <span class="literal">"OPTION"</span>:
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Initializing "</span> +
|
|
oNode.tagName + <span class="literal">" node."</span>);
|
|
|
|
<span class="reserved">this</span>.addItem(new <span class="reserved">this</span>.ITEM_TYPE(oNode));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
<span class="reserved">while</span>((oNode = oNode.nextSibling));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Returns the first enabled item in a menu instance.
|
|
* <span class="attrib">@return</span> Returns a MenuModuleItem instance.
|
|
* <span class="attrib">@type</span> YAHOO.widget.MenuModuleItem
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._getFirstEnabledItem = <span class="reserved">function</span>() {
|
|
|
|
var nGroups = <span class="reserved">this</span>._aItemGroups.length;
|
|
var oItem;
|
|
var aItemGroup;
|
|
|
|
<span class="reserved">for</span>(var i=0; i<nGroups; i++) {
|
|
|
|
aItemGroup = <span class="reserved">this</span>._aItemGroups[i];
|
|
|
|
<span class="reserved">if</span>(aItemGroup) {
|
|
|
|
var nItems = aItemGroup.length;
|
|
|
|
<span class="reserved">for</span>(var n=0; n<nItems; n++) {
|
|
|
|
oItem = aItemGroup[n];
|
|
|
|
<span class="reserved">if</span>(
|
|
!oItem.cfg.getProperty(<span class="literal">"disabled"</span>) &&
|
|
oItem.element.style.display != <span class="literal">"none"</span>
|
|
) {
|
|
|
|
<span class="reserved">return</span> oItem;
|
|
|
|
}
|
|
|
|
oItem = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Determines if the value is one of the supported positions.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {Object} p_sPosition The object to be evaluated.
|
|
* <span class="attrib">@return</span> Returns true if the position is supported.
|
|
* <span class="attrib">@type</span> Boolean
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._checkPosition = <span class="reserved">function</span>(p_sPosition) {
|
|
|
|
<span class="reserved">if</span>(typeof p_sPosition == <span class="literal">"string"</span>) {
|
|
|
|
var sPosition = p_sPosition.toLowerCase();
|
|
|
|
<span class="reserved">return</span> (<span class="literal">"dynamic,static"</span>.indexOf(sPosition) != -1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Adds an item to a group.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {Number} p_nGroupIndex Number indicating the group to which
|
|
* the item belongs.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModuleItem} p_oItem The item to be added.
|
|
* <span class="attrib">@param</span> {Number} p_nItemIndex Optional. Index at which the item
|
|
* should be added.
|
|
* <span class="attrib">@return</span> The item that was added.
|
|
* <span class="attrib">@type</span> YAHOO.widget.MenuModuleItem
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._addItemToGroup =
|
|
|
|
<span class="reserved">function</span>(p_nGroupIndex, p_oItem, p_nItemIndex) {
|
|
|
|
var Dom = <span class="reserved">this</span>._oDom;
|
|
var oItem;
|
|
|
|
<span class="reserved">if</span>(p_oItem instanceof <span class="reserved">this</span>.ITEM_TYPE) {
|
|
|
|
oItem = p_oItem;
|
|
|
|
}
|
|
<span class="reserved">else</span> <span class="reserved">if</span>(typeof p_oItem == <span class="literal">"string"</span>) {
|
|
|
|
oItem = new <span class="reserved">this</span>.ITEM_TYPE(p_oItem);
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">if</span>(oItem) {
|
|
|
|
var sYUIId = Dom.generateId();
|
|
|
|
oItem.element.setAttribute(<span class="literal">"yuiid"</span>, sYUIId);
|
|
|
|
YAHOO.widget.MenuModule._menuItems[sYUIId] = oItem;
|
|
|
|
|
|
var nGroupIndex = typeof p_nGroupIndex == <span class="literal">"number"</span> ?
|
|
p_nGroupIndex : 0;
|
|
|
|
var aGroup = <span class="reserved">this</span>._getItemGroup(nGroupIndex);
|
|
|
|
var oGroupItem;
|
|
|
|
|
|
<span class="reserved">if</span>(!aGroup) {
|
|
|
|
aGroup = <span class="reserved">this</span>._createItemGroup(nGroupIndex);
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">if</span>(typeof p_nItemIndex == <span class="literal">"number"</span>) {
|
|
|
|
var bAppend = (p_nItemIndex >= aGroup.length);
|
|
|
|
|
|
<span class="reserved">if</span>(aGroup[p_nItemIndex]) {
|
|
|
|
aGroup.splice(p_nItemIndex, 0, oItem);
|
|
|
|
}
|
|
<span class="reserved">else</span> {
|
|
|
|
aGroup[p_nItemIndex] = oItem;
|
|
|
|
}
|
|
|
|
|
|
oGroupItem = aGroup[p_nItemIndex];
|
|
|
|
<span class="reserved">if</span>(oGroupItem) {
|
|
|
|
<span class="reserved">if</span>(
|
|
bAppend &&
|
|
(
|
|
!oGroupItem.element.parentNode ||
|
|
oGroupItem.element.parentNode.nodeType == 11
|
|
)
|
|
) {
|
|
|
|
<span class="reserved">this</span>._aListElements[nGroupIndex].appendChild(
|
|
oGroupItem.element
|
|
);
|
|
|
|
}
|
|
<span class="reserved">else</span> {
|
|
|
|
|
|
<span class="comment">/**
|
|
* Returns the next sibling of an item in an array
|
|
* <span class="attrib">@param</span> {p_aArray} An array
|
|
* <span class="attrib">@param</span> {p_nStartIndex} The index to start searching
|
|
* the array
|
|
* <span class="attrib">@ignore</span>
|
|
* <span class="attrib">@return</span> Returns an item in an array
|
|
* <span class="attrib">@type</span> Object
|
|
*/</span>
|
|
<span class="reserved">function</span> getNextItemSibling(p_aArray, p_nStartIndex) {
|
|
|
|
<span class="reserved">return</span> (
|
|
p_aArray[p_nStartIndex] ||
|
|
getNextItemSibling(
|
|
p_aArray,
|
|
(p_nStartIndex+1)
|
|
)
|
|
);
|
|
|
|
}
|
|
|
|
|
|
var oNextItemSibling =
|
|
getNextItemSibling(aGroup, (p_nItemIndex+1));
|
|
|
|
<span class="reserved">if</span>(
|
|
oNextItemSibling &&
|
|
(
|
|
!oGroupItem.element.parentNode ||
|
|
oGroupItem.element.parentNode.nodeType == 11
|
|
)
|
|
) {
|
|
|
|
<span class="reserved">this</span>._aListElements[nGroupIndex].insertBefore(
|
|
oGroupItem.element,
|
|
oNextItemSibling.element
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
oGroupItem.parent = <span class="reserved">this</span>;
|
|
|
|
<span class="reserved">this</span>._subscribeToItemEvents(oGroupItem);
|
|
|
|
<span class="reserved">this</span>._configureItemSubmenuModule(oGroupItem);
|
|
|
|
<span class="reserved">this</span>._updateItemProperties(nGroupIndex);
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Item inserted."</span> +
|
|
<span class="literal">" Text: "</span> + oGroupItem.cfg.getProperty(<span class="literal">"text"</span>) + <span class="literal">", "</span> +
|
|
<span class="literal">" Index: "</span> + oGroupItem.index + <span class="literal">", "</span> +
|
|
<span class="literal">" Group Index: "</span> + oGroupItem.groupIndex);
|
|
|
|
<span class="reserved">return</span> oGroupItem;
|
|
|
|
}
|
|
|
|
}
|
|
<span class="reserved">else</span> {
|
|
|
|
var nItemIndex = aGroup.length;
|
|
|
|
aGroup[nItemIndex] = oItem;
|
|
|
|
|
|
oGroupItem = aGroup[nItemIndex];
|
|
|
|
<span class="reserved">if</span>(oGroupItem) {
|
|
|
|
<span class="reserved">if</span>(
|
|
!Dom.isAncestor(
|
|
<span class="reserved">this</span>._aListElements[nGroupIndex],
|
|
oGroupItem.element
|
|
)
|
|
) {
|
|
|
|
<span class="reserved">this</span>._aListElements[nGroupIndex].appendChild(
|
|
oGroupItem.element
|
|
);
|
|
|
|
}
|
|
|
|
oGroupItem.element.setAttribute(<span class="literal">"groupindex"</span>, nGroupIndex);
|
|
oGroupItem.element.setAttribute(<span class="literal">"index"</span>, nItemIndex);
|
|
|
|
oGroupItem.parent = <span class="reserved">this</span>;
|
|
|
|
oGroupItem.index = nItemIndex;
|
|
oGroupItem.groupIndex = nGroupIndex;
|
|
|
|
<span class="reserved">this</span>._subscribeToItemEvents(oGroupItem);
|
|
|
|
<span class="reserved">this</span>._configureItemSubmenuModule(oGroupItem);
|
|
|
|
<span class="reserved">if</span>(nItemIndex === 0) {
|
|
|
|
Dom.addClass(oGroupItem.element, <span class="literal">"first-of-type"</span>);
|
|
|
|
}
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Item added."</span> +
|
|
<span class="literal">" Text: "</span> + oGroupItem.cfg.getProperty(<span class="literal">"text"</span>) + <span class="literal">", "</span> +
|
|
<span class="literal">" Index: "</span> + oGroupItem.index + <span class="literal">", "</span> +
|
|
<span class="literal">" Group Index: "</span> + oGroupItem.groupIndex);
|
|
|
|
<span class="reserved">return</span> oGroupItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Removes an item from a group by index.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {Number} p_nGroupIndex Number indicating the group to which
|
|
* the item belongs.
|
|
* <span class="attrib">@param</span> {Number} p_nItemIndex Number indicating the index of the item to
|
|
* be removed.
|
|
* <span class="attrib">@return</span> The item that was removed.
|
|
* <span class="attrib">@type</span> YAHOO.widget.MenuModuleItem
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._removeItemFromGroupByIndex =
|
|
|
|
<span class="reserved">function</span>(p_nGroupIndex, p_nItemIndex) {
|
|
|
|
var nGroupIndex = typeof p_nGroupIndex == <span class="literal">"number"</span> ? p_nGroupIndex : 0;
|
|
var aGroup = <span class="reserved">this</span>._getItemGroup(nGroupIndex);
|
|
|
|
<span class="reserved">if</span>(aGroup) {
|
|
|
|
var aArray = aGroup.splice(p_nItemIndex, 1);
|
|
var oItem = aArray[0];
|
|
|
|
<span class="reserved">if</span>(oItem) {
|
|
<span class="comment">
|
|
// Update the index and className properties of each member </span>
|
|
|
|
<span class="reserved">this</span>._updateItemProperties(nGroupIndex);
|
|
|
|
<span class="reserved">if</span>(aGroup.length === 0) {
|
|
<span class="comment">
|
|
// Remove the UL</span>
|
|
|
|
var oUL = <span class="reserved">this</span>._aListElements[nGroupIndex];
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.body && oUL) {
|
|
|
|
<span class="reserved">this</span>.body.removeChild(oUL);
|
|
|
|
}
|
|
<span class="comment">
|
|
// Remove the group from the array of items</span>
|
|
|
|
<span class="reserved">this</span>._aItemGroups.splice(nGroupIndex, 1);
|
|
<span class="comment">
|
|
|
|
// Remove the UL from the array of ULs</span>
|
|
|
|
<span class="reserved">this</span>._aListElements.splice(nGroupIndex, 1);
|
|
|
|
|
|
<span class="comment">/*
|
|
Assign the "first-of-type" class to the new first UL
|
|
in the collection
|
|
*/</span>
|
|
|
|
oUL = <span class="reserved">this</span>._aListElements[0];
|
|
|
|
<span class="reserved">if</span>(oUL) {
|
|
|
|
<span class="reserved">this</span>._oDom.addClass(oUL, <span class="literal">"first-of-type"</span>);
|
|
|
|
}
|
|
|
|
}
|
|
<span class="comment">
|
|
|
|
// Return a reference to the item that was removed</span>
|
|
|
|
<span class="reserved">return</span> oItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Removes a item from a group by reference.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {Number} p_nGroupIndex Number indicating the group to which
|
|
* the item belongs.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModuleItem} p_oItem The item to be removed.
|
|
* <span class="attrib">@return</span> The item that was removed.
|
|
* <span class="attrib">@type</span> YAHOO.widget.MenuModuleItem
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._removeItemFromGroupByValue =
|
|
|
|
<span class="reserved">function</span>(p_nGroupIndex, p_oItem) {
|
|
|
|
var aGroup = <span class="reserved">this</span>._getItemGroup(p_nGroupIndex);
|
|
|
|
<span class="reserved">if</span>(aGroup) {
|
|
|
|
var nItems = aGroup.length;
|
|
var nItemIndex = -1;
|
|
|
|
<span class="reserved">if</span>(nItems > 0) {
|
|
|
|
var i = nItems-1;
|
|
|
|
do {
|
|
|
|
<span class="reserved">if</span>(aGroup[i] == p_oItem) {
|
|
|
|
nItemIndex = i;
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
<span class="reserved">while</span>(i--);
|
|
|
|
<span class="reserved">if</span>(nItemIndex > -1) {
|
|
|
|
<span class="reserved">return</span> <span class="reserved">this</span>._removeItemFromGroupByIndex(
|
|
p_nGroupIndex,
|
|
nItemIndex
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Updates the index, groupindex, and className properties of the items
|
|
* in the specified group.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {Number} p_nGroupIndex Number indicating the group of items to update.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._updateItemProperties =
|
|
|
|
<span class="reserved">function</span>(p_nGroupIndex) {
|
|
|
|
var aGroup = <span class="reserved">this</span>._getItemGroup(p_nGroupIndex);
|
|
var nItems = aGroup.length;
|
|
|
|
<span class="reserved">if</span>(nItems > 0) {
|
|
|
|
var Dom = <span class="reserved">this</span>._oDom;
|
|
var i = nItems - 1;
|
|
var oItem;
|
|
var oLI;
|
|
<span class="comment">
|
|
// Update the index and className properties of each member </span>
|
|
|
|
do {
|
|
|
|
oItem = aGroup[i];
|
|
|
|
<span class="reserved">if</span>(oItem) {
|
|
|
|
oLI = oItem.element;
|
|
|
|
oItem.index = i;
|
|
oItem.groupIndex = p_nGroupIndex;
|
|
|
|
oLI.setAttribute(<span class="literal">"groupindex"</span>, p_nGroupIndex);
|
|
oLI.setAttribute(<span class="literal">"index"</span>, i);
|
|
|
|
Dom.removeClass(oLI, <span class="literal">"first-of-type"</span>);
|
|
|
|
}
|
|
|
|
}
|
|
<span class="reserved">while</span>(i--);
|
|
|
|
|
|
<span class="reserved">if</span>(oLI) {
|
|
|
|
Dom.addClass(oLI, <span class="literal">"first-of-type"</span>);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Creates a new item group (array) and it's associated HTMLUlElement node
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {Number} p_nIndex Number indicating the group to create.
|
|
* <span class="attrib">@return</span> An item group.
|
|
* <span class="attrib">@type</span> Array
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._createItemGroup = <span class="reserved">function</span>(p_nIndex) {
|
|
|
|
<span class="reserved">if</span>(!<span class="reserved">this</span>._aItemGroups[p_nIndex]) {
|
|
|
|
<span class="reserved">this</span>._aItemGroups[p_nIndex] = [];
|
|
|
|
var oUL = document.createElement(<span class="literal">"ul"</span>);
|
|
|
|
<span class="reserved">this</span>._aListElements[p_nIndex] = oUL;
|
|
|
|
<span class="reserved">return</span> <span class="reserved">this</span>._aItemGroups[p_nIndex];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Returns the item group at the specified index.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {Number} p_nIndex Number indicating the index of the item group to
|
|
* be retrieved.
|
|
* <span class="attrib">@return</span> An array of items.
|
|
* <span class="attrib">@type</span> Array
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._getItemGroup = <span class="reserved">function</span>(p_nIndex) {
|
|
|
|
var nIndex = ((typeof p_nIndex == <span class="literal">"number"</span>) ? p_nIndex : 0);
|
|
|
|
<span class="reserved">return</span> <span class="reserved">this</span>._aItemGroups[nIndex];
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Subscribe's a MenuModule instance to it's parent MenuModule instance's events.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModuleItem} p_oItem The item to listen
|
|
* for events on.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._configureItemSubmenuModule =
|
|
|
|
<span class="reserved">function</span>(p_oItem) {
|
|
|
|
var oSubmenu = p_oItem.cfg.getProperty(<span class="literal">"submenu"</span>);
|
|
|
|
<span class="reserved">if</span>(oSubmenu) {
|
|
|
|
<span class="comment">/*
|
|
Listen for configuration changes to the parent MenuModule
|
|
instance so they they can be applied to the submenu.
|
|
*/</span>
|
|
|
|
<span class="reserved">this</span>.cfg.configChangedEvent.subscribe(
|
|
<span class="reserved">this</span>._onParentMenuModuleConfigChange,
|
|
oSubmenu,
|
|
true
|
|
);
|
|
|
|
<span class="reserved">this</span>.renderEvent.subscribe(
|
|
<span class="reserved">this</span>._onParentMenuModuleRender,
|
|
oSubmenu,
|
|
true
|
|
);
|
|
|
|
oSubmenu.beforeShowEvent.subscribe(
|
|
<span class="reserved">this</span>._onSubmenuBeforeShow,
|
|
oSubmenu,
|
|
true
|
|
);
|
|
|
|
oSubmenu.showEvent.subscribe(<span class="reserved">this</span>._onSubmenuShow, oSubmenu, true);
|
|
|
|
oSubmenu.hideEvent.subscribe(<span class="reserved">this</span>._onSubmenuHide, oSubmenu, true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Subscribes a MenuModule instance to the specified item's Custom Events.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModuleItem} p_oItem The item to listen for events on.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._subscribeToItemEvents = <span class="reserved">function</span>(p_oItem) {
|
|
|
|
var aArguments = [<span class="reserved">this</span>, p_oItem];
|
|
|
|
p_oItem.focusEvent.subscribe(<span class="reserved">this</span>._onItemFocus, aArguments);
|
|
|
|
p_oItem.blurEvent.subscribe(<span class="reserved">this</span>._onItemBlur, aArguments);
|
|
|
|
p_oItem.cfg.configChangedEvent.subscribe(
|
|
<span class="reserved">this</span>._onItemConfigChange,
|
|
aArguments
|
|
);
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Returns the offset width of a MenuModule instance.
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._getOffsetWidth = <span class="reserved">function</span>() {
|
|
|
|
var oClone = <span class="reserved">this</span>.element.cloneNode(true);
|
|
|
|
<span class="reserved">this</span>._oDom.setStyle(oClone, <span class="literal">"width"</span>, <span class="literal">""</span>);
|
|
|
|
document.body.appendChild(oClone);
|
|
|
|
var sWidth = oClone.offsetWidth;
|
|
|
|
document.body.removeChild(oClone);
|
|
|
|
<span class="reserved">return</span> sWidth;
|
|
|
|
};
|
|
<span class="comment">
|
|
|
|
// Private Custom Event handlers</span>
|
|
|
|
<span class="comment">/**
|
|
* "init" Custom Event handler for a MenuModule instance.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
|
|
* fired the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onInit =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oMenuModule) {
|
|
|
|
var sCSSPosition = (<span class="reserved">this</span>.cfg.getProperty(<span class="literal">"position"</span>) == <span class="literal">"static"</span>) ?
|
|
<span class="literal">"static"</span> : <span class="literal">"absolute"</span>;
|
|
|
|
<span class="reserved">this</span>._oDom.setStyle(<span class="reserved">this</span>.element, <span class="literal">"position"</span>, sCSSPosition);
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "beforerender" Custom Event handler for a MenuModule instance. Appends all
|
|
* of the HTMLUListElement (&#60;UL&#60;s) nodes (and their child
|
|
* HTMLLIElement (&#60;LI&#60;)) nodes and their accompanying title nodes to
|
|
* the body of the MenuModule instance.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
|
|
* fired the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onBeforeRender =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oMenuModule) {
|
|
|
|
var Dom = <span class="reserved">this</span>._oDom;
|
|
var oConfig = <span class="reserved">this</span>.cfg;
|
|
var oEl = <span class="reserved">this</span>.element;
|
|
var nListElements = <span class="reserved">this</span>._aListElements.length;
|
|
|
|
|
|
<span class="reserved">if</span>(oConfig.getProperty(<span class="literal">"position"</span>) == <span class="literal">"static"</span>) {
|
|
|
|
oConfig.queueProperty(<span class="literal">"iframe"</span>, false);
|
|
oConfig.queueProperty(<span class="literal">"visible"</span>, true);
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">if</span>(nListElements > 0) {
|
|
|
|
var i = 0;
|
|
var bFirstList = true;
|
|
var oUL;
|
|
var oGroupTitle;
|
|
|
|
|
|
do {
|
|
|
|
oUL = <span class="reserved">this</span>._aListElements[i];
|
|
|
|
<span class="reserved">if</span>(oUL) {
|
|
|
|
<span class="reserved">if</span>(bFirstList) {
|
|
|
|
Dom.addClass(oUL, <span class="literal">"first-of-type"</span>);
|
|
bFirstList = false;
|
|
|
|
}
|
|
|
|
|
|
<span class="reserved">if</span>(!Dom.isAncestor(oEl, oUL)) {
|
|
|
|
<span class="reserved">this</span>.appendToBody(oUL);
|
|
|
|
}
|
|
|
|
|
|
oGroupTitle = <span class="reserved">this</span>._aGroupTitleElements[i];
|
|
|
|
<span class="reserved">if</span>(oGroupTitle) {
|
|
|
|
<span class="reserved">if</span>(!Dom.isAncestor(oEl, oGroupTitle)) {
|
|
|
|
oUL.parentNode.insertBefore(oGroupTitle, oUL);
|
|
|
|
}
|
|
|
|
|
|
Dom.addClass(oUL, <span class="literal">"hastitle"</span>);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
<span class="reserved">while</span>(i < nListElements);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "render" Custom Event handler for a MenuModule instance.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
|
|
* fired the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onRender =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oMenuModule) {
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.cfg.getProperty(<span class="literal">"position"</span>) == <span class="literal">"dynamic"</span>) {
|
|
|
|
var sWidth = <span class="reserved">this</span>.element.parentNode.tagName == <span class="literal">"BODY"</span> ?
|
|
<span class="reserved">this</span>.element.offsetWidth : <span class="reserved">this</span>._getOffsetWidth();
|
|
|
|
<span class="reserved">this</span>.cfg.setProperty(<span class="literal">"width"</span>, (sWidth + <span class="literal">"px"</span>));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "show" Custom Event handler for a MenuModule instance.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
|
|
* fired the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onShow =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oMenuModule) {
|
|
|
|
<span class="comment">/*
|
|
Setting focus to an item in the newly visible submenu alerts the
|
|
contents of the submenu to the screen reader.
|
|
*/</span>
|
|
|
|
<span class="reserved">this</span>.setInitialFocus();
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "hide" Custom Event handler for a MenuModule instance.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
|
|
* fired the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onBeforeHide =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oMenuModule) {
|
|
|
|
var oActiveItem = <span class="reserved">this</span>.activeItem;
|
|
|
|
<span class="reserved">if</span>(oActiveItem) {
|
|
|
|
oActiveItem.blur();
|
|
|
|
<span class="reserved">if</span>(oActiveItem.cfg.getProperty(<span class="literal">"selected"</span>)) {
|
|
|
|
oActiveItem.cfg.setProperty(<span class="literal">"selected"</span>, false);
|
|
|
|
}
|
|
|
|
var oSubmenu = oActiveItem.cfg.getProperty(<span class="literal">"submenu"</span>);
|
|
|
|
<span class="reserved">if</span>(oSubmenu && oSubmenu.cfg.getProperty(<span class="literal">"visible"</span>)) {
|
|
|
|
oSubmenu.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "configchange" Custom Event handler for a submenu.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oSubmenu The submenu that subscribed
|
|
* to the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onParentMenuModuleConfigChange =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oSubmenu) {
|
|
|
|
var sPropertyName = p_aArgs[0][0];
|
|
var oPropertyValue = p_aArgs[0][1];
|
|
|
|
switch(sPropertyName) {
|
|
|
|
case <span class="literal">"iframe"</span>:
|
|
case <span class="literal">"constraintoviewport"</span>:
|
|
|
|
p_oSubmenu.cfg.setProperty(sPropertyName, oPropertyValue);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "render" Custom Event handler for a MenuModule instance. Renders a
|
|
* submenu in response to the firing of it's parent's "render" event.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oSubmenu The submenu that subscribed
|
|
* to the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onParentMenuModuleRender =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oSubmenu) {
|
|
|
|
<span class="comment">/*
|
|
Set the "constraintoviewport" configuration
|
|
property to match the parent MenuModule
|
|
*/</span>
|
|
|
|
var oParentMenu = p_oSubmenu.parent.parent;
|
|
|
|
var oConfig = {
|
|
|
|
constraintoviewport:
|
|
oParentMenu.cfg.getProperty(<span class="literal">"constraintoviewport"</span>),
|
|
|
|
xy: [0,0]
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/*
|
|
Only sync the "iframe" configuration property if the parent
|
|
MenuModule instance's position is of the same value
|
|
*/</span>
|
|
|
|
<span class="reserved">if</span>(
|
|
<span class="reserved">this</span>.cfg.getProperty(<span class="literal">"position"</span>) ==
|
|
oParentMenu.cfg.getProperty(<span class="literal">"position"</span>)
|
|
) {
|
|
|
|
oConfig.iframe = oParentMenu.cfg.getProperty(<span class="literal">"iframe"</span>);
|
|
|
|
}
|
|
|
|
|
|
p_oSubmenu.cfg.applyConfig(oConfig);
|
|
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>._oDom.inDocument(<span class="reserved">this</span>.element)) {
|
|
|
|
<span class="reserved">this</span>.render();
|
|
|
|
}
|
|
<span class="reserved">else</span> {
|
|
|
|
<span class="reserved">this</span>.render(<span class="reserved">this</span>.parent.element);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "beforeshow" Custom Event handler for a submenu.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oSubmenu The submenu that fired
|
|
* the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onSubmenuBeforeShow =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oSubmenu) {
|
|
|
|
var oParent = <span class="reserved">this</span>.parent;
|
|
var aAlignment = oParent.parent.cfg.getProperty(<span class="literal">"submenualignment"</span>);
|
|
|
|
<span class="reserved">this</span>.cfg.setProperty(
|
|
<span class="literal">"context"</span>,
|
|
[
|
|
oParent.element,
|
|
aAlignment[0],
|
|
aAlignment[1]
|
|
]
|
|
);
|
|
|
|
oParent.submenuIndicator.alt =
|
|
oParent.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "show" Custom Event handler for a submenu.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oSubmenu The submenu that fired
|
|
* the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onSubmenuShow =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oSubmenu) {
|
|
|
|
var oParent = <span class="reserved">this</span>.parent;
|
|
|
|
oParent.submenuIndicator.alt =
|
|
oParent.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "hide" Custom Event handler for a submenu.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oSubmenu The submenu that fired
|
|
* the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onSubmenuHide =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oSubmenu) {
|
|
|
|
var oParent = <span class="reserved">this</span>.parent;
|
|
|
|
<span class="reserved">if</span>(oParent.parent.cfg.getProperty(<span class="literal">"visible"</span>)) {
|
|
|
|
oParent.cfg.setProperty(<span class="literal">"selected"</span>, false);
|
|
|
|
oParent.focus();
|
|
|
|
}
|
|
|
|
oParent.submenuIndicator.alt =
|
|
oParent.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "focus" YAHOO.util.CustomEvent handler for a MenuModule instance's items.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aObjects Array containing the current MenuModule instance
|
|
* and the item that fired the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onItemFocus =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_aObjects) {
|
|
|
|
var me = p_aObjects[0];
|
|
var oItem = p_aObjects[1];
|
|
|
|
me.activeItem = oItem;
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "blur" YAHOO.util.CustomEvent handler for a MenuModule instance's items.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aObjects Array containing the current MenuModule instance
|
|
* and the item that fired the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onItemBlur =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_aObjects) {
|
|
|
|
var me = p_aObjects[0];
|
|
var oItem = p_aObjects[1];
|
|
var oSubmenu = oItem.cfg.getProperty(<span class="literal">"submenu"</span>);
|
|
|
|
<span class="reserved">if</span>(!oSubmenu || (oSubmenu && !oSubmenu.cfg.getProperty(<span class="literal">"visible"</span>))) {
|
|
|
|
me.activeItem = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* "configchange" YAHOO.util.CustomEvent handler for the MenuModule
|
|
* instance's items.
|
|
* <span class="attrib">@private</span>
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the
|
|
* event was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aObjects Array containing the current MenuModule instance
|
|
* and the item that fired the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>._onItemConfigChange =
|
|
|
|
<span class="reserved">function</span>(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 <span class="literal">"submenu"</span>:
|
|
|
|
var oSubmenu = p_aArgs[0][1];
|
|
|
|
<span class="reserved">if</span>(oSubmenu) {
|
|
|
|
me._configureItemSubmenuModule(oItem);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case <span class="literal">"text"</span>:
|
|
case <span class="literal">"helptext"</span>:
|
|
|
|
<span class="comment">/*
|
|
A change to an item's "text" or "helptext"
|
|
configuration properties requires the width of the parent
|
|
MenuModule instance to be recalculated.
|
|
*/</span>
|
|
|
|
<span class="reserved">if</span>(me.element.style.width) {
|
|
|
|
var sWidth = me._getOffsetWidth() + <span class="literal">"px"</span>;
|
|
|
|
me._oDom.setStyle(me.element, <span class="literal">"width"</span>, sWidth);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* The default event handler executed when the moveEvent is fired, if the
|
|
* "constraintoviewport" configuration property is set to true.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.enforceConstraints =
|
|
|
|
<span class="reserved">function</span>(type, args, obj) {
|
|
|
|
var Dom = <span class="reserved">this</span>._oDom;
|
|
var oConfig = <span class="reserved">this</span>.cfg;
|
|
|
|
var pos = args[0];
|
|
|
|
var x = pos[0];
|
|
var y = pos[1];
|
|
|
|
var bod = document.getElementsByTagName(<span class="literal">'body'</span>)[0];
|
|
var htm = document.getElementsByTagName(<span class="literal">'html'</span>)[0];
|
|
|
|
var bodyOverflow = Dom.getStyle(bod, <span class="literal">"overflow"</span>);
|
|
var htmOverflow = Dom.getStyle(htm, <span class="literal">"overflow"</span>);
|
|
|
|
var offsetHeight = <span class="reserved">this</span>.element.offsetHeight;
|
|
var offsetWidth = <span class="reserved">this</span>.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(<span class="literal">"context"</span>);
|
|
var oContextElement = aContext ? aContext[0] : null;
|
|
|
|
|
|
<span class="reserved">if</span> (x < 10) {
|
|
|
|
x = leftConstraint;
|
|
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> ((x + offsetWidth) > viewPortWidth) {
|
|
|
|
<span class="reserved">if</span>(
|
|
oContextElement &&
|
|
((x - oContextElement.offsetWidth) > offsetWidth)
|
|
) {
|
|
|
|
x = (x - (oContextElement.offsetWidth + offsetWidth));
|
|
|
|
}
|
|
<span class="reserved">else</span> {
|
|
|
|
x = rightConstraint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
<span class="reserved">if</span> (y < 10) {
|
|
|
|
y = topConstraint;
|
|
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (y > bottomConstraint) {
|
|
|
|
<span class="reserved">if</span>(oContextElement && (y > offsetHeight)) {
|
|
|
|
y = ((y + oContextElement.offsetHeight) - offsetHeight);
|
|
|
|
}
|
|
<span class="reserved">else</span> {
|
|
|
|
y = bottomConstraint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
oConfig.setProperty(<span class="literal">"x"</span>, x, true);
|
|
oConfig.setProperty(<span class="literal">"y"</span>, y, true);
|
|
|
|
};
|
|
<span class="comment">
|
|
|
|
// Event handlers for configuration properties</span>
|
|
|
|
<span class="comment">/**
|
|
* Event handler for when the "position" configuration property of a
|
|
* MenuModule changes.
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance fired
|
|
* the event.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.configPosition =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oMenuModule) {
|
|
|
|
var sCSSPosition = p_aArgs[0] == <span class="literal">"static"</span> ? <span class="literal">"static"</span> : <span class="literal">"absolute"</span>;
|
|
|
|
<span class="reserved">this</span>._oDom.setStyle(<span class="reserved">this</span>.element, <span class="literal">"position"</span>, sCSSPosition);
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Event handler for when the "iframe" configuration property of a
|
|
* MenuModule changes.
|
|
* <span class="attrib">@param</span> {String} p_sType The name of the event that was fired.
|
|
* <span class="attrib">@param</span> {Array} p_aArgs Collection of arguments sent when the event
|
|
* was fired.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance fired
|
|
* the event.
|
|
* <span class="attrib">@see</span> YAHOO.widget.Overlay#configIframe
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.configIframe =
|
|
|
|
<span class="reserved">function</span>(p_sType, p_aArgs, p_oMenuModule) {
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.cfg.getProperty(<span class="literal">"position"</span>) == <span class="literal">"dynamic"</span>) {
|
|
|
|
YAHOO.widget.MenuModule.superclass.configIframe.call(
|
|
<span class="reserved">this</span>,
|
|
p_sType,
|
|
p_aArgs,
|
|
p_oMenuModule
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
<span class="comment">
|
|
// Public methods</span>
|
|
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.toString = <span class="reserved">function</span>() {
|
|
|
|
<span class="reserved">return</span> (<span class="literal">"Menu "</span> + <span class="reserved">this</span>.id);
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Sets the title of a group of items.
|
|
* <span class="attrib">@param</span> {String} p_sGroupTitle The title of the group.
|
|
* <span class="attrib">@param</span> {Number} p_nGroupIndex Optional. Number indicating the group to which
|
|
* the title belongs.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.setItemGroupTitle =
|
|
|
|
<span class="reserved">function</span>(p_sGroupTitle, p_nGroupIndex) {
|
|
|
|
<span class="reserved">if</span>(typeof p_sGroupTitle == <span class="literal">"string"</span> && p_sGroupTitle.length > 0) {
|
|
|
|
var Dom = <span class="reserved">this</span>._oDom;
|
|
|
|
var nGroupIndex =
|
|
typeof p_nGroupIndex == <span class="literal">"number"</span> ? p_nGroupIndex : 0;
|
|
|
|
var oTitle = <span class="reserved">this</span>._aGroupTitleElements[nGroupIndex];
|
|
|
|
|
|
<span class="reserved">if</span>(oTitle) {
|
|
|
|
oTitle.innerHTML = p_sGroupTitle;
|
|
|
|
}
|
|
<span class="reserved">else</span> {
|
|
|
|
oTitle = document.createElement(<span class="reserved">this</span>.GROUP_TITLE_TAG_NAME);
|
|
|
|
oTitle.innerHTML = p_sGroupTitle;
|
|
|
|
<span class="reserved">this</span>._aGroupTitleElements[nGroupIndex] = oTitle;
|
|
|
|
}
|
|
|
|
|
|
var i = <span class="reserved">this</span>._aGroupTitleElements.length - 1;
|
|
var nFirstIndex;
|
|
|
|
do {
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>._aGroupTitleElements[i]) {
|
|
|
|
Dom.removeClass(
|
|
<span class="reserved">this</span>._aGroupTitleElements[i],
|
|
<span class="literal">"first-of-type"</span>
|
|
);
|
|
|
|
nFirstIndex = i;
|
|
|
|
}
|
|
|
|
}
|
|
<span class="reserved">while</span>(i--);
|
|
|
|
|
|
<span class="reserved">if</span>(nFirstIndex !== null) {
|
|
|
|
Dom.addClass(
|
|
<span class="reserved">this</span>._aGroupTitleElements[nFirstIndex],
|
|
<span class="literal">"first-of-type"</span>
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Appends the specified item to a MenuModule instance.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModuleItem} p_oItem The item to be added.
|
|
* <span class="attrib">@param</span> {Number} p_nGroupIndex Optional. Number indicating the group to which
|
|
* the item belongs.
|
|
* <span class="attrib">@return</span> The item that was added to the MenuModule.
|
|
* <span class="attrib">@type</span> YAHOO.widget.MenuModuleItem
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.addItem = <span class="reserved">function</span>(p_oItem, p_nGroupIndex) {
|
|
|
|
<span class="reserved">if</span>(p_oItem) {
|
|
|
|
<span class="reserved">return</span> <span class="reserved">this</span>._addItemToGroup(p_nGroupIndex, p_oItem);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Inserts an item into a MenuModule instance at the specified index.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModuleItem} p_oItem The item to be inserted.
|
|
* <span class="attrib">@param</span> {Number} p_nItemIndex Number indicating the ordinal position
|
|
* at which the item should be added.
|
|
* <span class="attrib">@param</span> {Number} p_nGroupIndex Optional. Number indicating the group to which
|
|
* the item belongs.
|
|
* <span class="attrib">@return</span> The item that was inserted into the MenuModule.
|
|
* <span class="attrib">@type</span> YAHOO.widget.MenuModuleItem
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.insertItem =
|
|
|
|
<span class="reserved">function</span>(p_oItem, p_nItemIndex, p_nGroupIndex) {
|
|
|
|
<span class="reserved">if</span>(p_oItem) {
|
|
|
|
<span class="reserved">return</span> <span class="reserved">this</span>._addItemToGroup(p_nGroupIndex, p_oItem, p_nItemIndex);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Removes the specified item from a MenuModule instance.
|
|
* <span class="attrib">@param</span> {YAHOO.widget.MenuModuleItem/Number} p_oObject The item or index of
|
|
* the item to be removed.
|
|
* <span class="attrib">@param</span> {Number} p_nGroupIndex Optional. Number indicating the group to which
|
|
* the item belongs.
|
|
* <span class="attrib">@return</span> The item that was removed from the MenuModule.
|
|
* <span class="attrib">@type</span> YAHOO.widget.MenuModuleItem
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.removeItem =
|
|
|
|
<span class="reserved">function</span>(p_oObject, p_nGroupIndex) {
|
|
|
|
<span class="reserved">if</span>(typeof p_oObject != <span class="literal">"undefined"</span>) {
|
|
|
|
var oItem;
|
|
|
|
<span class="reserved">if</span>(p_oObject instanceof YAHOO.widget.MenuModuleItem) {
|
|
|
|
oItem =
|
|
<span class="reserved">this</span>._removeItemFromGroupByValue(p_nGroupIndex, p_oObject);
|
|
|
|
}
|
|
<span class="reserved">else</span> <span class="reserved">if</span>(typeof p_oObject == <span class="literal">"number"</span>) {
|
|
|
|
oItem =
|
|
<span class="reserved">this</span>._removeItemFromGroupByIndex(p_nGroupIndex, p_oObject);
|
|
|
|
}
|
|
|
|
<span class="reserved">if</span>(oItem) {
|
|
|
|
oItem.destroy();
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Item removed."</span> +
|
|
<span class="literal">" Text: "</span> + oItem.cfg.getProperty(<span class="literal">"text"</span>) + <span class="literal">", "</span> +
|
|
<span class="literal">" Index: "</span> + oItem.index + <span class="literal">", "</span> +
|
|
<span class="literal">" Group Index: "</span> + oItem.groupIndex);
|
|
|
|
<span class="reserved">return</span> oItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Returns a multi-dimensional array of all of a MenuModule's items.
|
|
* <span class="attrib">@return</span> An array of items.
|
|
* <span class="attrib">@type</span> Array
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.getItemGroups = <span class="reserved">function</span>() {
|
|
|
|
<span class="reserved">return</span> <span class="reserved">this</span>._aItemGroups;
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Returns the item at the specified index.
|
|
* <span class="attrib">@param</span> {Number} p_nItemIndex Number indicating the ordinal position of the
|
|
* item to be retrieved.
|
|
* <span class="attrib">@param</span> {Number} p_nGroupIndex Optional. Number indicating the group to which
|
|
* the item belongs.
|
|
* <span class="attrib">@return</span> An item.
|
|
* <span class="attrib">@type</span> YAHOO.widget.MenuModuleItem
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.getItem =
|
|
|
|
<span class="reserved">function</span>(p_nItemIndex, p_nGroupIndex) {
|
|
|
|
<span class="reserved">if</span>(typeof p_nItemIndex == <span class="literal">"number"</span>) {
|
|
|
|
var aGroup = <span class="reserved">this</span>._getItemGroup(p_nGroupIndex);
|
|
|
|
<span class="reserved">if</span>(aGroup) {
|
|
|
|
<span class="reserved">return</span> aGroup[p_nItemIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Removes the MenuModule instance's element from the DOM and sets all child
|
|
* elements to null.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.destroy = <span class="reserved">function</span>() {
|
|
<span class="comment">
|
|
|
|
// Remove Custom Event listeners</span>
|
|
|
|
<span class="reserved">this</span>.mouseOverEvent.unsubscribeAll();
|
|
<span class="reserved">this</span>.mouseOutEvent.unsubscribeAll();
|
|
<span class="reserved">this</span>.mouseDownEvent.unsubscribeAll();
|
|
<span class="reserved">this</span>.mouseUpEvent.unsubscribeAll();
|
|
<span class="reserved">this</span>.clickEvent.unsubscribeAll();
|
|
<span class="reserved">this</span>.keyPressEvent.unsubscribeAll();
|
|
<span class="reserved">this</span>.keyDownEvent.unsubscribeAll();
|
|
<span class="reserved">this</span>.keyUpEvent.unsubscribeAll();
|
|
|
|
|
|
var nItemGroups = <span class="reserved">this</span>._aItemGroups.length;
|
|
var nItems;
|
|
var oItemGroup;
|
|
var oItem;
|
|
var i;
|
|
var n;
|
|
<span class="comment">
|
|
|
|
// Remove all items</span>
|
|
|
|
<span class="reserved">if</span>(nItemGroups > 0) {
|
|
|
|
i = nItemGroups - 1;
|
|
|
|
do {
|
|
|
|
oItemGroup = <span class="reserved">this</span>._aItemGroups[i];
|
|
|
|
<span class="reserved">if</span>(oItemGroup) {
|
|
|
|
nItems = oItemGroup.length;
|
|
|
|
<span class="reserved">if</span>(nItems > 0) {
|
|
|
|
n = nItems - 1;
|
|
|
|
do {
|
|
|
|
oItem = <span class="reserved">this</span>._aItemGroups[i][n];
|
|
|
|
<span class="reserved">if</span>(oItem) {
|
|
|
|
oItem.destroy();
|
|
}
|
|
|
|
}
|
|
<span class="reserved">while</span>(n--);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
<span class="reserved">while</span>(i--);
|
|
|
|
}
|
|
<span class="comment">
|
|
|
|
// Continue with the superclass implementation of this method</span>
|
|
|
|
YAHOO.widget.MenuModule.superclass.destroy.call(<span class="reserved">this</span>);
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Destroyed."</span>);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
<span class="comment">/**
|
|
* Sets focus to a MenuModule instance's first enabled item.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.setInitialFocus = <span class="reserved">function</span>() {
|
|
|
|
var oItem = <span class="reserved">this</span>._getFirstEnabledItem();
|
|
|
|
<span class="reserved">if</span>(oItem) {
|
|
|
|
oItem.focus();
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Sets the "selected" configuration property of a MenuModule instance's first
|
|
* enabled item to "true."
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.setInitialSelection = <span class="reserved">function</span>() {
|
|
|
|
var oItem = <span class="reserved">this</span>._getFirstEnabledItem();
|
|
|
|
<span class="reserved">if</span>(oItem) {
|
|
|
|
oItem.cfg.setProperty(<span class="literal">"selected"</span>, true);
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Sets the "selected" configuration property of a MenuModule instance's active
|
|
* item to "false," blurs the item and hide's the item's submenu.
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.clearActiveItem = <span class="reserved">function</span> () {
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.activeItem) {
|
|
|
|
var oConfig = <span class="reserved">this</span>.activeItem.cfg;
|
|
|
|
oConfig.setProperty(<span class="literal">"selected"</span>, false);
|
|
|
|
var oSubmenu = oConfig.getProperty(<span class="literal">"submenu"</span>);
|
|
|
|
<span class="reserved">if</span>(oSubmenu) {
|
|
|
|
oSubmenu.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Initializes the class's configurable properties which can be changed using
|
|
* the MenuModule's Config object (cfg).
|
|
*/</span>
|
|
YAHOO.widget.MenuModule.<span class="reserved">prototype</span>.initDefaultConfig = <span class="reserved">function</span>() {
|
|
|
|
YAHOO.widget.MenuModule.superclass.initDefaultConfig.call(<span class="reserved">this</span>);
|
|
|
|
var oConfig = <span class="reserved">this</span>.cfg;
|
|
<span class="comment">
|
|
// Add configuration properties</span>
|
|
|
|
oConfig.addProperty(
|
|
<span class="literal">"position"</span>,
|
|
{
|
|
value: <span class="literal">"dynamic"</span>,
|
|
handler: <span class="reserved">this</span>.configPosition,
|
|
validator: <span class="reserved">this</span>._checkPosition
|
|
}
|
|
);
|
|
<span class="comment">
|
|
// this.cfg.refireEvent("position");</span>
|
|
|
|
oConfig.addProperty(<span class="literal">"submenualignment"</span>, { value: [<span class="literal">"tl"</span>,<span class="literal">"tr"</span>] } );
|
|
|
|
};
|
|
</pre>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="footer">
|
|
|
|
<hr />
|
|
|
|
Copyright © 2006 Yahoo! Inc. All rights reserved.
|
|
|
|
<br /><br />
|
|
|
|
Documentation generated by <a href="http://jsdoc.sourceforge.net/">
|
|
|
|
JSDoc</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|