API Docs for: 1.0.1

Grape.Utils Class

Defined in: js\grape\utils.js:62

Utility class.

Item Index

Methods

Methods

addEventListener

(
  • el
  • ev
  • fn
)
static

Defined in js\grape\utils.js:8

Adds an event listener to a DOM element.

Parameters:

  • el HTMLElement

    DOM element

  • ev String

    Event name

  • fn Function

    Event handler

ajax

(
  • url
  • [opts]
  • onSuccess
  • onError
)
static

Sends an AJAX request

Parameters:

  • url String

    Request url

  • [opts] Object optional

    Options AJAX options

    • [async] Boolean optional

      The request is asynchronous

    • [responseType] String optional

      the XHR responseType

  • onSuccess Function

    Success event handler. The parameter is the response text.

  • onError Function

    Error callback

arrayContains

(
  • array
  • element
)
Boolean static

Decides whether an array contains an element.

Parameters:

  • array Array

    The array

  • element

    The element to find

Returns:

Boolean:

true, if found

domContains

(
  • a
  • b
)
Boolean static

Decides whether a DOM element contains an other one

Parameters:

  • a HTMLElement

    The container element

  • b HTMLElement

    The contained element

Returns:

Boolean:

true if the first element contains the second

extend

(
  • target
  • options
)
static

Copies properties to an object from an other object.

Parameters:

  • target Object

    The properties are copied to this object.

  • options Object

    The properties are copied from this object

isArray

(
  • obj
)
Boolean static

Decides whether an object is an array.

Parameters:

  • obj

    The object to test

Returns:

Boolean:

true, if the object is an array

isFunction

(
  • obj
)
Boolean static

Decides whether an object is a function.

Parameters:

  • obj

    The object to test

Returns:

Boolean:

true, if the object is a function

parseJSON

(
  • str
)
static

Parses a JSON document

Parameters:

  • str String

    The document

Returns:

:

The JSON object

removeEventListener

(
  • el
  • ev
  • fn
)
static

Removes an event listener from a DOM element.

Parameters:

  • el HTMLElement

    DOM element

  • ev String

    Event name

  • fn Function

    Event handler

removeFromArray

(
  • array
  • element
)
Boolean static

Finds an element in an array and removes it.

Parameters:

  • array Array

    The array

  • element

    The element to remove

Returns:

Boolean:

true, if the item was found and removed