annotate src/DML/MainVisBundle/Resources/assets/marionette/App.90-routing.js @ 1:f38015048f48 tip

Added GPL
author Daniel Wolff
date Sat, 13 Feb 2016 20:43:38 +0100
parents 493bcb69166c
children
rev   line source
Daniel@0 1 "use strict";
Daniel@0 2
Daniel@0 3 App.addInitializer(function(options){
Daniel@0 4 var _this = this;
Daniel@0 5
Daniel@0 6 var popupsAreInstant = true;
Daniel@0 7 var appRouter = new (Backbone.Router.extend({
Daniel@0 8 routes: {
Daniel@0 9 "help": "navigateToHelp",
Daniel@0 10 "help/:id": "navigateToHelp",
Daniel@0 11 "": "navigateToDefault",
Daniel@0 12 "*notFound": "notFound",
Daniel@0 13 },
Daniel@0 14
Daniel@0 15 navigateToHelp: function(id){
Daniel@0 16 //App.logger.log("Navigating to help with material id: ", id);
Daniel@0 17 App.HelpModule.show({materialId: id !== null ? id : "", instant: popupsAreInstant});
Daniel@0 18 },
Daniel@0 19
Daniel@0 20 navigateToDefault: function(id){
Daniel@0 21 //App.logger.log("Navigating to default");
Daniel@0 22 App.HelpModule.hide();
Daniel@0 23 },
Daniel@0 24
Daniel@0 25 notFound: function(context){
Daniel@0 26 App.logger.warn("Route not found", context);
Daniel@0 27 }
Daniel@0 28 }))();
Daniel@0 29
Daniel@0 30 App.HelpModule.on("show", function(options) {
Daniel@0 31 var urlHash = "help";
Daniel@0 32 if (options.materialId) {
Daniel@0 33 urlHash += "/" + options.materialId;
Daniel@0 34 }
Daniel@0 35 var needToReplace = Backbone.history.fragment.slice(0, 4) == "help";
Daniel@0 36 appRouter.navigate(urlHash, {"replace": needToReplace});
Daniel@0 37 });
Daniel@0 38
Daniel@0 39 App.HelpModule.on("hide", function(options) {
Daniel@0 40 appRouter.navigate("/");
Daniel@0 41 });
Daniel@0 42
Daniel@0 43 Backbone.history.start({
Daniel@0 44 // "pushState": true,
Daniel@0 45 // "root": "/chords"
Daniel@0 46 });
Daniel@0 47
Daniel@0 48 popupsAreInstant: false;
Daniel@0 49 });