int |
ADJ_SCOPE
Adjusted scope, either the element we are registering the event
on or the custom object passed in by the listener, int constant
|
int |
EL
Element to bind, int constant
|
int |
FN
Function to execute, int constant
|
int |
POLL_INTERVAL
The poll interval in milliseconds
|
int |
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.
|
int |
SCOPE
Object passed in by the user that will be returned as a
parameter to the callback, int constant
|
int |
TYPE
Type of event, int constant
|
int |
WFN
Function wrapped for scope correction and cleanup, int constant
|
Class YAHOO.util.Event
Object | +--YAHOO.util.Event
class
YAHOO.util.Event
Field Summary [top]
Method Summary [top]
boolean |
addListener
(<Object> el, <String> sType, <Function> fn, <Object> oScope, <boolean> bOverride)
Appends an event handler
|
string |
generateId
(el)
Generates an unique ID for the element if it does not already
have one.
|
int |
getCharCode
(<Event> ev)
Returns the charcode for an event
|
Event |
getEvent
(e)
Finds the event in the window object, the caller's arguments, or
in the arguments of another method in the callstack.
|
Object |
getListeners
(el, sType)
Returns all listeners attached to the given element via addListener.
|
int |
getPageX
(<Event> ev)
Returns the event's pageX
|
int |
getPageY
(<Event> ev)
Returns the event's pageY
|
HTMLElement |
getRelatedTarget
(<Event> ev)
Returns the event's related target
|
HTMLElement |
getTarget
(<Event> ev, <boolean> resolveTextNode)
Returns the event's target element
|
Date |
getTime
(<Event> ev)
Returns the time of the event.
|
int[] |
getXY
(ev)
Returns the pageX and pageY properties as an indexed array.
|
void |
onAvailable
(<string> p_id, <function> p_fn, <object> p_obj, <boolean> p_override)
Executes the supplied callback when the item with the supplied
id is found.
|
void |
preventDefault
(<Event> ev)
Prevents the default behavior of the event
|
void |
purgeElement
(<HTMLElement> el, <boolean> recurse, <string> sType)
Removes all listeners attached to the given element via addListener.
|
boolean |
removeListener
(<Object> el, <String> sType, <Function> fn, index)
Removes an event handler
|
Object |
resolveTextNode
(<HTMLElement> node)
In some cases, some browsers will return a text node inside
the actual element that was targeted.
|
void |
stopEvent
(<Event> ev)
Convenience method for stopPropagation + preventDefault
|
void |
stopPropagation
(<Event> ev)
Stops event propagation
|
Field Detail [top]
ADJ_SCOPE
int
ADJ_SCOPE
Adjusted scope, either the element we are registering the event
on or the custom object passed in by the listener, int constant
EL
int
EL
Element to bind, int constant
FN
int
FN
Function to execute, int constant
POLL_INTERVAL
int
POLL_INTERVAL
The poll interval in milliseconds
POLL_RETRYS
int
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
SCOPE
int
SCOPE
Object passed in by the user that will be returned as a
parameter to the callback, int constant
TYPE
int
TYPE
Type of event, int constant
WFN
int
WFN
Function wrapped for scope correction and cleanup, int constant
Constructor Detail [top]
YAHOO.util.Event
YAHOO.util.Event
()
Method Detail [top]
addListener
boolean
addListener
(<Object> el, <String> sType, <Function> fn, <Object> oScope, <boolean> bOverride)
Appends an event handler
- Parameters:
-
el
- The html element to assign the event to -
sType
- The type of event to append -
fn
- The method the event invokes -
oScope
- An arbitrary object that will be passed as a parameter to the handler -
bOverride
- If true, the obj passed in becomes the execution scope of the listener
- Returns:
- True if the action was successful or defered, false if one or more of the elements could not have the event bound to it.
generateId
string
generateId
(el)
Generates an unique ID for the element if it does not already
have one.
- Parameters:
-
el
- the element
- Returns:
- the id of the element
getCharCode
int
getCharCode
(<Event> ev)
Returns the charcode for an event
- Parameters:
-
ev
- the event
- Returns:
- the event's charCode
getEvent
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:
-
the
- event parameter from the handler
- Returns:
- the event
getListeners
Object
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:
- 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
getPageX
int
getPageX
(<Event> ev)
Returns the event's pageX
- Parameters:
-
ev
- the event
- Returns:
- the event's pageX
getPageY
int
getPageY
(<Event> ev)
Returns the event's pageY
- Parameters:
-
ev
- the event
- Returns:
- the event's pageY
getRelatedTarget
HTMLElement
getRelatedTarget
(<Event> ev)
Returns the event's related target
- Parameters:
-
ev
- the event
- Returns:
- the event's relatedTarget
getTarget
HTMLElement
getTarget
(<Event> ev, <boolean> resolveTextNode)
Returns the event's target element
- Parameters:
-
ev
- the event -
resolveTextNode
- when set to true the target's parent will be returned if the target is a text node.
- Returns:
- the event's target
getTime
Date
getTime
(<Event> ev)
Returns the time of the event. If the time is not included, the
event is modified using the current time.
- Parameters:
-
ev
- the event
- Returns:
- the time of the event
getXY
int[]
getXY
(ev)
Returns the pageX and pageY properties as an indexed array.
onAvailable
void
onAvailable
(<string> p_id, <function> p_fn, <object> p_obj, <boolean> 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:
-
p_id
- the id of the element to look for. -
p_fn
- what to execute when the element is found. -
p_obj
- an optional object to be passed back as a parameter to p_fn. -
p_override
- If set to true, p_fn will execute in the scope of p_obj
preventDefault
void
preventDefault
(<Event> ev)
Prevents the default behavior of the event
- Parameters:
-
ev
- the event
purgeElement
void
purgeElement
(<HTMLElement> el, <boolean> recurse, <string> 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:
-
el
- the element to purge -
recurse
- recursively purge this element's children as well. Use with caution. -
sType
- optional type of listener to purge. If left out, all listeners will be removed
removeListener
boolean
removeListener
(<Object> el, <String> sType, <Function> fn, index)
Removes an event handler
- Parameters:
-
el
- the html element or the id of the element to assign the event to. -
sType
- the type of event to remove -
fn
- the method the event invokes
- Returns:
- true if the unbind was successful, false otherwise
resolveTextNode
Object
resolveTextNode
(<HTMLElement> 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:
-
node
- to resolve
- Returns:
- the normized node
stopEvent
void
stopEvent
(<Event> ev)
Convenience method for stopPropagation + preventDefault
- Parameters:
-
ev
- the event
stopPropagation
void
stopPropagation
(<Event> ev)
Stops event propagation
- Parameters:
-
ev
- the event