Introduction


In Addition to the previous namespaces, Spacer has the following minor namespaces:


Dom Namespace


Contains useful dom functions.


spa.dom.setDisable(input, status)


Set input disable status.

Parameter Type Description
input string | JQuery Input as jQuery selector string or as JQuery object
status boolean Disable status to set

spa.dom.setLoadingButton(button, ajax)


Remove button inner html and show loading icon. This function return the original button inner html.

Parameter Type Description
button string | JQuery Button as jQuery selector string or as JQuery object
ajax Ajax Promise If specified, then loading stops when ajax call ends.

spa.dom.unsetLoadingButton(button, html)


Remove loading icon and set button inner html.

Parameter Type Description
button string | JQuery Button as jQuery selector string or as JQuery object
html string Inner html to be set as button name

Utility Namespace


Contains general utility functions.


spa.util.debounce(delay, fn)


A modified version of underscorejs debounce function.

Parameter Type Description
delay integer Delay
fn function Callback

spa.util.timer(interval, fn)


A timer that execute a callback every interval. This function return timer id. You can pass this id to spa.util.cancelTimer(id) to cancel the timer.

Parameter Type Description
interval integer Interval
fn function Callback

spa.util.cancelTimer(id)


Cancel timer previously created with spa.util.cancelTimer(interval, fn).

Parameter Type Description
id integer Timer id

spa.util.executeLater(delay, fn)


Execute a callback one time after delay. This function return an id. You can pass this id to spa.util.cancelExecuteLater(id) to cancel the execution.

Parameter Type Description
delay integer Delay
fn function Callback

spa.util.cancelExecuteLater(id)


Cancel execution previously created with spa.util.cancelExecuteLater(delay, fn).

Parameter Type Description
id integer Execute later id

spa.util.randomString(length, num, small, capital)


Generate random string with fixed length.

Parameter Type Description
length integer String length
num boolean Whereas the string should contains numbers.
small boolean Whereas the string should contains small letters.
capital boolean Whereas the string should contains capital letters.