TK.Knob

new Knob(options)

TK.Knob is a TK.Circular inside of an SVG and which can be modified both by dragging and scrolling. TK.Knob uses TK.DragValue and TK.ScrollValue for setting its value. It inherits all options of TK.Circular and TK.DragValue.

Parameters:
Name Type Description
options Object
Properties:
Name Type Attributes Default Description
options.hand Object <optional>
{width: 1, length: 12, margin: 24}
options.margin Number <optional>
13
options.thickness Number <optional>
6
options.step Number <optional>
1
options.shift_up Number <optional>
4
options.shift_down Number <optional>
0.25
options.dot Object <optional>
{length: 6, margin: 13, width: 2}
options.marker Object <optional>
{thickness: 6, margin: 13}
options.label Object <optional>
{margin: 10, align: "outer", format: function(val){return val;}}
options.bar_direction Number <optional>
"horizontal"

Direction of the bar, either horizontal or vertical.

options.direction String <optional>
"polar"

Direction for changing the value. Can be "polar", "vertical" or "horizontal".

options.blind_angle Number <optional>
20

If options.direction is "polar", this is the angle of separation between positive and negative value changes

options.rotation Number <optional>
45

Defines the angle of the center of the positive value changes. 0 means straight upward. For instance, a value of 45 leads to increasing value when moving towards top and right.

Source:

Extends

Members

circular :TK.Circular

The TK.Circular module.

Source:

drag :TK.DragValue

Instance of TK.DragValue used for the interaction.

Source:

element :HTMLDivElement

The main DIV container. Has class toolkit-knob.

Source:

scroll :TK.ScrollValue

Instance of TK.ScrollValue used for the interaction.

Source:

svg :SVGImage

The main SVG image.

Source:

Methods

add_label()

This is an alias for TK.Circular#add_label of the internal circular instance.

Source:

remove_label()

This is an alias for TK.Circular#remove_label of the internal circular instance.

Source:

Methods inherited from TK.Widget

add_child(child)

Registers a widget as a child widget. This method is used to build up the widget tree. It does not modify the DOM tree.

add_children(a)

Registers an array of widgets as children.

all_children()

Returns an array of all children.

enable_draw()

Schedules this widget for drawing.

force_hide()

This is an alias for hide, which may be overloaded. See TK.Container for an example.

force_show()

This is an alias for hide, which may be overloaded. See TK.Container for an example.

get_style()

Returns the computed style of this widgets DOM element.

hidden()

Returns the current hidden status.

hide()

Make the widget hidden. This does not modify the DOM, instead it will stop rendering this widget. Options changed after calling hide will only be rendered (i.e. applied to the DOM) when the widget is made visible again using TK.Widget#show.

remove_child(child)

Removes a child widget. Note that this method only modifies the widget tree and does not change the DOM.

remove_children(a)

Removes an array of children.

set(key, value)

Sets an option.

set_style()

Sets a CSS style property in this widgets DOM element.

show()

Make the widget visible. This does not modify the DOM, instead it will only schedule the widget for rendering.

toggle_hidden()

TK.Toggle the hidden status. This is equivalent to calling hide() or show(), depending on the current hidden status of this widget.

visible_children()

Returns an array of all visible children.

widgetize()

Set the DOM elements of this widgets. This method is usually only used internally. Basically it means to add the id from options and set a basic CSS class. If delegate is true, basic events will be delegated from the element to the widget instance if classify is true, CSS functions will be bound to the widget instance.

Methods inherited from TK.Base

add_event(event, func, prevent, stop)

Register an event handler.

add_events(events, func)

Add multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

delegate_events(element) → {HTMLElement}

Delegates all occuring DOM events of a specific DOM node to the widget. This way the widget fires e.g. a click event if someone clicks on the given DOM node.

destroy()

Destroys all event handlers and the options object.

fire_event(event, …args)

Fires an event.

fire_events(events)

Fires several events.

get(key)

Get the value of an option.

has_event_listeners(event) → {boolean}

Test if the event descriptor has some handler functions in the queue.

remove_event(event, func)

Removes the given function from the event queue. If it is a native DOM event, it removes the DOM event listener as well.

remove_events(events, func)

Remove multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

set_options(optionsopt)

Merges a new options object into the existing one including deep copies of objects. If an option key begins with the string "on" it is considered as event handler. In this case the value should be the handler function for the event with the corresponding name without the first "on" characters.

Events

useraction

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

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

Source:

useraction

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

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

Source:

Events inherited from TK.Widget

classified

Is fired when a widget is classified.

destroy

Is fired when a widget is destroyed.

hide

The hide event is emitted when a widget is hidden and is not rendered anymore. This happens both with browser visibility changes and also internally when using layout widgets such as TK.Pager.

initialized

Is fired when a widget is initialized.

redraw

Is fired when a redraw is executed.

resize

The resize event is emitted whenever a widget is being resized. This event can be used to e.g. measure its new size. Note that some widgets do internal adjustments after the resize event. If that is relevant, the TK.Widget#resized event can be used, instead.

resized

The resized event is emitted after each rendering frame, which was triggered by a resize event.

set

The set event is emitted when an option was set using the TK.Widget#set method. The arguments are the option name and its new value.

Note that this happens both for user interaction and programmatical option changes.

show

The show event is emitted when a widget is shown and is being rendered. This is the counterpart to TK.Widget#hide.

stylized

Is fired when a widget is stylized.

widgetize

Is fired when a widget is widgetized.

Events inherited from TK.Base

delegated

Is fired when an element is delegated.

set_[option]

Is fired when an option is set.