Event

Event manager.

Methods

(static) add(elem, type, fn) → {void}

Add event to DOM element.

Source:
Parameters:
Name Type Description
elem object | string

DOM element or selector.

type string

Event type.

fn function

Callback.

Returns:
Type:
void
Example
Event.add(document.getElementById('foo'), 'click', function fooClick(evt) {
  // Element was clicked.
});
Event.add('#foo', 'click', function fooClick(evt) {
  // Element was clicked.
});

(static) isRightClick(ev) → {boolean}

Determine if an event is a "right click" event.

Source:
Parameters:
Name Type Description
ev object

DOM event.

Returns:
Type:
boolean
Example
// Assume this function is a click event listener.
function clickHandler(evt) {
  alert(Event.isRightClick(evt));
});

(static) remove(elem, type, fn) → {void}

Remove event from DOM element.

Source:
Parameters:
Name Type Description
elem object | string

DOM element or selector.

type string

Event type.

fn function

Callback.

Returns:
Type:
void
Example
// Assuming elemen had the `fooClick` function (see previous example):
Event.remove(document.getElementById('foo'), 'click', fooClick);
Event.remove('#foo'), 'click', fooClick);