Class: Browser::History

Inherits:
Object show all
Includes:
NativeCachedWrapper
Defined in:
opal/browser/history.rb

Overview

History allows manipulation of the session history.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NativeCachedWrapper

#restricted?, #set_native_reference

Instance Attribute Details

#currentString (readonly)



52
53
54
# File 'opal/browser/history.rb', line 52

def current
  $window.location.full_path
end

#lengthInteger (readonly)



18
# File 'opal/browser/history.rb', line 18

alias_native :length

Class Method Details

.supported?Boolean

Check if HTML5 history is supported.



10
11
12
# File 'opal/browser/history.rb', line 10

def self.supported?
  Browser.supports? 'History'
end

Instance Method Details

#back(number = 1) ⇒ Object

Go back in the history.



23
24
25
# File 'opal/browser/history.rb', line 23

def back(number = 1)
  `#@native.go(-number)`
end

#forward(number = 1) ⇒ Object

Go forward in the history.



30
31
32
# File 'opal/browser/history.rb', line 30

def forward(number = 1)
  `#@native.go(number)`
end

#push(item, data = nil) ⇒ Object

Push an item in the history.



38
39
40
# File 'opal/browser/history.rb', line 38

def push(item, data = nil)
  `#@native.pushState(#{data.to_n}, null, item)`
end

#replace(item, data = nil) ⇒ Object

Replace the current history item with another.



46
47
48
# File 'opal/browser/history.rb', line 46

def replace(item, data = nil)
  `#@native.replaceState(#{data.to_n}, null, item)`
end

#stateObject

Raises:

  • (NotImplementedError)


59
60
61
62
63
64
65
66
67
68
69
70
# File 'opal/browser/history.rb', line 59

def state
  %x{
    var state = #@native.state;

    if (state == null) {
      return nil;
    }
    else {
      return state;
    }
  }
end