Mercurial > hg > dml-open-vis
comparison src/DML/MainVisBundle/Resources/assets/marionette/App.20-modules+context+views.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 App.addInitializer(function(options){ | |
3 if (window.location.href.indexOf("reset") > 0) { | |
4 localStorage.clear(); | |
5 console.log("reset"); | |
6 } | |
7 | |
8 if (navigator.appVersion.indexOf("Mac") > 0) { | |
9 App.keyboardMappings = { | |
10 ctrl: "meta", | |
11 ctrlTitle: "cmd", | |
12 ctrlShift: "shift+meta", | |
13 ctrlShiftTitle: "cmd+shift", | |
14 }; | |
15 } else { | |
16 App.keyboardMappings = { | |
17 ctrl: "ctrl", | |
18 ctrlTitle: "ctrl", | |
19 ctrlShift: "ctrl+shift", | |
20 ctrlShiftTitle: "ctrl+shift", | |
21 }; | |
22 } | |
23 | |
24 App.DataModule.start(); | |
25 | |
26 | |
27 // pre-configuring | |
28 App.options.debugAPI = !!App.DataModule.Storage.getStrCache(null, "debug-api"); | |
29 App.options.defaultEntityWidth = 400; | |
30 | |
31 App.DataModule.CliopatriaAPI.start({ | |
32 apiRootPaths: options.musicLibrary.apiRootPaths, | |
33 apiVersion: options.musicLibrary.apiVersion, | |
34 dataVersion: options.musicLibrary.dataVersion, | |
35 dataCaching: options.musicLibrary.dataCaching | |
36 }); | |
37 | |
38 App.NotificationsModule.start(); | |
39 App.ContextModule.start(); | |
40 App.RepresentationModule.start(); | |
41 App.MainRegionModule.start(); | |
42 App.TooltipModule.start(); | |
43 | |
44 App.HelpModule.start(); | |
45 | |
46 // Define context and context manager | |
47 App.contextManager = new App.ContextModule.AppContextManager(); | |
48 App.context = new App.ContextModule.AppContext(); | |
49 | |
50 try { | |
51 App.contextManager.restoreFromStorage(App.context, ""); | |
52 } catch (e) { | |
53 App.contextManager.restoreDefault(""); | |
54 } | |
55 App.dynamicDefinitionProviderForCollections = new App.DataModule.DynamicDefinitionProviderForCollections(); | |
56 App.dynamicDefinitionProviderForRecordings = new App.DataModule.DymanicDefinitionProviderForRecordings(); | |
57 App.dynamicDerivedConfigDataProvider = new App.RepresentationModule.DynanicDerivedConfigDataProvider({ | |
58 configGridsByType: { | |
59 "collection": App.context.get("state").get("musicCollectionGrid"), | |
60 "recording": App.context.get("state").get("musicRecordingGrid") | |
61 } | |
62 }); | |
63 | |
64 App.PlayerModule.start(); | |
65 | |
66 var saveContextToStorage = function() { | |
67 App.contextManager.saveToStorage(App.context); | |
68 }; | |
69 | |
70 var throttledSaveAppContextToStorage = _.throttle(saveContextToStorage, 10000, {leading: false}); | |
71 | |
72 App.context.bind("change", throttledSaveAppContextToStorage); | |
73 | |
74 $(window).on("beforeunload", saveContextToStorage); | |
75 | |
76 | |
77 // Initialize main region | |
78 App.mainRegionView = new App.MainRegionModule.MainRegionView({state: App.context.get("state"), el: ".app__main-region"}); | |
79 | |
80 // Init main menu | |
81 App.MainMenuModule.start(); | |
82 | |
83 App.TooltipModule.convertTitlesToTooltips($("body")); | |
84 }); |