Class: Browser::History
- Includes:
- Native
- 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
Instance Attribute Details
#current ⇒ String (readonly)
Returns the current item.
56 57 58 |
# File 'opal/browser/history.rb', line 56 def current $window.location.path end |
#length ⇒ Integer (readonly)
Returns how many items are in the history.
18 |
# File 'opal/browser/history.rb', line 18 alias_native :length |
Class Method Details
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 41 42 |
# File 'opal/browser/history.rb', line 38 def push(item, data = nil) data = `null` if data.nil? `#@native.pushState(data, null, item)` end |
#replace(item, data = nil) ⇒ Object
Replace the current history item with another.
48 49 50 51 52 |
# File 'opal/browser/history.rb', line 48 def replace(item, data = nil) data = `null` if data.nil? `#@native.replaceState(data, null, item)` end |
#state ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'opal/browser/history.rb', line 63 def state %x{ var state = #@native.state; if (state == null) { return nil; } else { return state; } } end |