Class: Button

Button

new Button()

A button component
Source:
Example
const button = new Button({
                           id: "myButton",
                           size: Button.SIZE.LARGE,
                           outline: Button.OUTLINE.ENABLE
                          },
                          "Click me");
button.attachTo(document.body);

Extends

Members

children

getter for children which will automatically refresh them and create them if they are BaseComponent
Inherited From:
Source:

commonProperties

getter for commonProperties which are shared against all components
Inherited From:
Source:

Methods

_applyOptions(options, …names)

If you document a component properties like this: Component.PROPERTY = { X: function () { ... do something ... }, Y: function () { ... do something ... }, }; You can use this function that will iterate options object and for each component, calls the initialization where necessary. Usage (in constructor): this._applyOptions(options, "X", "Y");
Parameters:
Name Type Attributes Description
options
names string <repeatable>
keys to the options object, values of the keys should be functions
Inherited From:
Source:

addChildren(…children)

Parameters:
Name Type Attributes Description
children any <repeatable>
children to add to the component
Inherited From:
Source:

attachTo(element)

Parameters:
Name Type Description
element * The element to attach the component to
Inherited From:
Source:

create()

Create the component it needs to be overridden by the derived class
Overrides:
Source:

refreshState()

Refresh the state of the component, e.g. class names
Inherited From:
Source:

set(…properties)

Parameters:
Name Type Attributes Description
properties any <repeatable>
functions to set the state of the component
Inherited From:
Source:

setClass(key, value)

Set the class of the component
Parameters:
Name Type Description
key string The key of the class
value string The value of the class
Inherited From:
Source:
Example
button.setClass("size", "btn-lg");

Button

new Button(options, …args)

Parameters:
Name Type Attributes Description
options *
args any <repeatable>
options.onClick function <optional>
The click event handler
Source:

Members

children

getter for children which will automatically refresh them and create them if they are BaseComponent
Inherited From:
Source:

commonProperties

getter for commonProperties which are shared against all components
Inherited From:
Source:

Methods

_applyOptions(options, …names)

If you document a component properties like this: Component.PROPERTY = { X: function () { ... do something ... }, Y: function () { ... do something ... }, }; You can use this function that will iterate options object and for each component, calls the initialization where necessary. Usage (in constructor): this._applyOptions(options, "X", "Y");
Parameters:
Name Type Attributes Description
options
names string <repeatable>
keys to the options object, values of the keys should be functions
Inherited From:
Source:

addChildren(…children)

Parameters:
Name Type Attributes Description
children any <repeatable>
children to add to the component
Inherited From:
Source:

attachTo(element)

Parameters:
Name Type Description
element * The element to attach the component to
Inherited From:
Source:

create()

Create the component it needs to be overridden by the derived class
Overrides:
Source:

refreshState()

Refresh the state of the component, e.g. class names
Inherited From:
Source:

set(…properties)

Parameters:
Name Type Attributes Description
properties any <repeatable>
functions to set the state of the component
Inherited From:
Source:

setClass(key, value)

Set the class of the component
Parameters:
Name Type Description
key string The key of the class
value string The value of the class
Inherited From:
Source:
Example
button.setClass("size", "btn-lg");