goog.ui.SubMenuRenderer
Classgoog.ui.SubMenuRenderer
> goog.ui.MenuItemRenderer
> goog.ui.ControlRenderer
goog.ui.SubMenuRenderer()
Default renderer for {@link goog.ui.SubMenu}s. Each item has the following structure:
.CSS_CLASS
{string
}Default CSS class to be applied to the root element of components rendered by this renderer.
.canDecorate(element)
Inherited from goog.ui.ControlRenderer
.
Returns true if this renderer can decorate the element, false otherwise. The default implementation always returns true.
element
{Element
}
boolean
}
.createContent(content, dom)
[protected]Inherited from goog.ui.MenuItemRenderer
.
Wraps the given text caption or existing DOM node(s) in a structural element containing the menu item's contents.
content
{goog.ui.ControlContent
}
dom
{goog.dom.DomHelper
}
Element
}
.createDom(control)
Overrides {@link goog.ui.MenuItemRenderer#createDom} by adding the additional class 'goog-submenu' to the created element, and passes the element to {@link goog.ui.SubMenuItemRenderer#addArrow_} to add an child element that can be styled to show an arrow.
control
{goog.ui.Control
}
Element
}
.decorate(control, element)
Overrides {@link goog.ui.MenuItemRenderer#decorate} by adding the additional class 'goog-submenu' to the decorated element, and passing the element to {@link goog.ui.SubMenuItemRenderer#addArrow_} to add a child element that can be styled to show an arrow. Also searches the element for a child with the class goog-menu. If a matching child element is found, creates a goog.ui.Menu, uses it to decorate the child element, and passes that menu to subMenu.setMenu.
control
{goog.ui.Control
}
element
{Element
}
Element
}
.enableClassName(control, className, enable)
Inherited from goog.ui.ControlRenderer
.
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.
control
{goog.ui.Control
|Element
}
className
{string
}
enable
{boolean
}
.enableExtraClassName(control, className, enable)
Inherited from goog.ui.ControlRenderer
.
Updates the control's DOM by adding or removing the specified extra class name to/from its element.
control
{goog.ui.Control
}
className
{string
}
enable
{boolean
}
.getAriaRole()
Inherited from goog.ui.MenuItemRenderer
.
Returns the ARIA role to be applied to the control. See http://wiki/Main/ARIA for more info.
goog.dom.a11y.Role
|undefined
}
.getClassForState(state)
[protected]Inherited from goog.ui.MenuItemRenderer
.
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.
state
{goog.ui.Component.State
}
string
|undefined
}
.getClassNames(control)
[protected]Inherited from goog.ui.ControlRenderer
.
Returns all CSS class names applicable to the given control, based on its state. The return value is an array of strings containing
control
{goog.ui.Control
}
Array
.<string
>}
.getClassNamesForState(state)
[protected]Inherited from goog.ui.ControlRenderer
.
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.
state
{number
}
Array
.<string
>}
.getContentElement(element)
Inherited from goog.ui.MenuItemRenderer
.
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.
element
{Element
}
Element
}
.getCssClass()
Inherited from goog.ui.MenuItemRenderer
.
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.
string
}
.getIe6ClassCombinations()
Inherited from goog.ui.ControlRenderer
.
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 constant instead.
Array
.<Array
.<string
>>}
.getKeyEventTarget(control)
Inherited from goog.ui.ControlRenderer
.
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.
control
{goog.ui.Control
}
Element
}
.getStateFromClass(className)
[protected]Inherited from goog.ui.MenuItemRenderer
.
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.
className
{string
}
goog.ui.Component.State
}
.getStructuralCssClass()
Inherited from goog.ui.ControlRenderer
.
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.
string
}
.hasCheckBoxStructure(element)
[protected]Inherited from goog.ui.MenuItemRenderer
.
Determines whether the item contains a checkbox element.
element
{Element
}
boolean
}
.hasContentStructure(element)
[protected]Inherited from goog.ui.MenuItemRenderer
.
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.
element
{Element
}
boolean
}
.initializeDom(control)
Overrides {@link goog.ui.MenuItemRenderer#initializeDom} to tweak the DOM structure for the span.goog-submenu-arrow element depending on the text direction (LTR or RTL). When the SubMenu is RTL the arrow will be given the additional class of goog-submenu-arrow-rtl, and the arrow will be moved up to be the first child in the SubMenu's element. Otherwise the arrow will have the class goog-submenu-arrow-ltr, and be kept as the last child of the SubMenu's element.
control
{goog.ui.Control
}
.isFocusable(control)
Inherited from goog.ui.ControlRenderer
.
Returns true if the control's key event target supports keyboard focus (based on its {@code tabIndex} attribute), false otherwise.
control
{goog.ui.Control
}
boolean
}
.setAllowTextSelection(element, allow)
Inherited from goog.ui.ControlRenderer
.
Allows or disallows text selection within the control's DOM.
element
{Element
}
allow
{boolean
}
.setAriaRole(element, opt_preferredRole)
Inherited from goog.ui.ControlRenderer
.
Sets the element's ARIA role.
element
{Element
}
opt_preferredRole
{?goog.dom.a11y.Role
=}
.setAriaStates(control, element)
Inherited from goog.ui.ControlRenderer
.
Sets the element's ARIA states. An element does not need an ARIA role in order to have an ARIA state. Only states which are initialized to be true will be set.
control
{!goog.ui.Control
}
element
{!Element
}
.setCheckable(item, element, checkable)
Inherited from goog.ui.MenuItemRenderer
.
Enables/disables checkbox semantics on the menu item.
item
{goog.ui.Control
}
element
{Element
}
checkable
{boolean
}
.setContent(element, content)
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 submenu arrow structure is preserved.
element
{Element
}
content
{goog.ui.ControlContent
}
.setEnableCheckBoxStructure(item, element, enable)
[protected]Inherited from goog.ui.MenuItemRenderer
.
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.
item
{goog.ui.Control
}
element
{Element
}
enable
{boolean
}
.setFocusable(control, focusable)
Inherited from goog.ui.ControlRenderer
.
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.
control
{goog.ui.Control
}
focusable
{boolean
}
.setRightToLeft(element, rightToLeft)
Inherited from goog.ui.ControlRenderer
.
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.
element
{Element
}
rightToLeft
{boolean
}
.setSelectable(item, element, selectable)
Inherited from goog.ui.MenuItemRenderer
.
Enables/disables radio button semantics on the menu item.
item
{goog.ui.Control
}
element
{Element
}
selectable
{boolean
}
.setState(control, state, enable)
Inherited from goog.ui.ControlRenderer
.
Updates the appearance of the control in response to a state change.
control
{goog.ui.Control
}
state
{goog.ui.Component.State
}
enable
{boolean
}
.setVisible(element, visible)
Inherited from goog.ui.ControlRenderer
.
Shows or hides the element.
element
{Element
}
visible
{boolean
}
.updateAriaState(element, state, enable)
[protected]Inherited from goog.ui.ControlRenderer
.
Updates the element's ARIA (accessibility) state.
element
{Element
}
state
{goog.ui.Component.State
}
enable
{boolean
}