Home Reference Source
import Slider from 'newton-lib/src/dom/Slider.js'
public class | source

Slider

Class used to handle the sliders and their labels.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Sets a callback for when the slider changes value.

public

Sets the arguments passed to the callback function set in Slider.callback.

public

clone: dom.Input

Creates a Dom element from the cloned Input.

public

Sets the color in HEX format of the slider.

public

Sets the amount of decimal places displayed on the label.

public

Flag for fixing the decimal places to the amount set in Slider.decPlaces.

public

Sets the HTML base id of the slider and label element.

public

Raw label element obtained by jQuery.

public

Sets the maximum value of the slider.

public

Sets the minimum value of the slider.

public

Stores a copy of the current color.

public

Raw slider element obtained by document.getElementById.

public

Sets the starting position of the slider.

public

Sets the units that the slider will use.

public

Sets the current value of the slider.

Method Summary

Public Methods
public

enabled(state: boolean)

Enable or disable the slider.

public

get(): number

Get the current value of the slider.

public

set(value: number)

Sets a value in the slider.

public

setColor(color: string)

Change the color of the slider.

public

setLabel(value: number)

Sets a value in the label.

Public Constructors

public constructor(opts: object) source

Params:

NameTypeAttributeDescription
opts object
  • optional

Object that contains valid Slider properties with values. Their values will be assigned at the end of the constructor. If an invalid property is passed then the value will be ignored.

Public Members

public callback: function source

Sets a callback for when the slider changes value. Default value is undefined.

public callbackArgs: * source

Sets the arguments passed to the callback function set in Slider.callback. Default value is undefined.

public clone: dom.Input source

Creates a Dom element from the cloned Input. This value the user inputs is validated to always be a number.

public color: string source

Sets the color in HEX format of the slider. Default value is COLORS.RED.

public decPlaces: number source

Sets the amount of decimal places displayed on the label. Default value is 1.

public fixPlaces: boolean source

Flag for fixing the decimal places to the amount set in Slider.decPlaces. Default value is false.

public id: string source

Sets the HTML base id of the slider and label element. In order for the slider to match with a label, the id must be the same for both elements. The ending changes depending if it is a slider or a label. This class will look for the id: {id}_slider and {id}_label, where id is this value. Default value is "".

public label: object source

Raw label element obtained by jQuery.

public max: number source

Sets the maximum value of the slider. Default value is 1.

public min: number source

Sets the minimum value of the slider. Default value is 0.

public prevColor: string source

Stores a copy of the current color. Used when the slider is disabled and the color must be later restored when the slider is enabled again. Default value is COLORS.RED.

public slider: object source

Raw slider element obtained by document.getElementById.

public start: number source

Sets the starting position of the slider. Default value is 0.

public units: string source

Sets the units that the slider will use. Default value is "".

public value: number source

Sets the current value of the slider. Default value is Slider.start.

Public Methods

public enabled(state: boolean) source

Enable or disable the slider. When the slider is disabled the color changes to COLORS.GRAY. Once it changes back to enabled, its previous color is restored.

Params:

NameTypeAttributeDescription
state boolean

Desired state of the slider.

public get(): number source

Get the current value of the slider.

Return:

number

The current value of the slider.

public set(value: number) source

Sets a value in the slider. This modifies the value in the label.

Params:

NameTypeAttributeDescription
value number

Desired value to set in the slider.

public setColor(color: string) source

Change the color of the slider.

Params:

NameTypeAttributeDescription
color string

Desired HEX color.

public setLabel(value: number) source

Sets a value in the label. This value is formatted accoding to the settings in the element.

Params:

NameTypeAttributeDescription
value number

Desired value to set in the label.