History

Fix various issues when switching from single doc to full app

Thibaut Courouble committed 9 years ago

Commit 4f62ccb1 parent 7947f2d4 files · +39 −35Browse files

Showing the changes to assets/javascripts/app (1 of 4 files). Show all

Unified · Split

assets/javascripts/app/router.coffee+22−14
@@ -34,19 +34,24 @@ class app.Router · 33 unmodified lines
3434 return
3535
3636 before: (context, next) ->
37+ previousContext = @context
3738 @context = context
3839 @trigger 'before', context
39− next()
40− return
40+
41+ if res = next()
42+ @context = previousContext
43+ return res
44+ else
45+ return
4146
4247 doc: (context, next) ->
4348 if doc = app.docs.findBySlug(context.params.doc) or app.disabledDocs.findBySlug(context.params.doc)
4449 context.doc = doc
4550 context.entry = doc.toEntry()
4651 @triggerRoute 'entry'
52+ return
4753 else
48− next()
49− return
54+ return next()
5055
5156 type: (context, next) ->
5257 doc = app.docs.findBySlug(context.params.doc)
@@ -55,9 +60,9 @@ class app.Router · 2 unmodified lines
5560 context.doc = doc
5661 context.type = type
5762 @triggerRoute 'type'
63+ return
5864 else
59− next()
60− return
65+ return next()
6166
6267 entry: (context, next) ->
6368 doc = app.docs.findBySlug(context.params.doc)
@@ -66,36 +71,39 @@ class app.Router · 2 unmodified lines
6671 context.doc = doc
6772 context.entry = entry
6873 @triggerRoute 'entry'
74+ return
6975 else
70− next()
71− return
76+ return next()
7277
7378 root: ->
74− if app.isSingleDoc()
75− setTimeout (-> window.location = '/'), 0
76− else
77− @triggerRoute 'root'
79+ return '/' if app.isSingleDoc()
80+ @triggerRoute 'root'
7881 return
7982
80− settings: ->
83+ settings: (context) ->
84+ return "/#/#{context.path}" if app.isSingleDoc()
8185 @triggerRoute 'settings'
8286 return
8387
84− offline: ->
88+ offline: (context)->
89+ return "/#/#{context.path}" if app.isSingleDoc()
8590 @triggerRoute 'offline'
8691 return
8792
8893 about: (context) ->
94+ return "/#/#{context.path}" if app.isSingleDoc()
8995 context.page = 'about'
9096 @triggerRoute 'page'
9197 return
9298
9399 news: (context) ->
100+ return "/#/#{context.path}" if app.isSingleDoc()
94101 context.page = 'news'
95102 @triggerRoute 'page'
96103 return
97104
98105 help: (context) ->
106+ return "/#/#{context.path}" if app.isSingleDoc()
99107 context.page = 'help'
100108 @triggerRoute 'page'
101109 return

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t