2014-01-03 13:32:13 -05:00
|
|
|
app = require 'application'
|
|
|
|
|
2014-02-24 14:12:52 -05:00
|
|
|
init = ->
|
2014-01-03 13:32:13 -05:00
|
|
|
app.initialize()
|
|
|
|
Backbone.history.start({ pushState: true })
|
|
|
|
handleNormalUrls()
|
2014-02-24 14:12:52 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
treemaExt = require 'treema-ext'
|
|
|
|
treemaExt.setup()
|
|
|
|
filepicker.setKey('AvlkNoldcTOU4PvKi2Xm7z')
|
|
|
|
|
2014-04-02 16:12:24 -04:00
|
|
|
$ -> init()
|
2014-02-24 14:12:52 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
handleNormalUrls = ->
|
|
|
|
# http://artsy.github.com/blog/2012/06/25/replacing-hashbang-routes-with-pushstate/
|
|
|
|
$(document).on "click", "a[href^='/']", (event) ->
|
|
|
|
|
|
|
|
href = $(event.currentTarget).attr('href')
|
|
|
|
|
|
|
|
# chain 'or's for other black list routes
|
|
|
|
passThrough = href.indexOf('sign_out') >= 0
|
|
|
|
|
|
|
|
# Allow shift+click for new tabs, etc.
|
|
|
|
if !passThrough && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
# Remove leading slashes and hash bangs (backward compatablility)
|
|
|
|
url = href.replace(/^\//,'').replace('\#\!\/','')
|
|
|
|
|
|
|
|
# Instruct Backbone to trigger routing events
|
|
|
|
app.router.navigate url, { trigger: true }
|
|
|
|
|
|
|
|
return false
|
|
|
|
|