From d106552ad3ca3f1b8fed11fbef31e1ee63537304 Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Thu, 11 Jun 2020 18:00:00 +0000 Subject: [PATCH] Add shortcuts to load tracks and no-go areas Press 'O' or 'Shift+O' to open/load tracks or no-go areas respectively. --- index.html | 2 ++ js/plugin/TracksLoader.js | 17 ++++++++++++++++- locales/en.json | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 3ecb010..a456a1b 100644 --- a/index.html +++ b/index.html @@ -78,6 +78,8 @@ id="navbarLoadDropdown" aria-haspopup="true" aria-expanded="false" + data-i18n="[title]navbar.load.tooltip" + title="Load route" > Load diff --git a/js/plugin/TracksLoader.js b/js/plugin/TracksLoader.js index 440b60d..ab84422 100644 --- a/js/plugin/TracksLoader.js +++ b/js/plugin/TracksLoader.js @@ -22,7 +22,10 @@ BR.tracksLoader = function(map, layersControl, routing) { }, addToMap: false, // File size limit in kb (default: 1024) ? - fileSizeLimit: 1024 + fileSizeLimit: 1024, + shortcut: { + open: 79 // char code for 'o' + } }, _initContainer: function() { @@ -31,6 +34,8 @@ BR.tracksLoader = function(map, layersControl, routing) { var fileInput; var container = L.DomUtil.get('navbarLoadTracksContainer'); + L.DomEvent.addListener(document, 'keydown', this._keydownListener, this); + // Create an invisible file input fileInput = L.DomUtil.create('input', 'hidden', container); fileInput.type = 'file'; @@ -62,6 +67,16 @@ BR.tracksLoader = function(map, layersControl, routing) { var dummy = L.DomUtil.create('div'); dummy.hidden = true; return dummy; + }, + + _keydownListener: function(e) { + if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.open) { + if (e.shiftKey) { + $('#loadNogos').modal('show'); + } else { + $('#navbarLoadTracks')[0].click(); + } + } } }); var tracksLoaderControl = new TracksLoader(); diff --git a/locales/en.json b/locales/en.json index 8442805..cbffae6 100644 --- a/locales/en.json +++ b/locales/en.json @@ -149,6 +149,7 @@ "load": { "nogos": "No-go areas", "title": "Load", + "tooltip": "Load tracks (O key)\nLoad No-go areas (Shift+O)", "tracks": "Tracks" }, "profile": {