Namespace: UTILS

UTILS

The UTILS "namespace" / global variable.
Source:

Methods

<static> ajaxRequest(options) → {boolean}

Sends an Ajax request using the specified options. Ajax requests are sent with a special 'X-Requested-With' header that can be used to identify the requests on the server.
Parameters:
Name Type Argument Description
options Object <optional>
an object containing members specifying the options of the request

Valid members of this object are:
{string}        [url=location.href]  the url to send the request to

{string}        [method='GET']       the request method ('GET' or 'POST')

{string|Object} [data=null]          the data to send with the request

{number}        [timeout]            the amount of time in milliseconds
                                     to wait for a response before
                                     canceling the request. The onfailure
                                     and oncomplete functions will be called.

{Function}      [onsuccess]          the function to be executed when
                                     the response is received successfully.
                                     This function is passed the
                                     XMLHttpRequest object as a parameter.

{Function}      [onfailure]          the function to be executed when the
                                     response is received and the status
                                     is not 200 or 304 (an error occurred).
                                     This function is passed the
                                     XMLHttpRequest object as a parameter.

{Function}      [oncomplete]         the function to be executed when the
                                     response is received whether or not
                                     it was successful. This function will
                                     always be executed after the onsuccess
                                     or onfailure function. This function
                                     is passed the XMLHttpRequest object
                                     as a parameter.
Source:
Returns:
whether or not the request was made successfully
Type
boolean

<static> getCookie(name) → {string}

Gets the specified cookie's value.
Parameters:
Name Type Description
name string the name of the cookie to get
Source:
Returns:
the cookie value
Type
string

<static> move(elem, options)

Moves an element from one position to another.
Parameters:
Name Type Argument Description
elem Element the element to be moved
options Object <optional>
an object containing members specifying the animation options

Valid members of this object are:
{Array}    [from=[0,0]]  the starting position in [x, y]. Defaults to
                         the element's current position or [0, 0].

{Array}    [to=[0,0]]    the ending position in [x, y]

{number}   [dur=400]     the duration of the animation in milliseconds
                         (must be > 0)

{Function} [callback]    the function to be executed when the animation
                         is finished. This function is executed in the
                         context of the element.
Source:
Throws:
if elem argument is not an Element
Type
Error

<static> setCookie(name, value, expires, path, domain, secure)

Sets a cookie to the specified value. If no cookie exists, then it is created.
Parameters:
Name Type Argument Description
name string the name of the cookie
value string the value of the cookie
expires number <optional>
the number of days in which the cookie will expire
path string <optional>
the cookie path
domain string <optional>
the cookie domain
secure boolean <optional>
whether the cookie should only be sent over a secure connection
Source:

<static> trim(str) → {string}

Removes the leading and trailing whitespace from a string. http://blog.stevenlevithan.com/archives/faster-trim-javascript
Parameters:
Name Type Description
str string the string to trim
Source:
Returns:
the trimmed string
Type
string