Class: Browser::History
- Includes:
- NativeCachedWrapper
- Defined in:
- opal/browser/history.rb
Overview
History allows manipulation of the session history.
Instance Attribute Summary collapse
-
#current ⇒ String
readonly
The current item.
-
#length ⇒ Integer
readonly
How many items are in the history.
Class Method Summary collapse
-
.supported? ⇒ Boolean
Check if HTML5 history is supported.
Instance Method Summary collapse
-
#back(number = 1) ⇒ Object
Go back in the history.
-
#forward(number = 1) ⇒ Object
Go forward in the history.
-
#push(item, data = nil) ⇒ Object
Push an item in the history.
-
#replace(item, data = nil) ⇒ Object
Replace the current history item with another.
- #state ⇒ Object
Methods included from NativeCachedWrapper
#restricted?, #set_native_reference
Instance Attribute Details
permalink #current ⇒ String (readonly)
Returns the current item.
53 54 55 |
# File 'opal/browser/history.rb', line 53 def current $window.location.full_path end |
permalink #length ⇒ Integer (readonly)
Returns how many items are in the history.
19 |
# File 'opal/browser/history.rb', line 19 alias_native :length |
Class Method Details
permalink .supported? ⇒ Boolean
Check if HTML5 history is supported.
11 12 13 |
# File 'opal/browser/history.rb', line 11 def self.supported? Browser.supports? 'History' end |
Instance Method Details
permalink #back(number = 1) ⇒ Object
Go back in the history.
24 25 26 |
# File 'opal/browser/history.rb', line 24 def back(number = 1) `#@native.go(-number)` end |
permalink #forward(number = 1) ⇒ Object
Go forward in the history.
31 32 33 |
# File 'opal/browser/history.rb', line 31 def forward(number = 1) `#@native.go(number)` end |
permalink #push(item, data = nil) ⇒ Object
Push an item in the history.
39 40 41 |
# File 'opal/browser/history.rb', line 39 def push(item, data = nil) `#@native.pushState(#{data.to_n}, null, item)` end |
permalink #replace(item, data = nil) ⇒ Object
Replace the current history item with another.
47 48 49 |
# File 'opal/browser/history.rb', line 47 def replace(item, data = nil) `#@native.replaceState(#{data.to_n}, null, item)` end |
permalink #state ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'opal/browser/history.rb', line 60 def state %x{ var state = #@native.state; if (state == null) { return nil; } else { return state; } } end |