Sha256: 8342ed5ece721f895d938d58703f65110f0f5b6d9ad0fe082a1ed5270e7823d1

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 Bytes

Contents

Class.bridge_class 'Event', `$.Event`

# Wraps native jQuery event objects.
class Event
  def [](name)
    `#{self}[name]`
  end

  def ctrl_key
    @ctrlKey
  end

  def current_target
    `$(#{self}.currentTarget)`
  end

  def default_prevented?
    `#{self}.isDefaultPrevented()`
  end

  # Stops propagation and prevents default action.
  def kill
    stop_propagation
    prevent_default
  end

  alias_native :prevent_default, :preventDefault

  def page_x
    `#{self}.pageX`
  end

  def page_y
    `#{self}.pageY`
  end

  alias_native :propagation_stopped?, :propagationStopped

  alias_native :stop_propagation, :stopPropagation

  alias_native :stop_immediate_propagation, :stopImmediatePropagation

  def target
    `$(#{self}.target)`
  end

  def touch_x
    `#{self}.originalEvent.touches[0].pageX`
  end

  def touch_y
    `#{self}.originalEvent.touches[0].pageY`
  end

  def type
    @type
  end

  def which
    @which
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-jquery-0.0.11 opal/opal-jquery/event.rb
opal-jquery-0.0.9 opal/opal-jquery/event.rb