Static class to manage events. It will return itself if it is tried to be instantiated.
- Source:
Methods
-
<static> add()
-
Alias for
CB_Events.on.- Source:
- See:
-
<static> executeByName(eventTarget, eventName [, e] [, returnOnNothingExecuted]) → {boolean}
-
Executes all event listeners for an specific event from a node (target).
Parameters:
Name Type Argument Description eventTargetObject The target whose event listeners we want to execute. It will be the value of "this" for every call to each listener.
eventNamestring The name of the event whose event listeners we want to execute.
eEvent <optional>
Event object that will be passed as the first and unique parameter for every call to each listener.
returnOnNothingExecuted* <optional>
The value that will be returned by the function if nothing is executed.
- Source:
Returns:
Returns the result of doing the AND operator of all return values of each listener executed. If only one listener is executed, it will return the result of doing the AND operator with its returning value and "true". Returns the value of the "returnOnNothingExecuted" parameter if nothing is executed.
- Type
- boolean
-
<static> getAll() → {array}
-
Returns all stored event handlers (if any).
- Source:
Returns:
Returns an array of
CB_Events.EVENT_HANDLERobjects.- Type
- array
-
<static> getByName(eventTarget, eventName [, onlyWithFunction]) → {array}
-
Returns all handlers for an specific event from a node (target), if any.
Parameters:
Name Type Argument Default Description eventTargetObject The target whose event listeners we want to get.
eventNamestring The name of the event whose event listeners we want to get.
onlyWithFunctionboolean <optional>
false Defines whether to return only the handlers which have a function as the listener.
- Source:
Returns:
Returns an array of
CB_Events.EVENT_HANDLERobjects.- Type
- array
-
<static> getType(e) → {string}
-
Returns the type of an event, if any (otherwise, returns an empty string).
Parameters:
Name Type Description eEvent Event object.
- Source:
Returns:
- Type
- string
-
<static> normalize(e) → {Event}
-
Gets the right event object for the current web client and normalizes it attaching to it some methods and properties if they were not present (as preventDefault, stopPropagation, target, etc.). The new attached methods and properties may include polyfills, etc.
Parameters:
Name Type Description eEvent Event object. If not provided, it will use the value of "event", "window.event", "Event" or an empty object ("{}").
- Source:
Returns:
Returns the event object normalized.
- Type
- Event
-
<static> on(eventTarget, eventName, eventFunction [, useCapture] [, keepOldEventFunction] [, erasable])
-
Adds an event listener.
Parameters:
Name Type Argument Default Description eventTargetObject The target where we want to attach the event listener.
eventNamestring The name of the event that we want to add.
eventFunctionfunction The function (event listener) of the event that we want to add.
useCaptureboolean <optional>
false Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.
keepOldEventFunctionboolean <optional>
true Defines whether we want to keep any possible previous event listener for the same target and event name or not.
erasableboolean <optional>
true Defines whether the event listener will be erasable by
CB_Events.removeAllorCB_Events.removeByNamefunctions later or not (it will always be erasable if we force delete).- Source:
- To Do:
-
- Try to simulate "useCapture" when the "addEventListener" method is not available.
-
<static> remove(eventTarget, eventName, eventFunction [, useCapture])
-
Removes an event listener (even if it is not erasable).
Parameters:
Name Type Argument Default Description eventTargetObject The target whose event listener we want to remove.
eventNamestring The name of the event that we want to remove.
eventFunctionfunction The function (event listener) of the event that we want to remove.
useCaptureboolean <optional>
false Defines whether the event we want to remove was defined to use capture or not.
- Source:
-
<static> removeAll( [forceDelete])
-
Removes all event listeners.
Parameters:
Name Type Argument Default Description forceDeleteboolean <optional>
false If it is set to true, it will remove all event listeners (even the ones which were added as not erasable).
- Source:
-
<static> removeByName(eventTarget, eventName [, forceDelete])
-
Deletes all handlers for an specific event from a node (target).
Parameters:
Name Type Argument Default Description eventTargetObject The target whose event listeners we want to remove.
eventNamestring The name of the event whose event listeners we want to remove.
forceDeleteboolean <optional>
false If it is set to true, it will remove any listener (even the ones which were added as not erasable).
- Source:
Type Definitions
-
EVENT_HANDLER
-
Object that contains an event handler.
Type:
- Object
- Source:
Properties:
Name Type Description eventTargetObject The target of the event.
eventNamestring The name of the event.
eventFunctionfunction The event listener.
useCaptureboolean Defines whether the event listener was defined to use capture or not.
erasableboolean Defines whether the event handler is erasable (without forcing delete) or not.