Manual Reference Source Test
import EventifiedElement from 'elementify/lib/elements/eventifiedelement.js'
public class | source

EventifiedElement

Member Summary

Private Members
private get

_id: *

Unique id for HtmlElement automatically generated Its solely purpose is for events tracking

version 1.0.0 since 1.0.0

Method Summary

Public Methods
public

fire(event: String, element: window | document | node): Boolean

Fire an event to htmlElement.

version 1.0.0 since 1.0.0
public

getEvent(event: String): *

Returns the callback(s) attached to element is already attached to the HtmlElement

version 1.0.0 since 1.0.0
public

hasEvent(event: String, callback: String | Function): *

Check if a listener is set for the element is already attached to the HtmlElement

version 1.0.0 since 1.0.0
public

off(event: String, callback: String | Function, capture: Boolean): HtmlElement

Detach event from htmlElement node.

version 1.0.0 since 1.0.0
public

on(event: String, callback: String | Function, capture: Boolean): HtmlElement

Attach event to htmlElement node.

version 1.0.0 since 1.0.0
public

registerEvents(events: Object): void

Mass registering for event based on a key/callback object

version 1.0.0 since 1.0.0
Private Methods
private

_callbackId(callback: *): *

Private Members

private get _id: * version 1.0.0 since 1.0.0 source

Unique id for HtmlElement automatically generated Its solely purpose is for events tracking

Public Methods

public fire(event: String, element: window | document | node): Boolean version 1.0.0 since 1.0.0 source

Fire an event to htmlElement. It is mostly an alias to native dispatchEvent but with the option to make another element fire the event (it must be a valid target though)

Params:

NameTypeAttributeDescription
event String

Event name

element window | document | node
  • optional
  • default: this.node

Element that is required to fire the event. If not provided, the underlying node will be the source.

Return:

Boolean

The return value is false if event is cancelable and at least one of the event handlers which handled this event called Event.preventDefault(). Otherwise it returns true.

See:

public getEvent(event: String): * version 1.0.0 since 1.0.0 source

Returns the callback(s) attached to element is already attached to the HtmlElement

Params:

NameTypeAttributeDescription
event String
  • optional

Event name

Return:

*

See:

public hasEvent(event: String, callback: String | Function): * version 1.0.0 since 1.0.0 source

Check if a listener is set for the element is already attached to the HtmlElement

Params:

NameTypeAttributeDescription
event String
  • optional

Event name

callback String | Function
  • optional

callback

Return:

*

See:

public off(event: String, callback: String | Function, capture: Boolean): HtmlElement version 1.0.0 since 1.0.0 source

Detach event from htmlElement node. It is mostly an alias to native removeEventListener with a storage of the registered event

Params:

NameTypeAttributeDescription
event String

Event name

callback String | Function

Callback to run

capture Boolean
  • optional
  • default: false

Capture the event

Return:

HtmlElement

Self for chaining

See:

public on(event: String, callback: String | Function, capture: Boolean): HtmlElement version 1.0.0 since 1.0.0 source

Attach event to htmlElement node. It is mostly an alias to native addEventListener with a storage of the registered event.

A good side effect is you cannot [duplicate callbacks with anonymous functions] (https://triangle717.wordpress.com/2015/12/14/js-avoid-duplicate-listeners).

Params:

NameTypeAttributeDescription
event String

Event name

callback String | Function

Callback to run

capture Boolean
  • optional
  • default: false

Capture the event

Return:

HtmlElement

Self for chaining

See:

public registerEvents(events: Object): void version 1.0.0 since 1.0.0 source

Mass registering for event based on a key/callback object

Params:

NameTypeAttributeDescription
events Object

Events object to register

Return:

void

Private Methods

private _callbackId(callback: *): * source

Params:

NameTypeAttributeDescription
callback *

Return:

*