Sha256: cefd2bc07bb0401af206d5c54151fdf410dd71ec48821c26b63e037ae41566b0

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

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

# Wraps native jQuery event objects.
class Event
  %x{
    var bridge_class = $.Event;

    #{self}._proto = bridge_class.prototype, def = #{self}._proto;
    bridge_class.prototype._klass = #{self};
  }

  include Kernel

  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.13 opal/opal-jquery/event.rb
opal-jquery-0.0.12 opal/opal-jquery/event.rb