Yahoo! UI Library

Menu Library 

Yahoo! UI Library > menu > YAHOO.widget.MenuItem

Class YAHOO.widget.MenuItem

Known Subclasses:
YAHOO.widget.ContextMenuItem YAHOO.widget.MenuBarItem
Creates an item for a menu.

Constructor

YAHOO.widget.MenuItem ( p_oObject , p_oConfig )
Parameters:
p_oObject <String> String specifying the text of the menu item.
p_oObject <HTMLLIElement> Object specifying the <li> element of the menu item.
p_oObject <HTMLOptGroupElement> Object specifying the <optgroup> element of the menu item.
p_oObject <HTMLOptionElement> Object specifying the <option> element of the menu item.
p_oConfig <Object> Optional. Object literal specifying the configuration for the menu item. See configuration class documentation for more details.

Properties

_checkImage - private HTMLImageElement

Object reference to the menu item's checkmark image.
Default Value: null

_oAnchor - private HTMLAnchorElement

Object reference to the menu item's <a> element.
Default Value: null

_oHelpTextEM - private HTMLElement

Object reference to the menu item's help text <em> element.
Default Value: null

_oSubmenu - private YAHOO.widget.Menu

Object reference to the menu item's submenu.
Default Value: null

_oText - private TextNode

Object reference to the menu item's text node.
Default Value: null

browser - String

String representing the browser.

CHECKED_IMAGE_ALT_TEXT - final String

String representing the alt text for the image to be used for the checked image.
Default Value: "Checked."

CHECKED_IMAGE_PATH - final String

String representing the path to the image to be used for the checked state.
Default Value: "nt/ic/ut/bsc/menuchk8_nrm_1.gif"

COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT - final String

String representing the alt text for the image to be used for the submenu arrow indicator.
Default Value: "Collapsed. Click to expand."

constructor - YAHOO.widget.MenuItem

Object reference to the menu item's constructor function.
Default Value: YAHOO.widget.MenuItem

CSS_CLASS_NAME - final String

String representing the CSS class(es) to be applied to the <li> element of the menu item.
Default Value: "yuimenuitem"

DISABLED_CHECKED_IMAGE_ALT_TEXT - final String

String representing the alt text for the image to be used for the checked image when the item is disabled.
Default Value: "Checked. (Item disabled.)"

DISABLED_CHECKED_IMAGE_PATH - final String

String representing the path to the image to be used for the disabled checked state.
Default Value: "nt/ic/ut/bsc/menuchk8_dim_1.gif"

DISABLED_SUBMENU_INDICATOR_ALT_TEXT - final String

String representing the alt text for the image to be used for the submenu arrow indicator when the menu item is disabled.
Default Value: "Disabled."

DISABLED_SUBMENU_INDICATOR_IMAGE_PATH - final String

String representing the path to the image to be used for the submenu arrow indicator when the menu item is disabled.
Default Value: "nt/ic/ut/alt1/menuarorght8_dim_1.gif"

element - HTMLLIElement

Object reference to the menu item's <li> element.
Default Value: HTMLLIElement

EXPANDED_SUBMENU_INDICATOR_ALT_TEXT - final String

String representing the alt text for the image to be used for the submenu arrow indicator when the submenu is visible.
Default Value: "Expanded. Click to collapse."

groupIndex - Number

Number indicating the index of the group to which the menu item belongs.
Default Value: null

imageRoot - String

String representing the root path for all of the menu item's images.

IMG_ROOT - String

String representing the prefix path to use for non-secure images.
Default Value: "http://us.i1.yimg.com/us.yimg.com/i/"

IMG_ROOT_SSL - String

String representing the prefix path to use for securely served images.
Default Value: "https://a248.e.akamai.net/sec.yimg.com/i/"

index - Number

Number indicating the ordinal position of the menu item in its group.
Default Value: null

isSecure - Boolean

Boolean representing whether or not the current browsing context is secure (HTTPS).

parent - YAHOO.widget.Menu

Object reference to the menu item's parent menu.
Default Value: null

SELECTED_CHECKED_IMAGE_PATH - final String

