Class: JSEvent

Inherits:
Object show all
Defined in:
lib/volt/page/bindings/event_binding.rb

Overview

TODO: We need to figure out how we want to wrap JS events

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(js_event) ⇒ JSEvent

Returns a new instance of JSEvent.



6
7
8
# File 'lib/volt/page/bindings/event_binding.rb', line 6

def initialize(js_event)
  @js_event = js_event
end

Instance Attribute Details

#js_eventObject (readonly)

Returns the value of attribute js_event.



5
6
7
# File 'lib/volt/page/bindings/event_binding.rb', line 5

def js_event
  @js_event
end

Instance Method Details

#key_codeObject



10
11
12
# File 'lib/volt/page/bindings/event_binding.rb', line 10

def key_code
  `this.js_event.keyCode`
end

#prevent_default!Object



18
19
20
# File 'lib/volt/page/bindings/event_binding.rb', line 18

def prevent_default!
  `this.js_event.preventDefault();`
end

#stop!Object



14
15
16
# File 'lib/volt/page/bindings/event_binding.rb', line 14

def stop!
  `this.js_event.stopPropagation();`
end

#targetObject



22
23
24
# File 'lib/volt/page/bindings/event_binding.rb', line 22

def target
  `this.js_event.toElement`
end