Yahoo! UI Library

button  1.0

Yahoo! UI Library > button > Button
Search:
 
Filters

Class Button - extends Y.Widget, Y.MakeNode

The Button class provides a fancier type of button.

Constructor

Button ( cfg )
Parameters:
cfg <object> Configuration Attributes

Properties

_prevIconClassName - private string

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

BOUNDING_TEMPLATE - private string

Overrides the boundingBox template to make it an anchor
Default Value: '<a />'

CONTENT_TEMPLATE - private null

Overrides the contentBox template to prevent a content box from being drawn
Default Value: null

HTML_PARSER - object

HTML Parser assumes srcNode is either a <button> or <input type="submit|reset">

Y.Button._CLASS_NAMES - protected static [Strings]

Class name suffixes for CSS classNames used in the widget

Y.Button._EVENTS - protected static Object

DOM events to be listened to, used by the MakeNode extension

Y.Button.LEFT - static String

Constant to set the iconPosition to be to the left of the label
Default Value: 'left'

Y.Button.PUSH - static String

Constant for 'push' type button (the default)
Default Value: 'push'

Y.Button.RESET - static String

Constant for 'reset' type button (the default)
Default Value: 'reset'

Y.Button.RIGHT - static String

Constant to set the iconPosition to be to the right of the label
Default Value: 'right'

Y.Button.SUBMIT - static String

Constant for 'submit' type button
Default Value: 'submit'

Methods

_callbackFromType

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

_defPressFn

private void _defPressFn ( ev )
Default press callback function
Parameters:
ev <EventFacade>

_onClick

private void _onClick ( ev )
Default click event handler
Parameters:
ev <Event Facade>

_onMouseDown

private void _onMouseDown ( )
Adds the pressed class to bounding box

_onMouseUp

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.

_uiSetDefault

private void _uiSetDefault ( state )
Updates the default class on the bounding box
Parameters:
state <boolean>

_uiSetHref

private void _uiSetHref ( value )
Sets the href attribute on the bounding box
Parameters:
value <String> url of link to be set.

_uiSetIcon

private void _uiSetIcon ( value )
Sets the icon class for the bounding box
Parameters:
value <String> class suffix (always prefixed with yui3-button-icon-)

_uiSetIconPosition

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'

_uiSetLabel

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

_uiSetTitle

private void _uiSetTitle ( title )
Sets the title attribute to the bounding box
Parameters:
title <String>

initializer

void initializer ( )
publishes events

Events

callbackChange

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

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

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

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

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

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

press ( )
Fired when the button is clicked and no href provided

titleChange

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

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

callback - Function

Function to be called on button click

default - Boolean

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 - string

Label to be shown on the button
Default Value: ''

title - string

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


Copyright © 2011 Yahoo! Inc. All rights reserved.