class Browser::History

{History} allows manipulation of the session history.

@see developer.mozilla.org/en-US/docs/Web/API/History

Public Instance Methods

back(number = 1) click to toggle source

Go back in the history.

@param number [Integer] how many items to go back

# File lib/wedge/plugins/history.rb, line 40
def back(number = 1)
  `History.go(-number)`
end
change(&block) click to toggle source
# 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
current() click to toggle source

@!attribute [r] current @return [String] the current item

# File lib/wedge/plugins/history.rb, line 77
def current
  $window.location.path
end
forward(number = 1) click to toggle source

Go forward in the history.

@param number [Integer] how many items to go forward

# File lib/wedge/plugins/history.rb, line 47
def forward(number = 1)
  `History.go(number)`
end
get_state() click to toggle source
# File lib/wedge/plugins/history.rb, line 71
def get_state
  Native(`History.getState()`)
end
push(item, data = nil) click to toggle source

Push an item in the history.

@param item [String] the item to push in the history @param data [Object] additional state to push

# 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) click to toggle source

Replace the current history item with another.

@param item [String] the item to replace with @param data [Object] additional state to replace

# File lib/wedge/plugins/history.rb, line 65
def replace(item, data = nil)
  data = `null` if data.nil?

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