Buttons

Buttons

new Buttons(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.buttons Array.<(Object|String)> <optional>
[]

A list of Button instances, button options objects or label strings which is converted to button instances on init. If get is called, a converted list of button instances is returned. Example: [new Button({label:'Button#1'}), 'Button#2', {label:'Button#3'}]

options.direction String <optional>
"horizontal"

The layout of the button list, either "horizontal" or "vertical".

options.select Integer | Button | Array.<Integer> | Array.<Button> <optional>
-1

The Button or a list of Buttons, depending on options.multi_select, to highlight. Expects either the buttons index starting from zero or the Button instance(s) itself. Set to -1 or [] to de-select any selected button.

options.button_class Object <optional>
Button

A class to be used for instantiating new buttons.

options.button_role String <optional>
'option'

A role to be used for instantiating new buttons.

options.multi_select Integer <optional>
0

Set to 0 to disable multiple selection, 1 for unlimited and any other number for a defined maximum amount of selectable buttons. If an array is given for options.select while this option is 0, the first entry will be used.

options.deselect Boolean <optional>
false

Define if single-selection (options.multi_select=false) can be de-selected.

Buttons is a list of (Button)s, arranged either vertically or horizontally. Single buttons can be selected by clicking. If multi_select is enabled, buttons can be added and removed from the selection by clicking on them. Buttons uses warning to highlight buttons which can't be selected due to options.multi_select=n.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{ }

An object containing initial options.

Extends

Members

buttons :ChildWidgets

Source:

An instance of ChildWidgets holding all Buttons.

Type:
  • ChildWidgets

element :HTMLDivElement

Source:
Overrides:

The main DIV container. Has class .aux-buttons.

Type:
  • HTMLDivElement

Methods

addButton(options, positionopt) → {Button}

Source:

Adds a Button to Buttons.

Parameters:
Name Type Attributes Description
options Button | Object | String

An alread instantiated Button, an object containing options for a new Button to add or a string for the label of the newly created Button.

position integer <optional>

The position to add the Button to. If undefined, the Button is added to the end of the list.

Returns:

The Button instance.

Type
Button

addButtons(list)

Source:

Adds an array of buttons to the end of the list.

Parameters:
Name Type Description
list Array.<(string|object)>

An Array containing Button instances, objects with options for the buttons (see Button for more information) or strings for the buttons labels.

empty()

Source:

Removes all buttons.

getButtons() → {Array.<Button>}

Source:
Returns:

The list of Buttons.

Type
Array.<Button>

hide()

Source:
Inherited From:

Starts the transition of the visible to false.

hideChild(child)

Source:
Inherited From:

Switches the hidden state of a child to hidden. The argument is either the child index or the child itself.

Parameters:
Name Type Description
child Object | integer

Child or its index.

isChildHidden(child) → {boolean}

Source:
Inherited From:

Returns true if the given child is currently marked as hidden in this container.

Parameters:
Name Type Description
child number | Widget
Returns:
Type
boolean

isSelected(button) → {Boolean}

Source:

Checks if an index or Button is selected.

Parameters:
Name Type Description
button Integer | Button

button index or Button instance.

Returns:
Type
Boolean

removeButton(button, destroy)

Source:

Removes a Button from Buttons.

Parameters:
Name Type Description
button integer | Button

button index or the Button instance to be removed.

destroy Boolean

destroy the Button after removal.

show()

Source:
Inherited From:

Starts the transition of the visible to true.

showChild(child)

Source:
Inherited From:

Switches the hidden state of a child to shown. The argument is either the child index or the child itself.

Parameters:
Name Type Description
child Object | integer

Child or its index.

toggleChild(child)

Source:
Inherited From:

Toggles the hidden state of a child. The argument is either the child index or the child itself.

Parameters:
Name Type Description
child Object | integer

Child or its index.

Events

added

Source:

A Button was added to Buttons.

Parameters:
Name Type Description
button Button

The Button which was added to Buttons.

removed

Source:

A Button was removed from the Buttons.

Parameters:
Name Type Description
button Button

The Button instance which was removed.

useraction

Source:

The useraction event is emitted when a widget gets modified by user interaction. The event is emitted for the option select.

Parameters:
Name Type Description
name string

The name of the option which was changed due to the users action

value mixed

The new value of the option

useraction

Source:

The useraction event is emitted when a widget gets modified by user interaction. The event is emitted for the option select.

Parameters:
Name Type Description
name string

The name of the option which was changed due to the users action

value mixed

The new value of the option