Skip to main content

API Documentation for utils

isArray ⇒ Boolean

This is a polyfill for the Array.isArray function. Determines whether the passed obect is an Array.

Kind: global variable
Returns: Boolean - returns true if the passed object is an Array.

ParamType
vArgobject

isset(object) ⇒ boolean

Determines if the provided value has been defined.

Kind: global function

ParamType
objectmixed

hash_key(value) ⇒ string | null

Converts a scalar to its best string representation for hash keys and HTML attribute values.

Transformations: 'str' -> 'str' null -> '' undefined -> '' true -> '1' false -> '0' 0 -> '0' 1 -> '1'

Kind: global function

ParamType
valuestring

escape_html(str) ⇒ string

Escapes a string for use within HTML.

Kind: global function

ParamType
strstring

escape_replace(str) ⇒ string

Escapes "$" characters in replacement strings.

Kind: global function

ParamType
strstring

once(fn) ⇒ function

Wraps fn so that it can only be invoked once.

Kind: global function

ParamType
fnfunction

debounce(fn, delay) ⇒ function

Wraps fn so that it can only be called once every delay milliseconds (invoked on the falling edge).

Kind: global function

ParamType
fnfunction
delaynumber

debounce_events(self, types, fn)

Debounce all fired events types listed in types while executing the provided fn.

Kind: global function

ParamType
selfobject
typesarray
fnfunction

watchChildEvent($parent, event, selector, fn)

A workaround for http://bugs.jquery.com/ticket/6696

Kind: global function

ParamTypeDescription
$parentobjectParent element to listen on.
eventstringEvent name.
selectorstringDescendant selector to filter by.
fnfunctionEvent handler.

getInputSelection(input) ⇒ object

Determines the current selection within a text input control. Returns an object containing:

  • start
  • length

Kind: global function

ParamType
inputobject

transferStyles($from, $to, properties)

Copies CSS properties from one element to another.

Kind: global function

ParamType
$fromobject
$toobject
propertiesarray

measureString(str, $parent) ⇒ number

Measures the width of a string within a parent element (in pixels).

Kind: global function

ParamType
strstring
$parentobject

autoGrow($input)

Sets up an input to grow horizontally as the user types. If the value is changed manually, you can trigger the "update" handler to resize:

$input.trigger('update');

Kind: global function

ParamType
$inputobject

isJSON(data) ⇒ Boolean

Determines whether or not the data argument is a valid JSON string.

Kind: global function
Returns: Boolean - true if is an JSON object

ParamTypeDescription
dataStringData to test

uaDetect(platform, re) ⇒ Boolean

If the browser supports the User-Agent Client Hint, then return the platform name, otherwise return the result of a regular expression test on the user agent string

Kind: global function
Returns: Boolean - A boolean value.

ParamDescription
platformThe platform you want to detect.
reA regular expression that matches the user agent string.