Class: Browser::Event
- Includes:
- Native
- Defined in:
- opal/browser/event.rb,
opal/browser/event/ui.rb,
opal/browser/event/base.rb,
opal/browser/event/drag.rb,
opal/browser/event/close.rb,
opal/browser/event/focus.rb,
opal/browser/event/mouse.rb,
opal/browser/event/touch.rb,
opal/browser/event/wheel.rb,
opal/browser/event/custom.rb,
opal/browser/event/sensor.rb,
opal/browser/event/gamepad.rb,
opal/browser/event/message.rb,
opal/browser/event/storage.rb,
opal/browser/event/keyboard.rb,
opal/browser/event/progress.rb,
opal/browser/event/animation.rb,
opal/browser/event/clipboard.rb,
opal/browser/event/pop_state.rb,
opal/browser/event/composition.rb,
opal/browser/event/hash_change.rb,
opal/browser/event/device_light.rb,
opal/browser/event/before_unload.rb,
opal/browser/event/device_motion.rb,
opal/browser/event/page_transition.rb,
opal/browser/event/audio_processing.rb,
opal/browser/event/device_proximity.rb,
opal/browser/event/device_orientation.rb
Direct Known Subclasses
Animation, AudioProcessing, BeforeUnload, Clipboard, Close, Custom, DeviceLight, DeviceMotion, DeviceOrientation, DeviceProximity, Drag, Gamepad, HashChange, Message, PageTransition, PopState, Progress, Sensor, Storage, Touch, UI
Defined Under Namespace
Modules: Target Classes: Animation, AudioProcessing, BeforeUnload, Clipboard, Close, Composition, Custom, Definition, DeviceLight, DeviceMotion, DeviceOrientation, DeviceProximity, Drag, Focus, Gamepad, HashChange, Keyboard, Message, Mouse, PageTransition, PopState, Progress, Sensor, Storage, Touch, UI, Wheel
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
- #on ⇒ Object
Class Method Summary collapse
- .aliases ⇒ Object
- .class_for(name) ⇒ Object
- .construct(name, desc) ⇒ Object
- .create(name, *args, &block) ⇒ Object
- .name_for(name) ⇒ Object
- .new(value, callback = nil) ⇒ Object
- .supported? ⇒ Boolean
Instance Method Summary collapse
- #arguments ⇒ Object
- #arguments=(args) ⇒ Object
-
#initialize(event, callback = nil) ⇒ Event
constructor
A new instance of Event.
- #name ⇒ Object
- #off ⇒ Object
- #prevent ⇒ Object
- #prevented? ⇒ Boolean
- #stop ⇒ Object
- #stop! ⇒ Object
- #stopped? ⇒ Boolean
- #target ⇒ Object
Constructor Details
#initialize(event, callback = nil) ⇒ Event
Returns a new instance of Event.
193 194 195 196 197 |
# File 'opal/browser/event.rb', line 193 def initialize(event, callback = nil) super(event) @callback = callback end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback
190 191 192 |
# File 'opal/browser/event.rb', line 190 def callback @callback end |
Class Method Details
.aliases ⇒ Object
33 34 35 36 37 38 |
# File 'opal/browser/event.rb', line 33 def self.aliases @aliases ||= { 'dom:load' => 'DOMContentLoaded', 'hover' => 'mouse:over' } end |
.class_for(name) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'opal/browser/event.rb', line 44 def self.class_for(name) case name_for(name) when 'animationend', 'animationiteration', 'animationstart' Animation when 'audioprocess' AudioProcessing when 'beforeunload' BeforeUnload when 'compositionend', 'compositionstart', 'compositionupdate' Composition when 'copy', 'cut' Clipboard when 'devicelight' DeviceLight when 'devicemotion' DeviceMotion when 'deviceorientation' DeviceOrientation when 'deviceproximity' DeviceProximity when 'drag', 'dragend', 'dragleave', 'dragover', 'dragstart', 'drop' Drag when 'gamepadconnected', 'gamepaddisconnected' Gamepad when 'hashchange' HashChange when 'load', 'loadend', 'loadstart' Progress when 'pagehide', 'pageshow' PageTransition when 'popstate' PopState when 'storage' Storage when 'touchcancel', 'touchend', 'touchleave', 'touchmove', 'touchstart' Touch when 'compassneedscalibration', 'userproximity' Sensor when 'message' Message when 'close' Close when 'click', 'contextmenu', 'dblclick', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'show' Mouse when 'keydown', 'keypress', 'keyup' Keyboard when 'blur', 'focus', 'focusin', 'focusout' Focus when 'wheel' Wheel when 'abort', 'afterprint', 'beforeprint', 'cached', 'canplay', 'canplaythrough', 'change', 'chargingchange', 'chargingtimechange', 'checking', 'close', 'dischargingtimechange', 'DOMContentLoaded', 'downloading', 'durationchange', 'emptied', 'ended', 'error', 'fullscreenchange', 'fullscreenerror', 'input', 'invalid', 'levelchange', 'loadeddata', 'loadedmetadata', 'noupdate', 'obsolete', 'offline', 'online', 'open', 'orientationchange', 'pause', 'pointerlockchange', 'pointerlockerror', 'play', 'playing', 'ratechange', 'readystatechange', 'reset', 'seeked', 'seeking', 'stalled', 'submit', 'success', 'suspend', 'timeupdate', 'updateready', 'visibilitychange', 'volumechange', 'waiting' Event else Custom end end |
.construct(name, desc) ⇒ Object
153 154 155 |
# File 'opal/browser/event.rb', line 153 def self.construct(name, desc) `new Event(#{name}, #{desc})` end |
.create(name, *args, &block) ⇒ Object
142 143 144 145 146 147 148 149 150 |
# File 'opal/browser/event.rb', line 142 def self.create(name, *args, &block) name = name_for(name) klass = class_for(name) event = klass.new(klass.construct(name, klass.const_get(:Definition).new(&block))) event.arguments = args event end |
.name_for(name) ⇒ Object
40 41 42 |
# File 'opal/browser/event.rb', line 40 def self.name_for(name) (aliases[name] || name).gsub(?:, '') end |
.new(value, callback = nil) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 |
# File 'opal/browser/event.rb', line 178 def self.new(value, callback = nil) return super unless self == Event klass = class_for(callback ? callback.name : `value.type`) if klass == Event super else klass.new(value, callback) end end |
.supported? ⇒ Boolean
138 139 140 |
# File 'opal/browser/event.rb', line 138 def self.supported? true end |
Instance Method Details
#arguments ⇒ Object
211 212 213 |
# File 'opal/browser/event.rb', line 211 def arguments `#@native.arguments || []` end |
#arguments=(args) ⇒ Object
215 216 217 |
# File 'opal/browser/event.rb', line 215 def arguments=(args) `#@native.arguments = #{args}` end |
#name ⇒ Object
199 200 201 |
# File 'opal/browser/event.rb', line 199 def name `#@native.type` end |
#off ⇒ Object
225 226 227 |
# File 'opal/browser/event.rb', line 225 def off @callback.off if @callback end |
#prevent ⇒ Object
238 239 240 241 |
# File 'opal/browser/event.rb', line 238 def prevent `#@native.preventDefault()` if defined?(`#@native.preventDefault`) `#@native.prevented = true` end |
#prevented? ⇒ Boolean
243 244 245 |
# File 'opal/browser/event.rb', line 243 def prevented? `!!#@native.prevented` end |
#stop ⇒ Object
233 234 235 236 |
# File 'opal/browser/event.rb', line 233 def stop `#@native.stopPropagation()` if defined?(`#@native.stopPropagation`) `#@native.stopped = true` end |
#stop! ⇒ Object
247 248 249 250 |
# File 'opal/browser/event.rb', line 247 def stop! prevent stop end |
#stopped? ⇒ Boolean
229 230 231 |
# File 'opal/browser/event.rb', line 229 def stopped? `!!#@native.stopped` end |