Namespace BTM.Event
BTM Event handling functions
Defined in: event.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
BTM.Event.DOMLoaded
Flag to identify if the DOM has loaded.
|
| <static> |
BTM.Event.eventHandlers
Reference to all event handlers registered through BTM.Event.observe
|
| <static> |
BTM.Event.keyCodes
Hash of Event Key Codes, use with BTM.Event.getKeyCode
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
BTM.Event.cancelEvent(event)
Cancel an event.
|
| <static> |
BTM.Event.fakeEvent(element, eventType, extras)
Create a fake Event object
|
| <static> |
BTM.Event.fire(element, eventType, extras)
Fire an event on an element.
|
| <static> |
BTM.Event.getKeyCode(event)
Determine the Key that fired an event
|
| <static> |
BTM.Event.getTarget(event)
Determine the original target element an Event fired on
|
| <static> |
BTM.Event.observe(element, eventType, callback, priority)
Add an event listener to an element
|
| <static> |
BTM.Event.runEventFuncs(event, element, eventType)
Run the event listeners assigned to a specific element/event combination.
|
| <static> |
BTM.Event.stopObserving(element, eventType, callbackIndex, priority)
Remove an event listener from an element
|
Field Detail
<static>
{Boolean}
BTM.Event.DOMLoaded
Flag to identify if the DOM has loaded.
<static>
BTM.Event.eventHandlers
Reference to all event handlers registered through BTM.Event.observe
<static>
BTM.Event.keyCodes
Hash of Event Key Codes, use with BTM.Event.getKeyCode
Method Detail
<static>
BTM.Event.cancelEvent(event)
Cancel an event. This stops the event from "bubbling" up the DOM tree, and prevents the default action.
- Parameters:
- {Event} event
- the event to be cancelled
<static>
{Object}
BTM.Event.fakeEvent(element, eventType, extras)
Create a fake Event object
- Parameters:
- {HTMLElement|String} element
- element ID or element reference to generate Event object for. This can be any element accessible via JavaScript, including document, window, etc
- {String} eventType
- the event to fire, e.g.: 'click', 'mouseover', 'MyApp:CustomEvent', etc. Also supports the event 'DOMContentLoaded' on the document object
- {Object} extras Optional
- key:value pairs of extra data to be included in the custom Event object generated when the Event fires
- Returns:
- {Object} the generated Event object
<static>
BTM.Event.fire(element, eventType, extras)
Fire an event on an element. This will apply to native and custom events registered via BTM.Event.observe
- Parameters:
- {HTMLElement|String} element
- element ID or element reference to fire Event on. This can be any element accessible via JavaScript, including document, window, etc
- {String} eventType
- the event to fire, e.g.: 'click', 'mouseover', 'MyApp:CustomEvent', etc. Also supports the event 'DOMContentLoaded' on the document object
- {Object} extras Optional
- key:value pairs of extra data to be included in the custom Event object generated when the Event fires
<static>
{String}
BTM.Event.getKeyCode(event)
Determine the Key that fired an event
- Parameters:
- {Event} event
- the event to determine the original Key of
- Returns:
- {String} the Key that was pressed
<static>
{HTMLElement}
BTM.Event.getTarget(event)
Determine the original target element an Event fired on
- Parameters:
- {Event} event
- the event to determine the original target of
- Returns:
- {HTMLElement} the element the Event originally fired on
<static>
{Number}
BTM.Event.observe(element, eventType, callback, priority)
Add an event listener to an element
var t = new MyClass();
BTM.observe('mydiv', 'click', t.myMethod.bindAsEventListener(t, 'hello', 'world'));
BTM.observe(document,'DOMContentLoaded', someRandomFunc, 8); // runs someRandomFunc() once the DOM has loaded, as a lower priority.
- Parameters:
- {HTMLElement|String} element
- element ID or element reference to add event listener to. This can be any element accessibly via JavaScript, including document, window, etc.
- {String} eventType
- the event to listen to, e.g.: 'click', 'mouseover', etc. Also supports the custom event 'DOMContentLoaded' on the document object.
- {Function} callback
- the Function to be called when the event fires
- {Number} priority Optional, Default: 5
- the priority of the event listener, lower numbers run first
- Returns:
- {Number} the index in the Array that holds this callback. Used with BTM.Event.stopObserving
- See:
<static>
BTM.Event.runEventFuncs(event, element, eventType)
Run the event listeners assigned to a specific element/event combination.
- Parameters:
- {Event} event
- the Event object
- {HTMLElement} element
- the DOM Element the Event was fired on
- {String} eventType
- the Event type, e.g.: 'click', 'hover', etc
<static>
{Function}
BTM.Event.stopObserving(element, eventType, callbackIndex, priority)
Remove an event listener from an element
- Parameters:
- {HTMLElement|String} element
- element ID or element reference to add event listener to. This can be any element accessible via JavaScript, including document, window, etc.
- {String} eventType
- the event to listen to, e.g.: 'click', 'mouseover', etc. Also supports the event 'DOMContentLoaded' on the document object.
- {Number} callbackIndex
- the index in the Array that holds the callback to be removed. Generated by BTM.Event.observe
- {Number} priority Optional, Default: 5
- the priority of the event listener, lower numbers run first
- Returns:
- {Function} the callback that was removed
- See: