Class Index | File Index

Classes


Namespace YAHOO.util.Event

Event
Defined in: event.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
The event utility provides functions to add and remove event listeners, event cleansing.
Field Summary
Field Attributes Field Name and Description
<private> <static>  
YAHOO.util.Event._interval
poll handle
<private> <static>  
YAHOO.util.Event._simpleAdd
Adds a DOM event directly without the caching, cleanup, scope adj, etc
<private> <static>  
YAHOO.util.Event._simpleRemove
Basic remove listener
<static>  
YAHOO.util.Event.ADJ_SCOPE
Adjusted scope, either the element we are registering the event on or the custom object passed in by the listener, int constant
<private> <inner>  
Counter for auto id generation
<static>  
YAHOO.util.Event.EL
Element to bind, int constant
<private> <static>  
YAHOO.util.Event.elCache
<static>  
YAHOO.util.Event.FN
Function to execute, int constant
<private> <static>  
YAHOO.util.Event.isIE
IE detection needed to properly calculate pageX and pageY.
<private> <static>  
YAHOO.util.Event.isSafari
Safari detection is necessary to work around the preventDefault bug that makes it so you can't cancel a href click from the handler.
<private> <inner>  
Cache of DOM0 event handlers to work around issues with DOM2 events in Safari
<private> <inner>  
Listener stack for DOM0 events
<private> <inner>  
Lookup table for legacy events
<private> <inner>  
Cache of wrapped listeners
<private> <inner>  
True after the onload event has fired
<static>  
YAHOO.util.Event.OBJ
Object passed in by the user that will be returned as a parameter to the callback, int constant
<private> <inner>  
onAvailable listeners
<static>  
YAHOO.util.Event.POLL_INTERVAL
The poll interval in milliseconds
<static>  
YAHOO.util.Event.POLL_RETRYS
The number of times we should look for elements that are not in the DOM at the time the event is requested after the document has been loaded.
<private> <inner>  
The number of times to poll after window.onload.
<static>  
YAHOO.util.Event.TYPE
Type of event, int constant
<private> <inner>  
User-defined unload function that will be fired before all events are detached
<static>  
YAHOO.util.Event.WFN
Function wrapped for scope correction and cleanup, int constant
Method Summary
Method Attributes Method Name and Description
<private> <static>  
YAHOO.util.Event._getCacheIndex(el, sType, fn)
Locating the saved event handler data by function ref
<private> <static>  
YAHOO.util.Event._getScroll()
Returns the scrollTop and scrollLeft.
<private> <static>  
YAHOO.util.Event._getScrollLeft()
Returns scrollLeft
<private> <static>  
YAHOO.util.Event._getScrollTop()
Returns scrollTop
<private> <static>  
YAHOO.util.Event._isValidCollection(o)
We want to be able to use getElementsByTagName as a collection to attach a group of events to.
<private> <static>  
YAHOO.util.Event._load(e)
hook up any deferred listeners
<private> <static>  
YAHOO.util.Event._tryPreloadAttach()
Polling function that runs before the onload event fires, attempting to attach to DOM Nodes as soon as they are available
<private> <static>  
YAHOO.util.Event._unload(e)
Removes all listeners registered by pe.event.
<static>  
YAHOO.util.Event.addListener(el, sType, fn, obj, override)
Appends an event handler
<private> <static>  
YAHOO.util.Event.clearCache()
Clears the element cache
<private> <static>  
YAHOO.util.Event.fireLegacyEvent(e, legacyIndex)
When using legacy events, the handler is routed to this object so we can fire our custom listener stack.
<static>  
YAHOO.util.Event.generateId(el)
Generates an unique ID for the element if it does not already have one.
<static>  
YAHOO.util.Event.getCharCode(ev)
Returns the charcode for an event
<private> <static>  
YAHOO.util.Event.getEl(id)
We cache elements bound by id because when the unload event fires, we can no longer use document.getElementById
<static>  
YAHOO.util.Event.getEvent(e)
Finds the event in the window object, the caller's arguments, or in the arguments of another method in the callstack.
<private> <static>  
YAHOO.util.Event.getLegacyIndex(el, sType)
Returns the legacy event index that matches the supplied signature
<static>  
YAHOO.util.Event.getListeners(el, sType)
Returns all listeners attached to the given element via addListener.
<static>  
YAHOO.util.Event.getPageX(ev)
Returns the event's pageX
<static>  
YAHOO.util.Event.getPageY(ev)
Returns the event's pageY
<static>  
YAHOO.util.Event.getRelatedTarget(ev)
Returns the event's related target
<static>  
YAHOO.util.Event.getTarget(ev, resolveTextNode)
Returns the event's target element
<static>  
YAHOO.util.Event.getTime(ev)
Returns the time of the event.
<static>  
YAHOO.util.Event.getXY(ev)
Returns the pageX and pageY properties as an indexed array.
<static>  
YAHOO.util.Event.onAvailable(p_id, p_fn, p_obj, p_override)
Executes the supplied callback when the item with the supplied id is found.
<static>  
YAHOO.util.Event.onContentReady(p_id, p_fn, p_obj, p_override)
Works the same way as onAvailable, but additionally checks the state of sibling elements to determine if the content of the available element is safe to modify.
<static>  
YAHOO.util.Event.preventDefault(ev)
Prevents the default behavior of the event
<static>  
YAHOO.util.Event.purgeElement(el, recurse, sType)
Removes all listeners attached to the given element via addListener.
<static>  
YAHOO.util.Event.removeListener(el, sType, fn)
Removes an event handler
<static>  
YAHOO.util.Event.resolveTextNode(node)
In some cases, some browsers will return a text node inside the actual element that was targeted.
<private> <static>  
YAHOO.util.Event.startInterval()
<static>  
YAHOO.util.Event.stopEvent(ev)
Convenience method for stopPropagation + preventDefault
<static>  
YAHOO.util.Event.stopPropagation(ev)
Stops event propagation
<private> <static>  
YAHOO.util.Event.useLegacyEvent(el, sType)
Logic that determines when we should automatically use legacy events instead of DOM2 events.
Namespace Detail
YAHOO.util.Event
The event utility provides functions to add and remove event listeners, event cleansing. It also tries to automatically remove listeners it registers during the unload event.
Field Detail
<private> <static> YAHOO.util.Event._interval
poll handle

