Home

# Class goog.ui.CustomButtonRenderer

Custom renderer for {@link goog.ui.Button}s. Custom buttons can contain almost arbitrary HTML content, will flow like inline elements, but can be styled like block-level elements.

extends goog.ui.ButtonRenderer

Instance Method Summary
| `canDecorate(?Element element) ⇒ boolean` Returns true if this renderer can decorate the element. Overrides {@link goog.ui.ButtonRenderer#canDecorate} by returning true if the element is a DIV, false otherwise.
| `createButton(?goog.ui.ControlContent content, ?goog.dom.DomHelper dom) ⇒ ?Element` Takes a text caption or existing DOM structure, and returns the content wrapped in a pseudo-rounded-corner box. Creates the following DOM structure: Contents... Used by both {@link #createDom} and {@link #decorate}. To be overridden by subclasses.
| `createDom(?goog.ui.Button button) ⇒ ?Element` Returns the button's contents wrapped in the following DOM structure: Contents... Overrides {@link goog.ui.ButtonRenderer#createDom}.
| `decorate(?goog.ui.Button button, ?Element element) ⇒ ?Element` Takes an existing element and decorates it with the custom button control. Initializes the control's ID, content, tooltip, value, and state based on the ID of the element, its child nodes, and its CSS classes, respectively. Returns the element. Overrides {@link goog.ui.ButtonRenderer#decorate}.
| `getAriaRole() ⇒ (goog.dom.a11y.Role|null|undefined)` Returns the ARIA role to be applied to custom buttons.
| `getContentElement(?Element element) ⇒ ?Element` Takes the button's root element and returns the parent element of the button's contents. Overrides the superclass implementation by taking the nested DIV structure of custom buttons into account.
| `getCssClass() ⇒ string` Returns the CSS class to be applied to the root element of components rendered using this renderer.
| `hasBoxStructure(?goog.ui.Button button, ?Element element) ⇒ boolean` Check if the button's element has a box structure.
| `setAriaStates(!goog.ui.Button button, !Element element)` Sets the button's ARIA states.

Static Method Summary

`trimTextNodes_(?Element element, boolean fromStart)`

Takes an element and removes leading or trailing whitespace from the start or the end of its list of child nodes. The Boolean argument determines whether to trim from the start or the end of the node list. Empty text nodes are removed, and the first non-empty text node is trimmed from the left or the right as appropriate. For example,

#text "" #text "\n Hello " ... #text " World! \n" #text ""
becomes
#text "Hello " ... #text " World!"
This is essential for Gecko, where leading/trailing whitespace messes with the layout of elements with -moz-inline-box (used in goog-inline-block), and optional but harmless for non-Gecko.