API: menu YAHOO.widget.MenuBar (YUI Library)

# Yahoo! UI Library

### Menu 2.9.0

Yahoo! UI Library > menu > YAHOO.widget.MenuBar
Search:
Filters Show Private Show Protected Show Deprecated

## Class YAHOO.widget.MenuBar - extends YAHOO.widget.Menu

Horizontal collection of items, each of which can contain a submenu.

### Constructor

YAHOO.widget.MenuBar `( p_oElement , p_oConfig )`

Parameters:
  `p_oElement <String>` String specifying the id attribute of the `<div>` element of the menu bar.
  `p_oElement <String>` String specifying the id attribute of the `<select>` element to be used as the data source for the menu bar.
  `p_oElement <HTMLDivElement>` Object specifying the `<div>` element of the menu bar.
  `p_oElement <HTMLSelectElement>` Object specifying the `<select>` element to be used as the data source for the menu bar.
  `p_oConfig <Object>` Optional. Object literal specifying the configuration for the menu bar. See configuration class documentation for more details.

### Properties

#### CSS_CLASS_NAME - `final String`

String representing the CSS class(es) to be applied to the menu bar's `<div>` element.
Default Value: "yuimenubar"

#### SUBMENU_TOGGLE_REGION_WIDTH - `final Number`

Width (in pixels) of the area of a MenuBarItem that, when pressed, will toggle the display of the MenuBarItem's submenu.
Default Value: 20

#### Properties inherited from YAHOO.widget.Overlay:

`CONTEXT_TRIGGERS, DEFAULT_CONFIG, EVENT_TYPES, YAHOO.widget.Overlay._initialized`

#### Properties inherited from YAHOO.widget.Module:

`body, browser, cacheEffects, cfg, contructor, DEFAULT_CONFIG, element, EVENT_TYPES, footer, header, id, imageRoot, isSecure, platform`

#### Properties inherited from YAHOO.widget.Menu:

`_aGroupTitleElements, _aItemGroups, _aListElements, _bHandledMouseOutEvent, _bHandledMouseOverEvent, _bStopMouseEventHandlers, _nCurrentMouseX, _sClassName, _useHideDelay, activeItem, CSS_CLASS_NAME, GROUP_TITLE_TAG_NAME, ITEM_TYPE, itemData, lazyLoad, OFF_SCREEN_POSITION, parent, srcElement`

### Methods

#### _onClick

`protected void _onClick ( p_sType , p_aArgs , p_oMenuBar )`
"click" event handler for the menu bar.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.
  `p_oMenuBar <YAHOO.widget.MenuBar>` Object representing the menu bar that fired the event.

#### _onKeyDown

`private void _onKeyDown ( p_sType , p_aArgs , p_oMenuBar )`
"keydown" Custom Event handler for the menu bar.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.
  `p_oMenuBar <YAHOO.widget.MenuBar>` Object representing the menu bar that fired the event.

#### checkPosition

`private Boolean checkPosition ( p_sPosition )`
Checks to make sure that the value of the "position" property is one of the supported strings. Returns true if the position is supported.

Parameters:
  `p_sPosition <Object>` String specifying the position of the menu.

#### configSubmenuToggle

`void configSubmenuToggle ( p_sType , p_aArgs )`
Event handler for when the "submenutoggleregion" configuration property of a MenuBar changes.

Parameters:
  `p_sType <String>` The name of the event that was fired.
  `p_aArgs <Array>` Collection of arguments sent when the event was fired.

#### init

`void init ( p_oElement , p_oConfig )`
The MenuBar 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.

Parameters:
  `p_oElement <String>` String specifying the id attribute of the `<div>` element of the menu bar.
  `p_oElement <String>` String specifying the id attribute of the `<select>` element to be used as the data source for the menu bar.
  `p_oElement <HTMLDivElement>` Object specifying the `<div>` element of the menu bar.
  `p_oElement <HTMLSelectElement>` Object specifying the `<select>` element to be used as the data source for the menu bar.
  `p_oConfig <Object>` Optional. Object literal specifying the configuration for the menu bar. See configuration class documentation for more details.

#### initDefaultConfig

`void initDefaultConfig ( )`
Initializes the class's configurable properties which can be changed using the menu bar's Config object ("cfg").

#### toString

`String toString ( )`
Returns a string representing the menu bar.

#### Methods inherited from YAHOO.widget.Overlay:

`_alignOnTrigger, _autoFillOnHeightChange, _findTriggerCE, _getComputedHeight, _getConstrainedPos, _getPreciseHeight, _preventOverlap, _primeXYFromDOM, _processTriggers, _setDomVisibility, _validateAutoFillHeight, align, bringToTop, center, configAutoFillHeight, configConstrainToViewport, configContext, configFixedCenter, configHeight, configIframe, configVisible, configWidth, configX, configXY, configY, configzIndex, destroy, doCenterOnDOMEvent, enforceConstraints, fillHeight, fitsInViewport, forceContainerRedraw, getConstrainedX, getConstrainedXY, getConstrainedY, hideIframe, hideMacGeckoScrollbars, init, initDefaultConfig, initEvents, moveTo, onDomResize, showIframe, showMacGeckoScrollbars, stackIframe, syncIframe, syncPosition, toString`

