Class: Browser::History

Inherits:
Object show all
Includes:
Native
Defined in:
lib/wedge/plugins/history.rb

Overview

History allows manipulation of the session history.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#currentString (readonly)



77
78
79
# File 'lib/wedge/plugins/history.rb', line 77

def current
  $window.location.path
end

#lengthInteger (readonly)



35
# File 'lib/wedge/plugins/history.rb', line 35

alias_native :length

Instance Method Details

#back(number = 1) ⇒ Object

Go back in the history.



40
41
42
# File 'lib/wedge/plugins/history.rb', line 40

def back(number = 1)
  `History.go(-number)`
end

#change(&block) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/wedge/plugins/history.rb', line 81

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.



47
48
49
# File 'lib/wedge/plugins/history.rb', line 47

def forward(number = 1)
  `History.go(number)`
end

#get_stateObject



71
72
73
# File 'lib/wedge/plugins/history.rb', line 71

def get_state
  Native(`History.getState()`)
end

#push(item, data = nil) ⇒ Object

Push an item in the history.



55
56
57
58
59
# File 'lib/wedge/plugins/history.rb', line 55

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.



65
66
67
68
69
# File 'lib/wedge/plugins/history.rb', line 65

def replace(item, data = nil)
  data = `null` if data.nil?

  `History.replaceState(data, null, item)`
end