An implementation of goog.events.Listenable with full W3C
EventTarget-like support (capture/bubble mechanism, stopping event
propagation, preventing default actions).
A typedef for event like objects that are dispatchable via the
goog.events.dispatchEvent function. strings are treated as the type for a
goog.events.Event. Objects are treated as an extension of a new
goog.events.Event with the type property of the object being used as the type
of the Event.
Dispatches an event (or event like object) and calls all listeners
listening for events of this type. The type of the event is decided by the
type property on the event object.
If any of the listeners returns false OR calls preventDefault then this
function will return false. If one of the capture listeners calls
stopPropagation, then the bubble listeners won't fire.
If anyone called preventDefault on the event object (or
if any of the handlers returns false) this will also return false.
If there are no handlers, or if all handlers return true, this returns
true.
Returns a string with on prepended to the specified type. This is used for IE
which expects "on" to be prepended. This function caches the string in order
to avoid extra allocations in steady state.
Deprecated: This returns estimated count, now that Closure no longer
stores a central listener registry. We still return an estimation
to keep existing listener-related tests passing. In the near future,
this function will be removed.
Gets the total number of listeners currently in the system.
Returns whether an event target has any active listeners matching the
specified signature. If either the type or capture parameters are
unspecified, the function will match on the remaining criteria.
Adds an event listener for a specific event on a native event
target (such as a DOM element) or an object that has implemented
goog.events.Listenable. A listener can only be added once
to an object and if it is added again the key for the listener is
returned. Note that if the existing listener is a one-off listener
(registered via listenOnce), it will no longer be a one-off
listener after a call to listen().
Adds an event listener for a specific event on a native event
target (such as a DOM element) or an object that has implemented
goog.events.Listenable. After the event has fired the event
listener is removed from the target.
If an existing listener already exists, listenOnce will do
nothing. In particular, if the listener was previously registered
via listen(), listenOnce() will not turn the listener into a
one-off listener. Similarly, if there is already an existing
one-off listener, listenOnce does not modify the listeners (it is
still a once listener).
Adds an event listener with a specific event wrapper on a DOM Node or an
object that has implemented goog.events.Listenable. A listener can
only be added once to an object.
Adds an event listener for a specific event on a native event
target. A listener can only be added once to an object and if it
is added again the key for the listener is returned.
Note that a one-off listener will not change an existing listener,
if any. On the other hand a normal listener will change existing
one-off listener to become a normal listener.
Deprecated: This doesn't do anything, now that Closure no longer
stores a central listener registry.
Removes all native listeners registered via goog.events. Native
listeners are listeners on native browser objects (such as DOM
elements). In particular, goog.events.Listenable and
goog.events.EventTarget listeners will NOT be removed.
The listener function or an
object that contains handleEvent method.
Returns
Either the original function or a function that
calls obj.handleEvent. If the same listener is passed to this
function more than once, the same function is guaranteed to be
returned.