<private> <static> YAHOO.util.Event._simpleAdd
Adds a DOM event directly without the caching, cleanup, scope adj, etc

<private> <static> YAHOO.util.Event._simpleRemove
Basic remove listener

<static> {int} YAHOO.util.Event.ADJ_SCOPE
Adjusted scope, either the element we are registering the event on or the custom object passed in by the listener, int constant

<private> <inner> counter
Counter for auto id generation

<static> {int} YAHOO.util.Event.EL
Element to bind, int constant

<private> <static> YAHOO.util.Event.elCache

<static> {int} YAHOO.util.Event.FN
Function to execute, int constant

<private> <static> YAHOO.util.Event.isIE
IE detection needed to properly calculate pageX and pageY. capabilities checking didn't seem to work because another browser that does not provide the properties have the values calculated in a different manner than IE.

<private> <static> YAHOO.util.Event.isSafari
Safari detection is necessary to work around the preventDefault bug that makes it so you can't cancel a href click from the handler. There is not a capabilities check we can use here.

<private> <inner> legacyEvents
Cache of DOM0 event handlers to work around issues with DOM2 events in Safari

<private> <inner> legacyHandlers
Listener stack for DOM0 events

<private> <inner> legacyMap
Lookup table for legacy events

<private> <inner> {array} listeners
Cache of wrapped listeners

<private> <inner> {boolean} loadComplete
True after the onload event has fired

<static> {int} YAHOO.util.Event.OBJ
Object passed in by the user that will be returned as a parameter to the callback, int constant

<private> <inner> onAvailStack
onAvailable listeners

<static> {int} YAHOO.util.Event.POLL_INTERVAL
The poll interval in milliseconds

<static> {int} YAHOO.util.Event.POLL_RETRYS
The number of times we should look for elements that are not in the DOM at the time the event is requested after the document has been loaded. The default is 200@amp;50 ms, so it will poll for 10 seconds or until all outstanding handlers are bound (whichever comes first).

