Prototype JavaScript framework

namespace Event

Instance methods

  • element

    Event#element() -> Element
    Event.element(event) -> Element

    Returns the DOM element on which the event occurred.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • findElement

    Event#findElement(expression) -> Element
    Event.findElement(event, expression) -> Element

    Returns the first DOM element that matches a given CSS selector — starting with the element on which the event occurred, then moving up its ancestor chain.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • isLeftClick

    Event#isLeftClick() -> Boolean
    Event.isLeftClick(event) -> Boolean

    Determines whether a button-related mouse event involved the left mouse button.

    Keep in mind that the "left" mouse button is actually the "primary" mouse button. When a mouse is in left-handed mode, the browser will report clicks of the right button as "left-clicks."

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • isMiddleClick

    Event#isMiddleClick() -> Boolean
    Event.isMiddleClick(event) -> Boolean

    Determines whether a button-related mouse event involved the middle mouse button.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • isRightClick

    Event#isRightClick() -> Boolean
    Event.isRightClick(event) -> Boolean

    Determines whether a button-related mouse event involved the right mouse button.

    Keep in mind that the "left" mouse button is actually the "secondary" mouse button. When a mouse is in left-handed mode, the browser will report clicks of the left button as "left-clicks."

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • pointer

    Event#pointer() -> Object
    Event.pointer(event) -> Object

    Returns the absolute position of the pointer for a mouse event.

    Returns an object in the form { x: Number, y: Number}.

    Note that this position is absolute on the page, not on the viewport.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • pointerX

    Event#pointerX(event) -> Number

    Returns the absolute horizontal position of the pointer for a mouse event.

    Note that this position is absolute on the page, not on the viewport.

  • pointerY

    Event#pointerY(event) -> Number

    Returns the absolute vertical position of the pointer for a mouse event.

    Note that this position is absolute on the page, not on the viewport.

  • stop

    Event#stop() -> undefined
    Event.stop(event) -> undefined

    Stops the event’s propagation and prevents its eventual default action from being triggered.

    Stopping an event also sets a stopped property on that event for future inspection.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

Class methods

  • fire

    Event.fire(element, eventName[, memo[, bubble = true]]) -> Event
    • memo (?) – Metadata for the event. Will be accessible through the event's memo property.
    • bubble (Boolean) – Whether the event will bubble.

    Fires a custom event of name eventName with element as its target.

    Custom events must include a colon (:) in their names.

  • observe

    Event.observe(element, eventName, handler) -> Element

    Registers an event handler on a DOM element.

  • stopObserving

    Event.stopObserving(element[, eventName[, handler]]) -> Element

    Unregisters one or more event handlers.

    If handler is omitted, unregisters all event handlers on element for that eventName. If eventName is also omitted, unregisters all event handlers on element.