Class: IWEventManager

IWEventManager

A class used to register, trigger and remove events on both DOM and Javascript objects. Uses the singleton design pattern. To enforce one single instance we use an anonymous constructor.

new IWEventManager()

Methods


addCustomListener(obj, eventName, eventHandler)

Registers a handler for the given custom event name and object.
Parameters:
Name Type Description
obj Object the object firing the event
eventName String the name of the event
eventHandler function the listener function to register
Returns:
the listener object which can be used to remove the handler
Type
IWEventListener

addDomListener(obj, eventName, eventHandler)

Registers a handler for the given DOM event name and object. If possible the W3C or Microsoft syntax for attaching events will be used, otherwise an IW event handler is registered.
Parameters:
Name Type Description
obj Object the object firing the event
eventName String the name of the event
eventHandler function the listener function to register
Returns:
the listener object which can be used to remove the handler
Type
IWEventListener

addListener(obj, eventName, eventHandler)

Registers a handler for the given event name and object.

This method is deprecated, use addDomListener in case of a DOM event or addCustomListener otherwise.

Parameters:
Name Type Description
obj Object the object firing the event
eventName String the name of the event
eventHandler function the listener function to register
Deprecated:
  • Yes
Returns:
the listener object which can be used to remove the handler
Type
IWEventListener

bind(obj, eventName, listenerObj, eventHandler)

Registers a method from an object as handler for events of the specified type from another object.
Parameters:
Name Type Description
obj Object the object firing the event
eventName String the name of the event
listenerObj Object the object listening to the event
eventHandler function the listener function to register
Returns:
Type
IWEventListener

clearInstanceListeners(obj)

Removes all registered handlers for the given object.
Parameters:
Name Type Description
obj Object
Returns:
Type
void

clearListeners(obj, eventName)

Removes all handlers for the specified event type and object.
Parameters:
Name Type Description
obj Object an object with registered events
eventName String the name of the event to unregister
Returns:
Type
void

removeListener(eventListener)

Removes the handler determined by the specified reference.
Parameters:
Name Type Description
eventListener IWEventListener the event listener to remove
Returns:
Type
void

trigger(object, eventName, event)

Triggers the event on the given object.
Parameters:
Name Type Description
object Object the object triggering this event
eventName String the name of this event
event Object the event object
Returns:
Type
void