ButtonItem Class
A base class for ButtonItem, providing: <ul> <li>Widget Lifecycle (initializer, renderUI, bindUI, syncUI, destructor)</li> <li>An optional icon or label</li> <li>Managed user interaction states (default, active, hover)</li> <li>Keyboard accessible</li> </ul>
Quick Example:<br/>
<pre><code>var instance = new A.ButtonItem({ icon: 'gear', label: 'Configuration' }).render(); </code></pre>
Check the list of <a href="ButtonItem.html#configattributes">Configuration Attributes</a> available for ButtonItem.
Constructor
ButtonItem
-
config
Parameters:
-
config
ObjectObject literal specifying widget configuration properties.
Index
Methods
Properties
- ButtonItem.ATTRS static
- ButtonItem.AUGMENTS static
- ButtonItem.HTML_PARSER static
- ButtonItem.NAME static
- ROOT_TYPE
Methods
_getState
-
key
-
parent
Retrieves the state value from either the current instance, or if defined, the parent widget.
Parameters:
-
key
StringThe state name to retrieve
-
parent
ObjectThe parent widget to attempt to retrieve the state from
Returns:
_renderIconNode
()
Node
protected
Renders the underlying markup for the <a href="ButtonItem.html#config_icon">icon</a>.
Returns:
_renderLabelNode
()
Node
protected
Renders the underlying markup for the <a href="ButtonItem.html#config_label">label</a>.
Returns:
_renderStates
-
event
Attaches state interaction management to the widget.
Parameters:
-
event
EventFacade
_setTitle
()
protected
Setter for the title attribute
_syncChildrenStates
()
protected
Syncs the boundingBox class names to reflect whether the children only have icons or labels or both.
_uiSetHandler
-
val
Updates the UI for the icon in response to the <a href="ButtonItem.html#event_HandlerChange">Handler</a> event.
Parameters:
-
val
StringHandler name
_uiSetIcon
-
val
Updates the UI for the icon in response to the <a href="ButtonItem.html#event_iconChange">iconChange</a> event.
Parameters:
-
val
StringIcon name
_uiSetLabel
-
val
Updates the UI for the label in response to the <a href="ButtonItem.html#event_labelChange">labelChange</a> event.
Parameters:
-
val
StringThe new value
_uiSetTitle
-
val
Updates the UI for the title in response to the <a href="ButtonItem.html#event_titleChange">titleChange</a> event.
Parameters:
-
val
StringThe new value
_uiSetType
-
val
Updates the UI for the type in response to the <a href="ButtonItem.html#event_typeChange">typeChange</a> event.
Parameters:
-
val
StringThe new value
renderUI
()
protected
Create the DOM structure for the ButtonItem. Lifecycle.
syncUI
()
protected
Sync the ButtonItem UI. Lifecycle.
Properties
ButtonItem.ATTRS
Object
static
Static property used to define the default attribute configuration for the ButtonItem.
ButtonItem.AUGMENTS
Array
static
Static property provides an array to specify which classes augment this one.
ButtonItem.HTML_PARSER
Object
static
Object hash, defining how attribute values are to be parsed from markup contained in the widget's content box.
ButtonItem.NAME
String
static
Static property provides a string to identify the class.
ROOT_TYPE
Object
Constructor reference used to determine the root of a Widget-based object tree. <p> Currently used to control the behavior of the <code>root</code> attribute so that recursing up the object heirarchy can be constrained to a specific type of Widget. Widget authors should set this property to the constructor function for a given Widget implementation. </p>
Attributes
depth
Number
readonly
Number representing the depth of this Widget relative to the root Widget in the object heirarchy.
Default: -1
handler
Function | Object
An event callback to handle when a user interacts with the button. This can either be a function that will be attached on click, or an object map that accepts the following keys: <code>{fn: // The function to execute context: // The context to execute the function in type: // The type of event to listen for (defaults to "click") }</code>
Default: false
iconNode
String
DOM Node to display the icon of the ButtonItem. If not specified try to query using HTML_PARSER an element inside boundingBox which matches <code>aui-button-icon</code>.
Default: Generated div element.
labelNode
String
DOM Node to display the text of the ButtonItem. If not specified try to query using HTML_PARSER an element inside boundingBox which matches <code>aui-button-label</code>.
Default: Generated div element.
root
Widget
readonly
Returns the root Widget in the object hierarchy. If the ROOT_TYPE property is set, the search for the root Widget will be constrained to parent Widgets of the specified type.
selected
Number
Number indicating if the Widget is selected. Possible values are: <dl> <dt>0</dt> <dd>(Default) Not selected</dd> <dt>1</dt> <dd>Fully selected</dd> <dt>2</dt> <dd>Partially selected</dd> </dl>
Default: 0