String representing the path to the image to be used for the selected checked state.
Default Value: "nt/ic/ut/bsc/menuchk8_hov_1.gif"

SELECTED_SUBMENU_INDICATOR_IMAGE_PATH - final String

String representing the path to the image to be used for the submenu arrow indicator when the menu item is selected.
Default Value: "nt/ic/ut/alt1/menuarorght8_hov_1.gif"

srcElement - HTMLLIElement| HTMLOptGroupElement|HTMLOptionElement

Object reference to the HTML element (either <li>, <optgroup> or <option>) used create the menu item.

SUBMENU_INDICATOR_IMAGE_PATH - final String

String representing the path to the image to be used for the menu item's submenu arrow indicator.
Default Value: "nt/ic/ut/alt1/menuarorght8_nrm_1.gif"

SUBMENU_TYPE - final YAHOO.widget.Menu

Object representing the type of menu to instantiate and add when parsing the child nodes of the menu item's source HTML element.

submenuIndicator - HTMLImageElement

Object reference to the <img> element used to create the submenu indicator for the menu item.
Default Value: HTMLImageElement

value - Object

Object reference to the menu item's value.
Default Value: null

Methods

_checkDOMNode

private Boolean _checkDOMNode ( p_oObject )
Determines if an object is an HTML element.
Parameters:
p_oObject <Object> Object to be evaluated.
Returns: Boolean

_checkString

private Boolean _checkString ( p_oObject )
Determines if an object is a string.
Parameters:
p_oObject <Object> Object to be evaluated.
Returns: Boolean

_createRootNodeStructure

private void _createRootNodeStructure ( )
Creates the core DOM structure for the menu item.
Returns: void

_getFirstElement

private HTMLElement _getFirstElement ( p_oElement , p_sTagName )
Returns an HTML element's first HTML element node.
Parameters:
p_oElement <HTMLElement> Object reference specifying the element to be evaluated.
p_sTagName <String> Optional. String specifying the tagname of the element to be retrieved.
Returns: HTMLElement

_initSubTree

private void _initSubTree ( )
Iterates the source element's childNodes collection and uses the child nodes to instantiate other menus.
Returns: void

_preloadImage

private void _preloadImage ( p_sPath )
Preloads an image by creating an image element from the specified path and appending the image to the body of the document.
Parameters:
p_sPath <String> String specifying the path to the image.
Returns: void

blur

void blur ( )
Causes the menu item to lose focus and fires the onblur event.
Returns: void

configChecked

void configChecked ( p_sType , p_aArgs , p_oItem )
Event handler for when the "checked" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

configDisabled

void configDisabled ( p_sType , p_aArgs , p_oItem )
Event handler for when the "disabled" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

configEmphasis

void configEmphasis ( p_sType , p_aArgs , p_oItem )
Event handler for when the "emphasis" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

configHelpText

void configHelpText ( p_sType , p_aArgs , p_oItem )
Event handler for when the "helptext" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

configSelected

void configSelected ( p_sType , p_aArgs , p_oItem )
Event handler for when the "selected" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

configStrongEmphasis

void configStrongEmphasis ( p_sType , p_aArgs , p_oItem )
Event handler for when the "strongemphasis" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

configSubmenu

void configSubmenu ( p_sType , p_aArgs , p_oItem )
Event handler for when the "submenu" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

configTarget

void configTarget ( p_sType , p_aArgs , p_oItem )
Event handler for when the "target" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

configText

void configText ( p_sType , p_aArgs , p_oItem )
Event handler for when the "text" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

configURL

void configURL ( p_sType , p_aArgs , p_oItem )
Event handler for when the "url" configuration property of the menu item changes.
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_oItem <YAHOO.widget.MenuItem> Object representing the menu item that fired the event.
Returns: void

destroy

void destroy ( )
Removes the menu item's <li> element from its parent <ul> element.
Returns: void

focus

void focus ( )
Causes the menu item to receive the focus and fires the focus event.
Returns: void

getNextEnabledSibling

void getNextEnabledSibling ( )
Finds the menu item's next enabled sibling.
Returns: void
YAHOO.widget.MenuItem

getPreviousEnabledSibling

