ui.MenuItemRenderer Extends goog.ui.ControlRenderer
Default renderer for {@link goog.ui.MenuItem}s. Each item has the following structure:
...(menu item contents)...

Inheritance

Object
     goog.ui.ControlRenderer
          goog.ui.MenuItemRenderer

Constructor

goog.ui.MenuItemRenderer()

Instance Methods

Public Protected Private
createContent(contentdom)
Wraps the given text caption or existing DOM node(s) in a structural element containing the menu item's contents.
Arguments:
content :
goog.ui.ControlContent
Menu item contents.
dom :
DOM helper for document interaction.
Returns:   Menu item content element.
code »
createDom(item)
Overrides {@link goog.ui.ControlRenderer#createDom} by adding extra markup and stying to the menu item's element if it is selectable or checkable.
Arguments:
item :
Menu item to render.
Returns:   Root element for the item.
code »
decorate(itemelement)
Overrides {@link goog.ui.ControlRenderer#decorate} by initializing the menu item to checkable based on whether the element to be decorated has extra stying indicating that it should be.
Arguments:
item :
Menu item instance to decorate the element.
element :
Element to decorate.
Returns:   Decorated element.
code »
getAriaRole()
goog.dom.a11y.Role
No description.
Returns: 
goog.dom.a11y.Role
  The ARIA role.
code »
getClassForState(state)
string | undefined
Takes a single {@link goog.ui.Component.State}, and returns the corresponding CSS class name (null if none). Overrides the superclass implementation by using 'highlight' as opposed to 'hover' as the CSS class name suffix for the HOVER state, for backwards compatibility.
Arguments:
state :
goog.ui.Component.State
Component state.
Returns: 
string | undefined
  CSS class representing the given state (undefined if none).
code »
getCompositeCssClass_(index)
Returns the composite CSS class by using the cached value or by constructing the value from the base CSS class and the passed index.
Arguments:
index :
goog.ui.MenuItemRenderer.CompositeCssClassIndex_
Index for the CSS class - could be highlight, checkbox or content in usual cases.
Returns:   The composite CSS class.
code »
getContentElement(element)
No description.
Arguments:
element :
No description.
code »
getCssClass()
No description.
code »
getStateFromClass(className)
goog.ui.Component.State
Takes a single CSS class name which may represent a component state, and returns the corresponding component state (0x00 if none). Overrides the superclass implementation by treating 'goog-option-selected' as special, for backwards compatibility.
Arguments:
className :
CSS class name, possibly representing a component state.
Returns: 
goog.ui.Component.State
  state Component state corresponding to the given CSS class (0x00 if none).
code »
hasCheckBoxStructure(element)
Determines whether the item contains a checkbox element.
Arguments:
element :
Menu item root element.
Returns:   Whether the element contains a checkbox element.
code »
hasContentStructure(element)
Returns true if the element appears to have a proper menu item structure by checking whether its first child has the appropriate structural class name.
Arguments:
element :
Element to check.
Returns:   Whether the element appears to have a proper menu item DOM.
code »
setCheckable(itemelementcheckable)
Enables/disables checkbox semantics on the menu item.
Arguments:
item :
Menu item to update.
element :
Menu item element to update (may be null if the item hasn't been rendered yet).
checkable :
Whether the item should be checkable.
code »
setContent(elementcontent)
Takes a menu item's root element, and sets its content to the given text caption or DOM structure. Overrides the superclass immplementation by making sure that the checkbox structure (for selectable/checkable menu items) is preserved.
Arguments:
element :
The item's root element.
content :
goog.ui.ControlContent
Text caption or DOM structure to be set as the item's content.
code »
setEnableCheckBoxStructure(itemelementenable)
Adds or removes extra markup and CSS styling to the menu item to make it selectable or non-selectable, depending on the value of the {@code selectable} argument.
Arguments:
item :
Menu item to update.
element :
Menu item element to update.
enable :
Whether to add or remove the checkbox structure.
code »
setSelectable(itemelementselectable)
Enables/disables radio button semantics on the menu item.
Arguments:
item :
Menu item to update.
element :
Menu item element to update (may be null if the item hasn't been rendered yet).
selectable :
Whether the item should be selectable.
code »
canDecorate(element)
Returns true if this renderer can decorate the element, false otherwise. The default implementation always returns true.
Arguments:
element :
Element to decorate.
Returns:   Whether the renderer can decorate the element.
code »
createClassByStateMap_()
Creates the lookup table of states to classes, used during state changes.
code »
createDom(control)
Returns the control's contents wrapped in a DIV, with the renderer's own CSS class and additional state-specific classes applied to it.
Arguments:
control :
Control to render.
Returns:   Root element for the control.
code »
createStateByClassMap_()
Creates the lookup table of classes to states, used during decoration.
code »
decorate(controlelement)
Default implementation of {@code decorate} for {@link goog.ui.Control}s. Initializes the control's ID, content, and state based on the ID of the element, its child nodes, and its CSS classes, respectively. Returns the element.
Arguments:
control :
Control instance to decorate the element.
element :
Element to decorate.
Returns:   Decorated element.
code »
enableClassName(controlclassNameenable)
Updates the control's DOM by adding or removing the specified class name to/from its root element. May add additional combined classes as needed in IE6 and lower. Because of this, subclasses should use this method when modifying class names on the control's root element.
Arguments:
control :
Control instance (or root element) to be updated.
className :
CSS class name to add or remove.
enable :
Whether to add or remove the class name.
code »
enableExtraClassName(controlclassNameenable)
Updates the control's DOM by adding or removing the specified extra class name to/from its element.
Arguments:
control :
Control to be updated.
className :
CSS class name to add or remove.
enable :
Whether to add or remove the class name.
code »
getAppliedCombinedClassNames_(classesopt_includedClass)
Returns an array of all the combined class names that should be applied based on the given list of classes. Checks the result of {@link getIe6ClassCombinations} for any combinations that have all members contained in classes. If a combination matches, the members are joined with an underscore (in order), and added to the return array. If opt_includedClass is provided, return only the combined classes that have all members contained in classes AND include opt_includedClass as well. opt_includedClass is added to classes as well.
Arguments:
classes :
Array of classes to return matching combined classes for.
opt_includedClass :
If provided, get only the combined classes that include this one.
Returns:   Array of combined class names that should be applied.
code »
getAriaRole()
goog.dom.a11y.Role | undefined
Returns the ARIA role to be applied to the control. See http://wiki/Main/ARIA for more info.
Returns: 
goog.dom.a11y.Role | undefined
  ARIA role.
code »
getClassForState(state)
string | undefined
Takes a single {@link goog.ui.Component.State}, and returns the corresponding CSS class name (null if none).
Arguments:
state :
goog.ui.Component.State
Component state.
Returns: 
string | undefined
  CSS class representing the given state (undefined if none).
code »
getClassNames(control)
Returns all CSS class names applicable to the given control, based on its state. The return value is an array of strings containing
  1. the renderer-specific CSS class returned by {@link #getCssClass}, followed by
  2. the structural CSS class returned by {@link getStructuralCssClass} (if different from the renderer-specific CSS class), followed by
  3. any state-specific classes returned by {@link #getClassNamesForState}, followed by
  4. any extra classes returned by the control's {@code getExtraClassNames} method and
  5. for IE6 and lower, additional combined classes from {@link getAppliedCombinedClassNames_}.
Since all controls have at least one renderer-specific CSS class name, this method is guaranteed to return an array of at least one element.
Arguments:
control :
Control whose CSS classes are to be returned.
Returns:   Array of CSS class names applicable to the control.
code »
getClassNamesForState(state)
Takes a bit mask of {@link goog.ui.Component.State}s, and returns an array of the appropriate class names representing the given state, suitable to be applied to the root element of a component rendered using this renderer, or null if no state-specific classes need to be applied. This default implementation uses the renderer's {@link getClassForState} method to generate each state-specific class.
Arguments:
state :
Bit mask of component states.
Returns:   Array of CSS class names representing the given state (null if none).
code »
getContentElement(element)
Takes the control's root element and returns the parent element of the control's contents. Since by default controls are rendered as a single DIV, the default implementation returns the element itself. Subclasses with more complex DOM structures must override this method as needed.
Arguments:
element :
Root element of the control whose content element is to be returned.
Returns:   The control's content element.
code »
getCssClass()
Returns the CSS class name to be applied to the root element of all components rendered or decorated using this renderer. The class name is expected to uniquely identify the renderer class, i.e. no two renderer classes are expected to share the same CSS class name.
Returns:   Renderer-specific CSS class name.
code »
getIe6ClassCombinations()
Returns an array of combinations of classes to apply combined class names for in IE6 and below. See {@link IE6_CLASS_COMBINATIONS} for more detail. This method doesn't reference {@link IE6_CLASS_COMBINATIONS} so that it can be compiled out, but subclasses should return their IE6_CLASS_COMBINATIONS static contasnt instead.
Returns:   Array of class name combinations.
code »
getKeyEventTarget(control)
Returns the element within the component's DOM that should receive keyboard focus (null if none). The default implementation returns the control's root element.
Arguments:
control :
Control whose key event target is to be returned.
Returns:   The key event target.
code »
getStateFromClass(className)
goog.ui.Component.State
Takes a single CSS class name which may represent a component state, and returns the corresponding component state (0x00 if none).
Arguments:
className :
CSS class name, possibly representing a component state.
Returns: 
goog.ui.Component.State
  state Component state corresponding to the given CSS class (0x00 if none).
code »
getStructuralCssClass()
Returns the name of a DOM structure-specific CSS class to be applied to the root element of all components rendered or decorated using this renderer. Unlike the class name returned by {@link #getCssClass}, the structural class name may be shared among different renderers that generate similar DOM structures. The structural class name also serves as the basis of derived class names used to identify and style structural elements of the control's DOM, as well as the basis for state-specific class names. The default implementation returns the same class name as {@link #getCssClass}, but subclasses are expected to override this method as needed.
Returns:   DOM structure-specific CSS class name (same as the renderer- specific CSS class name by default).
code »
initializeDom(control)
Initializes the control's DOM by configuring properties that can only be set after the DOM has entered the document. This implementation sets up BiDi and keyboard focus. Called from {@link goog.ui.Control#enterDocument}.
Arguments:
control :
Control whose DOM is to be initialized as it enters the document.
code »
isFocusable(control)
Returns true if the control's key event target supports keyboard focus (based on its {@code tabIndex} attribute), false otherwise.
Arguments:
control :
Control whose key event target is to be checked.
Returns:   Whether the control's key event target is focusable.
code »
setAllowTextSelection(elementallow)
Allows or disallows text selection within the control's DOM.
Arguments:
element :
The control's root element.
allow :
Whether the element should allow text selection.
code »
setAriaRole(element)
Sets the element's ARIA role on browsers that support it.
Arguments:
element :
Element to update.
code »
setContent(elementcontent)
Takes a control's root element, and sets its content to the given text caption or DOM structure. The default implementation replaces the children of the given element. Renderers that create more complex DOM structures must override this method accordingly.
Arguments:
element :
The control's root element.
content :
goog.ui.ControlContent
Text caption or DOM structure to be set as the control's content. The DOM nodes will not be cloned, they will only moved under the content element of the control.
code »
setFocusable(controlfocusable)
Updates the control's key event target to make it focusable or non-focusable via its {@code tabIndex} attribute. Does nothing if the control doesn't support the {@code FOCUSED} state, or if it has no key event target.
Arguments:
control :
Control whose key event target is to be updated.
focusable :
Whether to enable keyboard focus support on the control's key event target.
code »
setRightToLeft(elementrightToLeft)
Applies special styling to/from the control's element if it is rendered right-to-left, and removes it if it is rendered left-to-right.
Arguments:
element :
The control's root element.
rightToLeft :
Whether the component is rendered right-to-left.
code »
setState(controlstateenable)
Updates the appearance of the control in response to a state change.
Arguments:
control :
Control instance to update.
state :
goog.ui.Component.State
State to enable or disable.
enable :
Whether the control is entering or exiting the state.
code »
setVisible(elementvisible)
Shows or hides the element.
Arguments:
element :
Element to update.
visible :
Whether to show the element.
code »
updateAriaState(elementstateenable)
Updates the element's ARIA (accessibility) state on Gecko.
Arguments:
element :
Element whose ARIA state is to be updated.
state :
goog.ui.Component.State
Component state being enabled or disabled.
enable :
Whether the state is being enabled or disabled.
code »

Static Properties

goog.ui.MenuItemRenderer.CSS_CLASS :
CSS class name the renderer applies to menu item elements.
Code »

Package ui

Package Reference