annotate src/DML/MainVisBundle/Resources/assets/marionette/App.50-keyboard-shortcuts.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 /* =========================================================================
Daniel@0 7 * Global key shortcuts
Daniel@0 8 */
Daniel@0 9 var $document = $(document);
Daniel@0 10
Daniel@0 11 var aPopupIsOpen = function() {
Daniel@0 12 return App.helpIsShowing();
Daniel@0 13 };
Daniel@0 14 var askToClosePopups = function() {
Daniel@0 15 };
Daniel@0 16
Daniel@0 17 $document.bind("keydown", "esc", function(event) {
Daniel@0 18 if (App.helpIsShowing()) {
Daniel@0 19 App.hideHelp();
Daniel@0 20 }
Daniel@0 21 });
Daniel@0 22 $document.bind("keydown", "h", function(event) {
Daniel@0 23 if (App.helpIsShowing()) {
Daniel@0 24 App.hideHelp();
Daniel@0 25 } else {
Daniel@0 26 App.showHelp();
Daniel@0 27 }
Daniel@0 28 });
Daniel@0 29 $document.bind("keydown", "f", function(event) {
Daniel@0 30 if (aPopupIsOpen()) {
Daniel@0 31 return false;
Daniel@0 32 }
Daniel@0 33 var state = App.context.get("state");
Daniel@0 34 state.set("musicRecordingsGridIsShown", !state.get("musicRecordingsGridIsShown"));
Daniel@0 35 });
Daniel@0 36
Daniel@0 37 $document.bind("keydown", App.keyboardMappings.ctrl + "+z", function(event) {
Daniel@0 38 if (aPopupIsOpen()) {
Daniel@0 39 askToClosePopups();
Daniel@0 40 return false;
Daniel@0 41 }
Daniel@0 42 App.undo();
Daniel@0 43 });
Daniel@0 44
Daniel@0 45 $document.bind("keydown", App.keyboardMappings.ctrlShift + "+z", function(event) {
Daniel@0 46 if (aPopupIsOpen()) {
Daniel@0 47 askToClosePopups();
Daniel@0 48 return false;
Daniel@0 49 }
Daniel@0 50 App.redo();
Daniel@0 51 });
Daniel@0 52
Daniel@0 53 var moveConfig = function(dimension, offset) {
Daniel@0 54 var state = App.context.get("state");
Daniel@0 55 var configGrid = state.get(state.get("musicRecordingsGridIsShown") ? "musicRecordingGrid" : "musicCollectionGrid");
Daniel@0 56 var configs = null;
Daniel@0 57 if (dimension == "entity") {
Daniel@0 58 configs = configGrid.get("entityConfigs");
Daniel@0 59 var selectedConfig = configGrid.getSelectedEntityConfig();
Daniel@0 60 if (selectedConfig) {
Daniel@0 61 var configToInsertBefore;
Daniel@0 62 if (offset == 1) {
Daniel@0 63 configToInsertBefore = configGrid.getNextEntityNeighbour(selectedConfig);
Daniel@0 64 if (configToInsertBefore) {
Daniel@0 65 configToInsertBefore = configGrid.getNextEntityNeighbour(configToInsertBefore);
Daniel@0 66 }
Daniel@0 67 } else {
Daniel@0 68 configToInsertBefore = configGrid.getPrevEntityNeighbour(selectedConfig);
Daniel@0 69 if (!configToInsertBefore) {
Daniel@0 70 return;
Daniel@0 71 }
Daniel@0 72 }
Daniel@0 73 configGrid.relocateEntityConfig(selectedConfig, configToInsertBefore ? configToInsertBefore : null);
Daniel@0 74 }
Daniel@0 75 } else {
Daniel@0 76 configs = configGrid.get("viewConfigs");
Daniel@0 77 var selectedConfig = configGrid.getSelectedViewConfig();
Daniel@0 78 if (selectedConfig) {
Daniel@0 79 var configToInsertBefore;
Daniel@0 80 if (offset == 1) {
Daniel@0 81 configToInsertBefore = configGrid.getNextViewNeighbour(selectedConfig);
Daniel@0 82 if (configToInsertBefore) {
Daniel@0 83 configToInsertBefore = configGrid.getNextViewNeighbour(configToInsertBefore);
Daniel@0 84 }
Daniel@0 85 } else {
Daniel@0 86 configToInsertBefore = configGrid.getPrevViewNeighbour(selectedConfig);
Daniel@0 87 if (!configToInsertBefore) {
Daniel@0 88 return;
Daniel@0 89 }
Daniel@0 90 }
Daniel@0 91 configGrid.relocateViewConfig(selectedConfig, configToInsertBefore ? configToInsertBefore : null);
Daniel@0 92 }
Daniel@0 93 }
Daniel@0 94 };
Daniel@0 95
Daniel@0 96 $document.bind("keydown", "alt+left", function(event) {
Daniel@0 97 if (aPopupIsOpen()) {
Daniel@0 98 askToClosePopups();
Daniel@0 99 return false;
Daniel@0 100 }
Daniel@0 101 moveConfig("entity", -1);
Daniel@0 102 event.preventDefault();
Daniel@0 103 return false;
Daniel@0 104 });
Daniel@0 105
Daniel@0 106 $document.bind("keydown", "alt+right", function(event) {
Daniel@0 107 if (aPopupIsOpen()) {
Daniel@0 108 askToClosePopups();
Daniel@0 109 return false;
Daniel@0 110 }
Daniel@0 111 moveConfig("entity", 1);
Daniel@0 112 event.preventDefault();
Daniel@0 113 return false;
Daniel@0 114 });
Daniel@0 115
Daniel@0 116 $document.bind("keydown", "alt+up", function(event) {
Daniel@0 117 if (aPopupIsOpen()) {
Daniel@0 118 askToClosePopups();
Daniel@0 119 return false;
Daniel@0 120 }
Daniel@0 121 moveConfig("view", -1);
Daniel@0 122 event.preventDefault();
Daniel@0 123 return false;
Daniel@0 124 });
Daniel@0 125 $document.bind("keydown", "alt+down", function(event) {
Daniel@0 126 if (aPopupIsOpen()) {
Daniel@0 127 askToClosePopups();
Daniel@0 128 return false;
Daniel@0 129 }
Daniel@0 130 moveConfig("view", 1);
Daniel@0 131 event.preventDefault();
Daniel@0 132 return false;
Daniel@0 133 });
Daniel@0 134
Daniel@0 135 });