YAHOO.widget.MenuItem getPreviousEnabledSibling ( )
Finds the menu item's previous enabled sibling.
Returns: YAHOO.widget.MenuItem

init

void init ( p_oObject , p_oConfig )
The MenuItem 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_oObject <String> String specifying the text of the menu item.
p_oObject <HTMLLIElement> Object specifying the <li> element of the menu item.
p_oObject <HTMLOptGroupElement> Object specifying the <optgroup> element of the menu item.
p_oObject <HTMLOptionElement> Object specifying the <option> element of the menu item.
p_oConfig <Object> Optional. Object literal specifying the configuration for the menu item. See configuration class documentation for more details.
Returns: void

initDefaultConfig

void initDefaultConfig ( )
Initializes an item's configurable properties.
Returns: void

toString

String toString ( )
Returns a string representing the menu item.
Returns: String

Events

blurEvent

blurEvent ( )
Fires when the menu item loses the input focus.

clickEvent

clickEvent ( )
Fires when the user clicks the on the menu item. Passes back the DOM Event object as an argument.

destroyEvent

destroyEvent ( )
Fires when the menu item's <li> element is removed from its parent <ul> element.

focusEvent

focusEvent ( )
Fires when the menu item receives focus.

keyDownEvent

keyDownEvent ( )
Fires when the user presses a key when the menu item has focus. Passes back the DOM Event object as an argument.

keyPressEvent

keyPressEvent ( )
Fires when the user presses an alphanumeric key when the menu item has focus. Passes back the DOM Event object as an argument.

keyUpEvent

keyUpEvent ( )
Fires when the user releases a key when the menu item has focus. Passes back the DOM Event object as an argument.

mouseDownEvent

mouseDownEvent ( )
Fires when the user mouses down on the menu item. Passes back the DOM Event object as an argument.

mouseOutEvent

mouseOutEvent ( )
Fires when the mouse has left the menu item. Passes back the DOM Event object as an argument.

mouseOverEvent

mouseOverEvent ( )
Fires when the mouse has entered the menu item. Passes back the DOM Event object as an argument.

mouseUpEvent

mouseUpEvent ( )
Fires when the user releases a mouse button while the mouse is over the menu item. Passes back the DOM Event object as an argument.

Configuration Attributes

checked - Boolean

Boolean indicating if the menu item should be rendered with a checkmark.
Default Value: false

disabled - Boolean

Boolean indicating if the menu item should be disabled. (Disabled menu items are dimmed and will not respond to user input or fire events.)
Default Value: false

emphasis - Boolean

Boolean indicating if the text of the menu item will be rendered with emphasis. When building a menu from existing HTML the value of this property will be interpreted from the menu's markup.
Default Value: false

helptext - String| HTMLElement

String specifying additional instructional text to accompany the text for the nenu item.
Default Value: null

selected - Boolean

Boolean indicating if the menu item should be highlighted.
Default Value: false

strongemphasis - Boolean

Boolean indicating if the text of the menu item will be rendered with strong emphasis. When building a menu from existing HTML the value of this property will be interpreted from the menu's markup.
Default Value: false

submenu - Menu|String|Object| HTMLElement

Object specifying the submenu to be appended to the menu item. The value can be one of the following:
  • Object specifying a Menu instance.
  • Object literal specifying the menu to be created. Format: { id: [menu id], itemdata: [array of values for items] }.
  • String specifying the id attribute of the <div> element of the menu.
  • Object specifying the <div> element of the menu.
Default Value: null

target - String

String specifying the value for the "target" attribute of the menu item's anchor element. Specifying a target will require the user to click directly on the menu item's anchor node in order to cause the browser to navigate to the specified URL. When building a menu from existing HTML the value of this property will be interpreted from the menu's markup.
Default Value: null

text - String

String specifying the text label for the menu item. When building a menu from existing HTML the value of this property will be interpreted from the menu's markup.
Default Value: ""

url - String

String specifying the URL for the menu item's anchor's "href" attribute. When building a menu from existing HTML the value of this property will be interpreted from the menu's markup.
Default Value: "#"


Copyright © 2006 Yahoo! Inc. All rights reserved.