<private> <inner> retryCount
The number of times to poll after window.onload. This number is increased if additional late-bound handlers are requested after the page load.

<static> {int} YAHOO.util.Event.TYPE
Type of event, int constant

<private> <inner> {array} unloadListeners
User-defined unload function that will be fired before all events are detached

<static> {int} YAHOO.util.Event.WFN
Function wrapped for scope correction and cleanup, int constant
Method Detail
<private> <static> YAHOO.util.Event._getCacheIndex(el, sType, fn)
Locating the saved event handler data by function ref
Parameters:
el
sType
fn

<private> <static> YAHOO.util.Event._getScroll()
Returns the scrollTop and scrollLeft. Used to calculate the pageX and pageY in Internet Explorer

<private> <static> YAHOO.util.Event._getScrollLeft()
Returns scrollLeft

<private> <static> YAHOO.util.Event._getScrollTop()
Returns scrollTop

<private> <static> {boolean} YAHOO.util.Event._isValidCollection(o)
We want to be able to use getElementsByTagName as a collection to attach a group of events to. Unfortunately, different browsers return different types of collections. This function tests to determine if the object is array-like. It will also fail if the object is an array, but is empty.
Parameters:
o
the object to test
Returns:
{boolean} true if the object is array-like and populated

<private> <static> YAHOO.util.Event._load(e)
hook up any deferred listeners
Parameters:
e

<private> <static> YAHOO.util.Event._tryPreloadAttach()
Polling function that runs before the onload event fires, attempting to attach to DOM Nodes as soon as they are available

<private> <static> YAHOO.util.Event._unload(e)
Removes all listeners registered by pe.event. Called automatically during the unload event.
Parameters:
e

<static> {boolean} YAHOO.util.Event.addListener(el, sType, fn, obj, override)
Appends an event handler
Parameters:
{Object} el
The html element to assign the event to
{String} sType
The type of event to append
{Function} fn
The method the event invokes
{Object} obj
An arbitrary object that will be passed as a parameter to the handler
{boolean} override
If true, the obj passed in becomes the execution scope of the listener
Returns:
{boolean} True if the action was successful or defered, false if one or more of the elements could not have the listener attached, or if the operation throws an exception.

<private> <static> YAHOO.util.Event.clearCache()
Clears the element cache
Deprecated:
Elements are not cached any longer

<private> <static> YAHOO.util.Event.fireLegacyEvent(e, legacyIndex)
When using legacy events, the handler is routed to this object so we can fire our custom listener stack.
Parameters:
e
legacyIndex

<static> {string} YAHOO.util.Event.generateId(el)
Generates an unique ID for the element if it does not already have one.
Parameters:
el
the element to create the id for
Returns:
{string} the resulting id of the element

<static> {int} YAHOO.util.Event.getCharCode(ev)
Returns the charcode for an event
Parameters:
{Event} ev
the event
Returns:
{int} the event's charCode

<private> <static> YAHOO.util.Event.getEl(id)
We cache elements bound by id because when the unload event fires, we can no longer use document.getElementById
Parameters:
id

<static> {Event} YAHOO.util.Event.getEvent(e)
Finds the event in the window object, the caller's arguments, or in the arguments of another method in the callstack. This is executed automatically for events registered through the event manager, so the implementer should not normally need to execute this function at all.
Parameters:
{Event} e
the event parameter from the handler
Returns:
{Event} the event

<private> <static> YAHOO.util.Event.getLegacyIndex(el, sType)
Returns the legacy event index that matches the supplied signature
Parameters:
el
sType

<static> {Object} YAHOO.util.Event.getListeners(el, sType)
Returns all listeners attached to the given element via addListener. Optionally, you can specify a specific type of event to return.
Parameters:
el
{HTMLElement} the element to inspect
sType
{string} optional type of listener to return. If left out, all listeners will be returned
Returns:
{Object} the listener. Contains the following fields:   type: (string) the type of event   fn: (function) the callback supplied to addListener   obj: (object) the custom object supplied to addListener   adjust: (boolean) whether or not to adjust the default scope   index: (int) its position in the Event util listener cache

