Yahoo! UI Library

Menu  2.5.0

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

Show Private Show Protected

Class YAHOO.widget.MenuItem

Known Subclasses:
YAHOO.widget.MenuBarItem YAHOO.widget.ContextMenuItem
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

_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

_oOnclickAttributeValue - private Object

Object reference to the menu item's current value for the "onclick" configuration attribute.
Default Value: null

_oSubmenu - private YAHOO.widget.Menu

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

_sClassName - private String

The current value of the "classname" configuration attribute.
Default Value: null

browser - String

String representing the browser.
Deprecated: Use YAHOO.env.ua

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"

CSS_LABEL_CLASS_NAME - final String

String representing the CSS class(es) to be applied to the menu item's <a> element.
Default Value: "yuimenuitemlabel"

DEFAULT_CONFIG - private final Object

Constant representing the MenuItem's configuration properties

element - HTMLLIElement

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

EVENT_TYPES - private final Object

Constant representing the name of the MenuItem's events

groupIndex - Number

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

id - String

Id of the menu item's root <li> element. This property should be set via the constructor using the configuration object literal. If an id is not specified, then one will be created using the "generateId" method of the Dom utility.
Default Value: null

index - Number

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

parent - YAHOO.widget.Menu

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

srcElement - HTMLLIElement| HTMLOptGroupElement|HTMLOptionElement

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

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.

value - Object

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

Methods

_createRootNodeStructure

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

_initSubTree

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

_onSubmenuBeforeHide

private void _onSubmenuBeforeHide ( p_sType , p_aArgs )
"beforehide" Custom Event handler for a submenu.
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.
Returns: void

blur

void blur ( )
Causes the menu item to lose focus and fires the blur 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

configClassName

void configClassName ( p_sType , p_aArgs , p_oItem )
Event handler for when the "classname" configuration property of a 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

configOnClick

void configOnClick ( p_sType , p_aArgs , p_oItem )
Event handler for when the "onclick" 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

hasFocus

Boolean hasFocus ( )
Returns a boolean indicating whether or not the menu item has focus.
Returns: Boolean

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

classname - String

CSS class to be applied to the menu item's root <li> element. The specified class(es) are appended in addition to the default class as specified by the menu item's CSS_CLASS_NAME constant.
Default Value: null

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.
Deprecated Use "text" configuration property to add emphasis. For example: oMenuItem.cfg.setProperty("text", "<em>Some Text</em>");
Default Value: false

helptext - String| HTMLElement

String specifying additional instructional text to accompany the text for the menu item.
Deprecated Use "text" configuration property to add help text markup. For example: oMenuItem.cfg.setProperty("text", "Copy <em class=\"helptext\">Ctrl + C</em>");
Default Value: null

onclick - Object

Object literal representing the code to be executed when the item is clicked. Format:
{
fn: Function, // The handler to call when the event fires.
obj: Object, // An object to pass back to the handler.
scope: Object // The object to use for the scope of the handler.
}
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.
Deprecated Use "text" configuration property to add strong emphasis. For example: oMenuItem.cfg.setProperty("text", "<strong> Some Text</strong>");
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 © 2007 Yahoo! Inc. All rights reserved.