Sha256: 853403ad7995602f8e20489c259173ead96afa0a8c153219d552dfba6d622af2

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

CATARSE.Router = Backbone.Router.extend({

  initialize: function(options){
    _.bindAll(this, "hashChange", "back", "currentPath", "lastPath")
    this.history = [this.currentPath()]
    $(window).bind('hashchange', this.hashChange)
  },
  
  currentPath: function() {
    var path = location.pathname + location.hash
    if(!/#/.test(path))
      path = path + "#"
    return path
  },
  
  lastPath: function() {
    var path = this.history[this.history.length - 2]
    if(!path)
      path = "#"
    return path
  },
  
  hashChange: function() {
    this.history.push(this.currentPath())
  },
  
  back: function() {
    location.href = this.lastPath()
  }
  
})

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
catarse_core-1.0.0.beta app/assets/javascripts/app/router.js