Grape.Utils Class
Utility class.
Item Index
Methods
- addEventListener static
- ajax static
- arrayContains static
- domContains static
- extend static
- isArray static
- isFunction static
- parseJSON static
- removeEventListener static
- removeFromArray static
Methods
addEventListener
-
el
-
ev
-
fn
Adds an event listener to a DOM element.
Parameters:
-
el
HTMLElementDOM element
-
ev
StringEvent name
-
fn
FunctionEvent handler
ajax
-
url
-
[opts]
-
onSuccess
-
onError
Sends an AJAX request
Parameters:
-
url
StringRequest url
-
[opts]
Object optionalOptions AJAX options
-
[async]
Boolean optionalThe request is asynchronous
-
[responseType]
String optionalthe XHR responseType
-
-
onSuccess
FunctionSuccess event handler. The parameter is the response text.
-
onError
FunctionError callback
arrayContains
-
array
-
element
Decides whether an array contains an element.
Parameters:
-
array
ArrayThe array
-
element
The element to find
Returns:
true, if found
domContains
-
a
-
b
Decides whether a DOM element contains an other one
Parameters:
-
a
HTMLElementThe container element
-
b
HTMLElementThe contained element
Returns:
true if the first element contains the second
extend
-
target
-
options
Copies properties to an object from an other object.
Parameters:
-
target
ObjectThe properties are copied to this object.
-
options
ObjectThe properties are copied from this object
isArray
-
obj
Decides whether an object is an array.
Parameters:
-
obj
The object to test
Returns:
true, if the object is an array
isFunction
-
obj
Decides whether an object is a function.
Parameters:
-
obj
The object to test
Returns:
true, if the object is a function
parseJSON
-
str
Parses a JSON document
Parameters:
-
str
StringThe document
Returns:
The JSON object
removeEventListener
-
el
-
ev
-
fn
Removes an event listener from a DOM element.
Parameters:
-
el
HTMLElementDOM element
-
ev
StringEvent name
-
fn
FunctionEvent handler
removeFromArray
-
array
-
element
Finds an element in an array and removes it.
Parameters:
-
array
ArrayThe array
-
element
The element to remove
Returns:
true, if the item was found and removed