TK

This is the namespace of the toolkit library. It contains all toolkit classes and constant. There are also a couple of utility functions which provide compatibility for older browsers.

Source:

Classes

Base
Button
ButtonArray
Chart
Circular
Clock
Container
Drag
DragValue
Dynamics
EqBand
Equalizer
Expander
Fader
FrequencyResponse
Gauge
Graph
Grid
Knob
Label
LevelMeter
MeterBase
MultiMeter
Pager
Range
Resize
ResponseHandle
ResponseHandler
Root
Scale
ScrollValue
Select
State
Toggle
Tooltip
Value
ValueButton
ValueKnob
Widget
Window

Mixins

Anchor
AudioMath
Filter
GlobalCursor
Gradient
Notes
Ranged
Ranges
Warning

Methods

(static) add_class(node, name)

Adds a CSS class to a DOM node.

Parameters:
Name Type Description
node HTMLElement | SVGElement

The DOM node.

name string

The class name.

Source:

(static) browser() → {string}

Returns the name of the browser

Source:
Returns:
Type
string

(static) css_space(element) → {object}

Returns the overall spacing around an HTMLElement of all given attributes

Parameters:
Name Type Description
element HTMLElement

The element to evaluate

Source:
Returns:

An object with the members "top", "bottom", "lfet", "right"

Type
object
Example
TK.css_space(element, "padding", "border");

(static) element(tag, …attributes, …class)

Returns a newly created HTMLElement.

Parameters:
Name Type Attributes Description
tag string

The type of the element

attributes object <repeatable>

Optional mapping of attributes for the new node

class string <repeatable>

Optional class name for the new node

Source:
Returns:

HTMLElement

(static) empty(element)

Removes all child nodes from an HTMLElement.

Parameters:
Name Type Description
element HTMLElement

The element to clean up

Source:

(static) error(…args)

Generates an error to the JavaScript console. This is virtually identical to console.error, however it can safely be used in browsers which do not support it.

Parameters:
Name Type Attributes Description
args * <repeatable>
Source:

(static) escapeHTML(html) → {string}

Escape an HTML string to be displayed as text

Parameters:
Name Type Description
html string

The HTML code to escape

Source:
Returns:
Type
string

(static) fixed(element) → {boolean}

Returns if an element is positioned fixed to the viewport

Parameters:
Name Type Description
element HTMLElement

the element to evaluate

Source:
Returns:
Type
boolean

(static) FORMAT(fmt) → {function}

Generates formatting functions from sprintf-style format strings. This is generally faster when the same format string is used many times.

Parameters:
Name Type Description
fmt string

The format string.

Source:
See:
Returns:

A formatting function.

Type
function
Example
var f = TK.FORMAT("%.2f Hz");

(static) get_class(class, element) → {NodeList}

Returns all elements as NodeList of a given class name. Optionally limit the list to all children of a specific DOM node. Shorthand for element.getElementsByClassName.

Parameters:
Name Type Description
class string

The name of the class

element DOMNode

Limit search to child nodes of this element. Optional.

Source:
Returns:
Type
NodeList

(static) get_duration(element) → {number}

Returns the longest animation duration of CSS animations and transitions.

Parameters:
Name Type Description
element HTMLElement

The element to evalute the animation duration for.

Source:
Returns:
Type
number

(static) get_id(id) → {HTMLElement}

Returns the DOM node with the given ID. Shorthand for document.getElementById.

Parameters:
Name Type Description
id string

The ID to search for

Source:
Returns:
Type
HTMLElement

(static) get_max_time(string) → {number}

Returns the maximum value (float) of a comma separated string. It is used to find the longest CSS animation in a set of multiple animations.

Parameters:
Name Type Description
string string

The comma separated string.

Source:
Returns:
Type
number
Example
get_max_time(get_style(DOMNode, "animation-duration"));

(static) get_style(node, property) → {string}

Returns the computed style of a node.

Parameters:
Name Type Description
node HTMLElement | SVGElement

The DOM node.

property string

The CSS property name.

Source:
Returns:
Type
string

(static) get_tag(tag, element) → {NodeList}

Returns all elements as NodeList of a given tag name. Optionally limit the list to all children of a specific DOM node. Shorthand for element.getElementsByTagName.

Parameters:
Name Type Description
tag string

The name of the tag

element DOMNode

Limit search to child nodes of this element. Optional.

Source:
Returns:
Type
NodeList

(static) has_class(node, name) → {boolean}

Returns true if the node has the given class.

Parameters:
Name Type Description
node HTMLElement | SVGElement

The DOM node.

name string

The class name.

Source:
Returns:
Type
boolean

(static) height() → {number}

Returns the height of the viewport

Source:
Returns:
Type
number

(static) html(html) → {HTMLFragment}

Returns a documentFragment containing the result of a string parsed as HTML.

Parameters:
Name Type Description
html string

A string to parse as HTML

Source:
Returns:
Type
HTMLFragment

(static) insert_after(newnode, refnode)