#### Methods inherited from YAHOO.widget.Module:

`_addToParent, _createEffects, _initResizeMonitor, _renderBody, _renderFooter, _renderHeader, _supportsCWResize, appendToBody, appendToFooter, appendToHeader, configEffect, configMonitorResize, configVisible, destroy, hide, init, initDefaultConfig, initEvents, initResizeMonitor, onDomResize, render, setBody, setFooter, setHeader, show, toString`

#### Methods inherited from YAHOO.widget.Menu:

`_addItemToGroup, _addShadowVisibleClass, _cancelHideDelay, _cancelShowDelay, _clearSetWidthFlag, _configureSubmenu, _createItemGroup, _createShadow, _didMouseLeave, _disableScrollFooter, _disableScrollHeader, _enableScrollFooter, _enableScrollHeader, _execHideDelay, _execSubmenuHideDelay, _getFirstEnabledItem, _getItemGroup, _initSubTree, _onBeforeHide, _onBeforeRender, _onBeforeShow, _onBlur, _onClick, _onHide, _onInit, _onItemAdded, _onKeyDown, _onKeyPress, _onMenuItemConfigChange, _onMenuItemDestroy, _onMouseMove, _onMouseOut, _onMouseOver, _onParentMenuConfigChange, _onParentMenuRender, _onRender, _onScrollTargetMouseOut, _onScrollTargetMouseOver, _onShow, _onVisibleChange, _onYChange, _removeItemFromGroupByIndex, _removeItemFromGroupByValue, _removeShadow, _removeShadowVisibleClass, _replaceShadow, _setMaxHeight, _setScrollHeight, _shadowBeforeShow, _sizeShadow, _stopMouseEventHandlers, _subscribeScrollHandlers, _subscribeToItemEvents, _unsubscribeScrollHandlers, _updateItemProperties, addItem, addItems, blur, checkPosition, clearActiveItem, clearContent, configClassName, configContainer, configDisabled, configHideDelay, configIframe, configMaxHeight, configPosition, configShadow, configVisible, destroy, focus, getItem, getItemGroups, getItems, getRoot, getSubmenus, hasFocus, init, initDefaultConfig, initEvents, insertItem, positionOffScreen, removeItem, setInitialFocus, setInitialSelection, setItemGroupTitle, subscribe, toString`

#### Events inherited from YAHOO.widget.Overlay:

`beforeMoveEvent, moveEvent, YAHOO.widget.Overlay.windowResizeEvent, YAHOO.widget.Overlay.windowScrollEvent,`

#### Events inherited from YAHOO.widget.Module:

`appendEvent, beforeHideEvent, beforeInitEvent, beforeRenderEvent, beforeShowEvent, changeBodyEvent, changeContentEvent, changeFooterEvent, changeHeaderEvent, destroyEvent, hideEvent, initEvent, renderEvent showEvent YAHOO.widget.Module.textResizeEvent`

#### Events inherited from YAHOO.widget.Menu:

`clickEvent, itemAddedEvent, itemRemovedEvent, keyDownEvent, keyPressEvent, keyUpEvent, mouseDownEvent, mouseOutEvent, mouseOverEvent, mouseUpEvent,`

### Configuration Attributes

#### autosubmenudisplay `- Boolean`

Boolean indicating if submenus are automatically made visible when the user mouses over the menu bar's items.
Default Value: false

#### position `- String`

String indicating how a menu bar should be positioned on the screen. Possible values are "static" and "dynamic." Static menu bars are visible by default and reside in the normal flow of the document (CSS position: static). Dynamic menu bars are hidden by default, reside out of the normal flow of the document (CSS position: absolute), and can overlay other elements on the screen.
Default Value: static

#### submenualignment `- Array`

Array defining how submenus should be aligned to their parent menu bar item. The format is: [itemCorner, submenuCorner].
Default Value: ["tl","bl"]

#### submenutoggleregion `- Boolean`

Boolean indicating if only a specific region of a MenuBarItem should toggle the display of a submenu. The default width of the region is determined by the value of the SUBMENU_TOGGLE_REGION_WIDTH property. If set to true, the autosubmenudisplay configuration property will be set to false, and any click event listeners will not be called when the user clicks inside the submenu toggle region of a MenuBarItem. If the user clicks outside of the submenu toggle region, the MenuBarItem will maintain its standard behavior.
Default Value: false

#### Configuration attributes inherited from YAHOO.widget.Overlay:

`autofillheight, constraintoviewport, context, fixedcenter, height, iframe preventcontextoverlap width x xy y zIndex`

#### Configuration attributes inherited from YAHOO.widget.Module:

`appendtodocumentbody, effect monitorresize visible`

#### Configuration attributes inherited from YAHOO.widget.Menu:

`autosubmenudisplay, classname, clicktohide, constraintoviewport, container, context, disabled, effect, fixedcenter, hidedelay, iframe, keepopen, maxheight minscrollheight position preventcontextoverlap scrollincrement shadow showdelay submenualignment submenuhidedelay visible x xy y`

Copyright © 2011 Yahoo! Inc. All rights reserved.