Button

Button

Class representing a generic button.

Constructor

new Button(configopt)

Source:

Create a button.

Parameters:
Name Type Attributes Description
config object <optional>
Properties
Name Type Attributes Default Description
element Element <optional>

Pre-created element (usually provided instead of config).

buttonElement Element <optional>

Pre-created link element.

labelElement Element <optional>

Pre-created label element.

iconElement Element <optional>

Pre-created icon element.

tagName string <optional>
'a'

Tag name of the button element.

classes Array.<string> <optional>
[]

List of classes to add to the button element.

id string <optional>

ID attribute of the button.

href string <optional>

Value of the href parameter to add to the link element.

label string <optional>

Label of the button.

tooltip string <optional>

Tooltip for the button.

flags Array.<string> <optional>

Flags to apply to an OOUI button.

action function <optional>

Function to execute on click or Enter press.

Members

buttonElement :Element

Source:

Button element (an 'a' element by default). It can be the same as the main element or its descendant.

Type:
  • Element

element :Element

Source:

Main element. It can be the same as the link element or a wrapper around it.

Type:
  • Element

iconElement :Element|undefined

Source:

Button icon element, a descendant of the link element.

Type:
  • Element | undefined

labelElement :Element

Source:

Button label element. It can be the same as the link element or its descendant.

Type:
  • Element

Methods

hide() → {Button}

Source:

Hide the button.

Returns:

This button.

Type
Button

isDisabled() → {boolean}

Source:

Check whether the button is disabled.

Returns:
Type
boolean

isPending() → {boolean}

Source:

Check whether the button is pending.

Returns:
Type
boolean

(protected) maybeExecuteAction(action, e)

Source:

Execute a pre-defined action if the button is conditions are met.

Parameters:
Name Type Description
action function
e Event

setAction(actionnullable) → {Button}

Source:

Set the action of the button. It will be executed on click or Enter press.

Parameters:
Name Type Attributes Description
action function <nullable>
Returns:

This button.

Type
Button

setDisabled(disabled) → {Button}

Source:

Set the button disabled or not.

Parameters:
Name Type Description
disabled boolean
Returns:

This button.

Type
Button

setHref(href) → {Button}

Source:

Set the href attribute of the button.

Parameters:
Name Type Description
href string
Returns:

This button.

Type
Button

setIconProgressive()

Source:

Set the class to an OOUI icon to make it look like icons with the "progressive" flag do. Somehow OOUI doesn't set it at the building stage.

setLabel(label) → {Button}

Source:

Set the label of the button.

Parameters:
Name Type Description
label string
Returns:

This button.

Type
Button

setPending(pending) → {Button}

Source:

Set the button pending or not.

Parameters:
Name Type Description
pending boolean
Returns:

This button.

Type
Button

setTooltip(tooltip) → {Button}

Source:

Set the tooltip of the button.

Parameters:
Name Type Description
tooltip string
Returns:

This button.

Type
Button

show() → {Button}

Source:

Show the button.

Returns:

This button.

Type
Button

toggle(show) → {Button}

Source:

Show or hide the button, depending on the parameter.

Parameters:
Name Type Description
show boolean

Whether to show the button.

Returns:

This button.

Type
Button