Inserts one HTMLELement after another in the DOM tree.

Parameters:
Name Type Description
newnode HTMLElement

The new node to insert into the DOM tree

refnode HTMLElement

The reference element to add the new element after

Source:

(static) insert_before(newnode, refnode)

Inserts one HTMLELement before another in the DOM tree.

Parameters:
Name Type Description
newnode HTMLElement

The new node to insert into the DOM tree

refnode HTMLElement

The reference element to add the new element before

Source:

(static) is_touch() → {boolean}

Check if a device is touch-enabled

Source:
Returns:
Type
boolean

(static) log(…args)

Generates a log message to the JavaScript console. This is virtually identical to console.log, however it can safely be used in browsers which do not support it.

Parameters:
Name Type Attributes Description
args * <repeatable>
Source:

(static) merge(…object) → {object}

Merge two or more objects. The second and all following objects will be merged into the first one.

Parameters:
Name Type Attributes Description
object obhject <repeatable>

The objects to merge

Source:
Returns:
Type
object

(static) object_and(origin, filter) → {object}

Filter an object via white list

Parameters:
Name Type Description
origin object

The object to filter

filter object

The object containing the white list

Source:
Returns:

The filtered result

Type
object

(static) object_sub(origin, filter) → {object}

Filter an object via black list

Parameters:
Name Type Description
origin object

The object to filter

filter object

The object containing the black list

Source:
Returns:

The filtered result

Type
object

(static) os() → {string}

Return the operating system

Source:
Returns:
Type
string

(static) position_left(element, relation) → {number}

Returns the position from the left of an element in relation to the document or an optional HTMLElement. Scrolling of the parent is taken into account.

Parameters:
Name Type Description
element HTMLElement

The element to evaluate

relation HTMLElement

The element to use as reference. Optional.

Source:
Returns:
Type
number

(static) position_top(element, relation) → {number}

Returns the position from top of an element in relation to the document or an optional HTMLElement. Scrolling of the parent is taken into account.

Parameters:
Name Type Description
element HTMLElement

The element to evaluate

relation HTMLElement

The element to use as reference. Optional.

Source:
Returns:
Type
number

(static) remove_class(node, name)

Removes a CSS class from a DOM node.

Parameters:
Name Type Description
node HTMLElement | SVGElement

The DOM node.

name string

The class name.

Source:

(static) retrieve(object, key) → {*}

Retrieve a piece of data from an object

Parameters:
Name Type Description
object object

The object to retrieve the data from

key string

The key to identify the memory

Source:
Returns:
Type
*

(static) seat_all_svg(parent)

Searches for all SVG that don't have the class "svg-fixed" and re-positions them in order to avoid blurry lines

Parameters:
Name Type Description
parent HTMLElement

If set only children of parent are searched

Source:

(static) seat_svg(svg)

Move SVG for some sub-pixel if their position in viewport is not int

Parameters:
Name Type Description
svg SVGElement

The SVG to manipulate

Source:

(static) set_content(element)

Sets the (exclusive) content of an HTMLElement.

Parameters:
Name Type Description
element HTMLElement

The element receiving the content

Source:

(static) set_style(element, style, value)

Sets a single CSS style onto an HTMLElement. It is used to autimatically add "px" to numbers and trim them to 3 digits at max. DEPRECATED!

Parameters:
Name Type Description
element HTMLElement

The element to set the style to

style string

The CSS attribute to set

value string | number

The value to set the CSS attribute to

Source:

(static) set_styles(element, styles)

Set multiple CSS styles onto an HTMLElement

Parameters:
Name Type Description
element HTMLElement

the element to add the styles to

styles object

A mapping containing all styles to add

Source:
Example
TK.set_styles(element, {"width":"100px", "height":"100px"});

(static) sprintf(fmt, …args) → {function}

Formats the arguments according to a given format string.

Parameters:
Name Type Attributes Description
fmt string

The format string.

args * <repeatable>

The format arguments.

Source:
See:
Returns:

A formatting function.

Type
function
Example
TK.sprintf("%d Hz", 440);

(static) store(object, key, data)

Store a piece of data in an object

Parameters:
Name Type Description
object object

The object to store the data

key string

The key to identify the memory

data *

The data to store

Source:

(static) textContent(element, text)

Sets a string as new exclusive text node of an HTMLElement.

Parameters:
Name Type Description
element HTMLElement

The element to clean up

text string

The string to set as text content

Source:

(static) toggle_class(node, name)

Toggles a CSS class from a DOM node.

Parameters:
Name Type Description
node HTMLElement | SVGElement

The DOM node.

name string

The class name.

Source:

(static) unique_id() → {string}

Generate a unique ID string

Source:
Returns:
Type
string

(static) warn(…args)

Generates a warning to the JavaScript console. This is virtually identical to console.warn, however it can safely be used in browsers which do not support it.

Parameters:
Name Type Attributes Description
args * <repeatable>
Source:

(static) width() → {number}

Returns the width of the viewport

Source:
Returns:
Type
number