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:
-
elHTMLElementDOM element
-
evStringEvent name
-
fnFunctionEvent handler
ajax
-
url -
[opts] -
onSuccess -
onError
Sends an AJAX request
Parameters:
-
urlStringRequest url
-
[opts]Object optionalOptions AJAX options
-
[async]Boolean optionalThe request is asynchronous
-
[responseType]String optionalthe XHR responseType
-
-
onSuccessFunctionSuccess event handler. The parameter is the response text.
-
onErrorFunctionError callback
arrayContains
-
array -
element
Decides whether an array contains an element.
Parameters:
-
arrayArrayThe array
-
elementThe element to find
Returns:
true, if found
domContains
-
a -
b
Decides whether a DOM element contains an other one
Parameters:
-
aHTMLElementThe container element
-
bHTMLElementThe contained element
Returns:
true if the first element contains the second
extend
-
target -
options
Copies properties to an object from an other object.
Parameters:
-
targetObjectThe properties are copied to this object.
-
optionsObjectThe properties are copied from this object
isArray
-
obj
Decides whether an object is an array.
Parameters:
-
objThe object to test
Returns:
true, if the object is an array
isFunction
-
obj
Decides whether an object is a function.
Parameters:
-
objThe object to test
Returns:
true, if the object is a function
parseJSON
-
str
Parses a JSON document
Parameters:
-
strStringThe document
Returns:
The JSON object
removeEventListener
-
el -
ev -
fn
Removes an event listener from a DOM element.
Parameters:
-
elHTMLElementDOM element
-
evStringEvent name
-
fnFunctionEvent handler
removeFromArray
-
array -
element
Finds an element in an array and removes it.
Parameters:
-
arrayArrayThe array
-
elementThe element to remove
Returns:
true, if the item was found and removed
