Class: Browser::History
- Includes:
- Native
- Defined in:
- lib/roda/component/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.
Instance Method Summary collapse
-
#back(number = 1) ⇒ Object
Go back in the history.
- #change(&block) ⇒ Object
-
#forward(number = 1) ⇒ Object
Go forward in the history.
- #get_state ⇒ Object
-
#push(item, data = nil) ⇒ Object
Push an item in the history.
-
#replace(item, data = nil) ⇒ Object
Replace the current history item with another.
Instance Attribute Details
#current ⇒ String (readonly)
Returns the current item.
68 69 70 |
# File 'lib/roda/component/history.rb', line 68 def current $window.location.path end |
#length ⇒ Integer (readonly)
Returns how many items are in the history.
26 |
# File 'lib/roda/component/history.rb', line 26 alias_native :length |
Instance Method Details
#back(number = 1) ⇒ Object
Go back in the history.
31 32 33 |
# File 'lib/roda/component/history.rb', line 31 def back(number = 1) `History.go(-number)` end |
#change(&block) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/roda/component/history.rb', line 72 def change &block %x{ History.Adapter.bind(window,'statechange',function(e){ var state = History.getState(); state = #{Native(`state`)} return #{block.call(`state`)} }); } end |
#forward(number = 1) ⇒ Object
Go forward in the history.
38 39 40 |
# File 'lib/roda/component/history.rb', line 38 def forward(number = 1) `History.go(number)` end |
#get_state ⇒ Object
62 63 64 |
# File 'lib/roda/component/history.rb', line 62 def get_state Native(`History.getState()`) end |
#push(item, data = nil) ⇒ Object
Push an item in the history.
46 47 48 49 50 |
# File 'lib/roda/component/history.rb', line 46 def push(item, data = nil) data = `null` if data.nil? `History.pushState(jQuery.parseJSON(data.$to_json()), null, item)` end |
#replace(item, data = nil) ⇒ Object
Replace the current history item with another.
56 57 58 59 60 |
# File 'lib/roda/component/history.rb', line 56 def replace(item, data = nil) data = `null` if data.nil? `History.replaceState(data, null, item)` end |