Skip to content

Commit

Permalink
Refactor router properties currentView, currentPath to view, path
Browse files Browse the repository at this point in the history
  • Loading branch information
sderickson committed Sep 29, 2015
1 parent 61392a0 commit a676093
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ class Router extends Backbone.Router
window.location.reload(true)

routeDirectly: (path, args) ->
return document.location.reload() if @currentView?.reloadOnClose
leavingMessage = _.result(@currentView, 'onLeaveMessage')
return document.location.reload() if @view?.reloadOnClose
leavingMessage = _.result(@view, 'onLeaveMessage')
if leavingMessage
if not confirm(leavingMessage)
return @navigate(this.currentPath, {replace: true})
return @navigate(this.path, {replace: true})

path = "views/#{path}"

Expand All @@ -31,17 +31,17 @@ class Router extends Backbone.Router
@closeCurrentView()
view.render()
$('body').empty().append(view.el)
@currentView = view
@currentPath = document.location.pathname + document.location.search
@view = view
@path = document.location.pathname + document.location.search
view.onInsert()

closeCurrentView: -> @currentView?.destroy()
closeCurrentView: -> @view?.destroy()

setupOnLeaveSite: ->
window.addEventListener "beforeunload", (e) =>
leavingMessage = _.result(@currentView, 'onLeaveMessage')
leavingMessage = _.result(@view, 'onLeaveMessage')
if leavingMessage
e.returnValue = leavingMessage
return leavingMessage

FrimFram.Router = Router
FrimFram.Router = Router

0 comments on commit a676093

Please sign in to comment.