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