<static> {int} YAHOO.util.Event.getPageX(ev)
Returns the event's pageX
Parameters:
{Event} ev
the event
Returns:
{int} the event's pageX

<static> {int} YAHOO.util.Event.getPageY(ev)
Returns the event's pageY
Parameters:
{Event} ev
the event
Returns:
{int} the event's pageY

<static> {HTMLElement} YAHOO.util.Event.getRelatedTarget(ev)
Returns the event's related target
Parameters:
{Event} ev
the event
Returns:
{HTMLElement} the event's relatedTarget

<static> {HTMLElement} YAHOO.util.Event.getTarget(ev, resolveTextNode)
Returns the event's target element
Parameters:
{Event} ev
the event
{boolean} resolveTextNode
when set to true the target's parent will be returned if the target is a text node. @deprecated, the text node is now resolved automatically
Returns:
{HTMLElement} the event's target

<static> {Date} YAHOO.util.Event.getTime(ev)
Returns the time of the event. If the time is not included, the event is modified using the current time.
Parameters:
{Event} ev
the event
Returns:
{Date} the time of the event

<static> {int[]} YAHOO.util.Event.getXY(ev)
Returns the pageX and pageY properties as an indexed array.
Parameters:
ev

<static> YAHOO.util.Event.onAvailable(p_id, p_fn, p_obj, p_override)
Executes the supplied callback when the item with the supplied id is found. This is meant to be used to execute behavior as soon as possible as the page loads. If you use this after the initial page load it will poll for a fixed time for the element. The number of times it will poll and the frequency are configurable. By default it will poll for 10 seconds.
Parameters:
{string} p_id
the id of the element to look for.
{function} p_fn
what to execute when the element is found.
{object} p_obj
an optional object to be passed back as a parameter to p_fn.
{boolean} p_override
If set to true, p_fn will execute in the scope of p_obj

<static> YAHOO.util.Event.onContentReady(p_id, p_fn, p_obj, p_override)
Works the same way as onAvailable, but additionally checks the state of sibling elements to determine if the content of the available element is safe to modify.
Parameters:
{string} p_id
the id of the element to look for.
{function} p_fn
what to execute when the element is ready.
{object} p_obj
an optional object to be passed back as a parameter to p_fn.
{boolean} p_override
If set to true, p_fn will execute in the scope of p_obj

<static> YAHOO.util.Event.preventDefault(ev)
Prevents the default behavior of the event
Parameters:
{Event} ev
the event

<static> YAHOO.util.Event.purgeElement(el, recurse, sType)
Removes all listeners attached to the given element via addListener. Optionally, the node's children can also be purged. Optionally, you can specify a specific type of event to remove.
Parameters:
{HTMLElement} el
the element to purge
{boolean} recurse
recursively purge this element's children as well. Use with caution.
{string} sType
optional type of listener to purge. If left out, all listeners will be removed

<static> {boolean} YAHOO.util.Event.removeListener(el, sType, fn)
Removes an event handler
Parameters:
{Object} el
the html element or the id of the element to assign the event to.
{String} sType
the type of event to remove.
{Function} fn
the method the event invokes. If fn is undefined, then all event handlers for the type of event are removed.
Returns:
{boolean} true if the unbind was successful, false otherwise.

<static> {HTMLElement} YAHOO.util.Event.resolveTextNode(node)
In some cases, some browsers will return a text node inside the actual element that was targeted. This normalizes the return value for getTarget and getRelatedTarget.
Parameters:
{HTMLElement} node
node to resolve
Returns:
{HTMLElement} the normized node

<private> <static> YAHOO.util.Event.startInterval()

<static> YAHOO.util.Event.stopEvent(ev)
Convenience method for stopPropagation + preventDefault
Parameters:
{Event} ev
the event

<static> YAHOO.util.Event.stopPropagation(ev)
Stops event propagation
Parameters:
{Event} ev
the event

<private> <static> YAHOO.util.Event.useLegacyEvent(el, sType)
Logic that determines when we should automatically use legacy events instead of DOM2 events.
Parameters:
el
sType

Documentation generated by JsDoc Toolkit 2.0.0 on Thu Dec 02 2010 15:18:59 GMT+0100 (CET)