Class: SpinnerControl

hcje/domTools.SpinnerControl(config, format, onChange)

Spinner control.

Constructor

new SpinnerControl(config, format, onChange)

Create spinner control.

The structure generated by the code is effectively

  • div: className hcje-spinner-control
    • span hcje-control-label
    • div className hcje-spinner-control__inner
      • input classNames hcje-button hcje-spinner-control__inner__down-button
      • div className hcje-spinner-control__inner__value
      • input classNames hcje-button hcje-spinner-control__inner__up-button
Parameters:
Name Type Description
config Object
Properties
Name Type Attributes Default Description
parentElement Element

element to attach to.

label string

Label for spinner control

initialValue number <optional>
0

Initial value.

downImage string

Url to down button image

upImage string

Url to up button image

downLabel string <optional>
'Reduce'

Label for down button.

upLabel string <optional>
'Increase'

Label for up button.

step number <optional>
1

Change in value per click

minValue number <optional>
0

Minimum value

maxValue number <optional>
100

Maximum value

format module:hcje/domTools.SpinnerControl~format

Formatting function. This takes the value and returns formated value. This is called before onChange.

onChange module:hcje/domTools.SpinnerControl~onChangeCallback

called with new value after changes. Note it is provided with the spinner's numerical value, not its formatted value.

Source:

Extends

  • module:hcje/domTools.BaseControl

Methods

getValue() → {number}

Get the current value.

Source:
Returns:
Type
number

Type Definitions

format(value) → {string}

Formatting function for a SpinnerControl.

Parameters:
Name Type Description
value number

Current value. This is the numerical value, no the formatted value.

Source:
Returns:

Formatted version of the numerical value.

Type
string

onChangeCallback(value)

Callback function for a SpinnerControl.

Parameters:
Name Type Description
value number

Current value. This is the numerical value, not the formatted value.

Source: