The Button class provides a fancier type of button.
Constructor
Button
(
cfg
)
- Parameters:
-
cfg
<object>
Configuration Attributes
Properties
Holds the previous value of the className assigned through the
icon
attribute for easy removal
(Eventually it will be dropped, see: http://yuilibrary.com/projects/yui3/ticket/2530486)
_TEMPLATE
- protected static String
Template to use by the MakeNode extension
Overrides the boundingBox template to make it an anchor
Default Value: '<a />'
Overrides the contentBox template to prevent a content box from being drawn
Default Value: null
HTML Parser assumes srcNode is either a <button> or
<input type="submit|reset">
Class name suffixes for CSS classNames used in the widget
DOM events to be listened to, used by the MakeNode extension
Constant to set the
iconPosition to be to the left of the label
Default Value: 'left'
Constant for 'push'
type button (the default)
Default Value: 'push'
Constant for 'reset'
type button (the default)
Default Value: 'reset'
Constant to set the
iconPosition to be to the right of the label
Default Value: 'right'
Constant for 'submit'
type button
Default Value: 'submit'
Methods
private
_callbackFromType
(
)
Returns a function based on the type of button. Form buttons such
as Submit and Reset are attached to their parent form if one is
found. Otherwise null is returned.
- Returns:
- Function or null
private
void
_defPressFn
(
ev
)
Default press callback function
- Parameters:
-
ev
<EventFacade>
private
void
_onClick
(
ev
)
Default click event handler
- Parameters:
-
ev
<Event Facade>
private
void
_onMouseDown
(
)
Adds the pressed class to bounding box
private
void
_onMouseUp
(
)
Removes the pressed class.
MouseUp is listened to at the document body level since the cursor might have moved
away from the pressed button when released.
private
void
_uiSetDefault
(
state
)
Updates the default class on the bounding box
- Parameters:
-
state
<boolean>
private
void
_uiSetHref
(
value
)
Sets the href attribute on the bounding box
- Parameters:
-
value
<String>
url of link to be set.
private
void
_uiSetIcon
(
value
)
Sets the icon class for the bounding box
- Parameters:
-
value
<String>
class suffix (always prefixed with yui3-button-icon-
)
private
void
_uiSetIconPosition
(
value
)
Sets the position of the icon relative to the label.
Spans for icons are always set at either side,
this method changes a classname in the bounding box
so that one of them is hidden
- Parameters:
-
value
<String>
'left' or 'right'
private
void
_uiSetLabel
(
value
)
Sets the icon class for the bounding box
- Parameters:
-
value
<String or null>
label to be set or null for none
private
void
_uiSetTitle
(
title
)
Sets the title attribute to the bounding box
- Parameters:
-
title
<String>
void
initializer
(
)
publishes events
Events
callbackChange
(
event
)
Fires when the value for the configuration attribute 'callback' is changed. You can listen for the event using the
on method if you wish to be notified before the attribute's value has changed, or using the
after method if you wish to be notified after the attribute's value has changed.
- Parameters:
-
event
<Event.Facade>
An Event Facade object with the following attribute specific properties added: - prevVal
- The value of the attribute, prior to it being set
- newVal
- The value the attribute is to be set to
- attrName
- The name of the attribute being set
- subAttrName
- If setting a property within the attribute's value, the name of the sub-attribute property being set
defaultChange
(
event
)
Fires when the value for the configuration attribute 'default' is changed. You can listen for the event using the
on method if you wish to be notified before the attribute's value has changed, or using the
after method if you wish to be notified after the attribute's value has changed.
- Parameters:
-
event
<Event.Facade>
An Event Facade object with the following attribute specific properties added: - prevVal
- The value of the attribute, prior to it being set
- newVal
- The value the attribute is to be set to
- attrName
- The name of the attribute being set
- subAttrName
- If setting a property within the attribute's value, the name of the sub-attribute property being set
hrefChange
(
event
)
Fires when the value for the configuration attribute 'href' is changed. You can listen for the event using the
on method if you wish to be notified before the attribute's value has changed, or using the
after method if you wish to be notified after the attribute's value has changed.
- Parameters:
-
event
<Event.Facade>
An Event Facade object with the following attribute specific properties added: - prevVal
- The value of the attribute, prior to it being set
- newVal
- The value the attribute is to be set to
- attrName
- The name of the attribute being set
- subAttrName
- If setting a property within the attribute's value, the name of the sub-attribute property being set
iconChange
(
event
)
Fires when the value for the configuration attribute 'icon' is changed. You can listen for the event using the
on method if you wish to be notified before the attribute's value has changed, or using the
after method if you wish to be notified after the attribute's value has changed.
- Parameters:
-
event
<Event.Facade>
An Event Facade object with the following attribute specific properties added: - prevVal
- The value of the attribute, prior to it being set
- newVal
- The value the attribute is to be set to
- attrName
- The name of the attribute being set
- subAttrName
- If setting a property within the attribute's value, the name of the sub-attribute property being set
iconPositionChange
(
event
)
Fires when the value for the configuration attribute 'iconPosition' is changed. You can listen for the event using the
on method if you wish to be notified before the attribute's value has changed, or using the
after method if you wish to be notified after the attribute's value has changed.
- Parameters:
-
event
<Event.Facade>
An Event Facade object with the following attribute specific properties added: - prevVal
- The value of the attribute, prior to it being set
- newVal
- The value the attribute is to be set to
- attrName
- The name of the attribute being set
- subAttrName
- If setting a property within the attribute's value, the name of the sub-attribute property being set
labelChange
(
event
)
Fires when the value for the configuration attribute 'label' is changed. You can listen for the event using the
on method if you wish to be notified before the attribute's value has changed, or using the
after method if you wish to be notified after the attribute's value has changed.
- Parameters:
-
event
<Event.Facade>
An Event Facade object with the following attribute specific properties added: - prevVal
- The value of the attribute, prior to it being set
- newVal
- The value the attribute is to be set to
- attrName
- The name of the attribute being set
- subAttrName
- If setting a property within the attribute's value, the name of the sub-attribute property being set
press
(
)
Fired when the button is clicked and no href provided
titleChange
(
event
)
Fires when the value for the configuration attribute 'title' is changed. You can listen for the event using the
on method if you wish to be notified before the attribute's value has changed, or using the
after method if you wish to be notified after the attribute's value has changed.
- Parameters:
-
event
<Event.Facade>
An Event Facade object with the following attribute specific properties added: - prevVal
- The value of the attribute, prior to it being set
- newVal
- The value the attribute is to be set to
- attrName
- The name of the attribute being set
- subAttrName
- If setting a property within the attribute's value, the name of the sub-attribute property being set
typeChange
(
event
)
Fires when the value for the configuration attribute 'type' is changed. You can listen for the event using the
on method if you wish to be notified before the attribute's value has changed, or using the
after method if you wish to be notified after the attribute's value has changed.
- Parameters:
-
event
<Event.Facade>
An Event Facade object with the following attribute specific properties added: - prevVal
- The value of the attribute, prior to it being set
- newVal
- The value the attribute is to be set to
- attrName
- The name of the attribute being set
- subAttrName
- If setting a property within the attribute's value, the name of the sub-attribute property being set
Configuration Attributes
Function to be called on button click
Button is to be the default button
Default Value: false
href
- object
href property to set on the button A element
Default Value: null
icon
- string or null for none
Suffix to be added to the yui3-button-icon-
class to
set on the button
Default Value: null
iconPosition
- String ('left' or 'right')
Whether the icon should go to the left or to the right of the label
Default Value: 'left'
Label to be shown on the button
Default Value: ''
Title (tooltip) to set on the button element
type
- string
Defines the button type. One of push, submit or reset. Any value but submit or reset will assume push.
Default Value: push