Mercurial > hg > dml-open-vis
comparison src/DML/MainVisBundle/Resources/assets/marionette/App.90-routing.js @ 0:493bcb69166c
added public content
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 20:54:02 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:493bcb69166c |
---|---|
1 "use strict"; | |
2 | |
3 App.addInitializer(function(options){ | |
4 var _this = this; | |
5 | |
6 var popupsAreInstant = true; | |
7 var appRouter = new (Backbone.Router.extend({ | |
8 routes: { | |
9 "help": "navigateToHelp", | |
10 "help/:id": "navigateToHelp", | |
11 "": "navigateToDefault", | |
12 "*notFound": "notFound", | |
13 }, | |
14 | |
15 navigateToHelp: function(id){ | |
16 //App.logger.log("Navigating to help with material id: ", id); | |
17 App.HelpModule.show({materialId: id !== null ? id : "", instant: popupsAreInstant}); | |
18 }, | |
19 | |
20 navigateToDefault: function(id){ | |
21 //App.logger.log("Navigating to default"); | |
22 App.HelpModule.hide(); | |
23 }, | |
24 | |
25 notFound: function(context){ | |
26 App.logger.warn("Route not found", context); | |
27 } | |
28 }))(); | |
29 | |
30 App.HelpModule.on("show", function(options) { | |
31 var urlHash = "help"; | |
32 if (options.materialId) { | |
33 urlHash += "/" + options.materialId; | |
34 } | |
35 var needToReplace = Backbone.history.fragment.slice(0, 4) == "help"; | |
36 appRouter.navigate(urlHash, {"replace": needToReplace}); | |
37 }); | |
38 | |
39 App.HelpModule.on("hide", function(options) { | |
40 appRouter.navigate("/"); | |
41 }); | |
42 | |
43 Backbone.history.start({ | |
44 // "pushState": true, | |
45 // "root": "/chords" | |
46 }); | |
47 | |
48 popupsAreInstant: false; | |
49 }); |