Module: DOM::Window

Extended by:
Events
Defined in:
opal/fron/dom/window.rb

Overview

Window

Instance Attribute Summary

Attributes included from Events

#listeners

Class Method Summary collapse

Methods included from Events

addListener, delegate, off, on, on!, removeListeners, trigger

Class Method Details

.hashString

Returns the locations hash


26
27
28
# File 'opal/fron/dom/window.rb', line 26

def self.hash
  `window.location.hash.slice(1)`
end

.hash=(value) ⇒ Object

Sets the locations hash with the given value


33
34
35
# File 'opal/fron/dom/window.rb', line 33

def self.hash=(value)
  `window.location.hash = #{value}`
end

.scrollXNumeric

Returns the X scroll position of the window


47
48
49
# File 'opal/fron/dom/window.rb', line 47

def self.scrollX
  `window.scrollX || document.documentElement.scrollTop`
end

.scrollYNumeric

Returns the Y scroll position of the window


40
41
42
# File 'opal/fron/dom/window.rb', line 40

def self.scrollY
  `window.scrollY || document.documentElement.scrollTop`
end

.stateString

Returns the locations pathname as state


19
20
21
# File 'opal/fron/dom/window.rb', line 19

def self.state
  `window.location.pathname`
end

.state=(url) ⇒ Object

Sets the url via pushState


10
11
12
13
14
# File 'opal/fron/dom/window.rb', line 10

def self.state=(url)
  return if url == state
  `window.history.pushState({},'',#{url})`
  timeout { trigger 'popstate' }
end