From d1285baa691fa5b091843ead23d725065de855c9 Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Thu, 25 Mar 2021 07:58:51 +0100 Subject: [PATCH] change keyboard shortcuts; update tooltips - "Load Track as Route" is now triggered by pressing `Shift-O` - "Load No-Go-Areas" is now triggered by pressing `Shift-N` - tooltip for navbar link is updated an ready for translation --- index.html | 14 ++++++++------ js/plugin/NogoAreas.js | 8 ++++++++ js/plugin/RouteLoaderConverter.js | 10 +++++++--- js/plugin/TracksLoader.js | 12 ++++++------ locales/en.json | 5 +++-- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index 6e32d90..c7e9ea5 100644 --- a/index.html +++ b/index.html @@ -78,12 +78,14 @@ aria-haspopup="true" aria-expanded="false" data-i18n="[title]navbar.load.tooltip" - data-i18n-options="{ - 'tracksAction': '$t(navbar.load.tracks)', - 'tracksKey': 'O', - 'nogosAction': '$t(navbar.load.nogos)', - 'nogosKey': '$t(keyboard.shift)+O' - }" + data-i18n-options='{ + "tracksAction": "$t(navbar.load.tracks)", + "tracksKey": "O", + "trackAsRouteAction": "$t(trackasroute.title)", + "trackAsRouteKey": "$t(keyboard.shift)+O", + "nogosAction": "$t(navbar.load.nogos)", + "nogosKey": "$t(keyboard.shift)+N" + }' title="Load route" > diff --git a/js/plugin/NogoAreas.js b/js/plugin/NogoAreas.js index db50761..af3dac1 100644 --- a/js/plugin/NogoAreas.js +++ b/js/plugin/NogoAreas.js @@ -5,6 +5,7 @@ BR.NogoAreas = L.Control.extend({ enable: 78, // char code for 'n' disable: 27, // char code for 'ESC' }, + import: 78, // char code for 'n'; used in conjunction with 'shift' }, }, @@ -147,6 +148,13 @@ BR.NogoAreas = L.Control.extend({ if (!BR.Util.keyboardShortcutsAllowed(e)) { return; } + + if (true === e.shiftKey && e.keyCode === this.options.shortcut.import) { + $('#loadNogos').modal('show'); + + return; + } + if (e.keyCode === this.options.shortcut.draw.disable && this.button.state() === BR.NogoAreas.STATE_CANCEL) { this.stopDrawing(this.button); } else if ( diff --git a/js/plugin/RouteLoaderConverter.js b/js/plugin/RouteLoaderConverter.js index 0343bc4..d719853 100644 --- a/js/plugin/RouteLoaderConverter.js +++ b/js/plugin/RouteLoaderConverter.js @@ -16,7 +16,7 @@ BR.routeLoader = function (map, layersControl, routing, pois) { isTestMode: false, simplifyLastKnownGood: 0.001, shortcut: { - open: 82, // char code for 'r' + open: 79, // char code for 'O'; used in conjunction with 'shift' }, }, @@ -93,7 +93,7 @@ BR.routeLoader = function (map, layersControl, routing, pois) { isTestMode: false, simplifyLastKnownGood: 0.001, shortcut: { - open: 82, // char code for 'r' + open: 79, // char code for 'O'; used in conjunction with 'shift' }, }; }, @@ -391,7 +391,11 @@ BR.routeLoader = function (map, layersControl, routing, pois) { }, keydownListener: function (e) { - if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this._options.shortcut.open) { + if ( + BR.Util.keyboardShortcutsAllowed(e) && + e.keyCode === this._options.shortcut.open && + true === e.shiftKey + ) { $('#navbarLoadEditTracks').click(); } }, diff --git a/js/plugin/TracksLoader.js b/js/plugin/TracksLoader.js index 9f53401..f2c437a 100644 --- a/js/plugin/TracksLoader.js +++ b/js/plugin/TracksLoader.js @@ -61,12 +61,12 @@ BR.tracksLoader = function (map, layersControl, routing, pois) { }, _keydownListener: function (e) { - if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.open) { - if (e.shiftKey) { - $('#loadNogos').modal('show'); - } else { - $('#navbarLoadTracks')[0].click(); - } + if ( + BR.Util.keyboardShortcutsAllowed(e) && + e.keyCode === this.options.shortcut.open && + false === e.shiftKey + ) { + $('#navbarLoadTracks')[0].click(); } }, }); diff --git a/locales/en.json b/locales/en.json index 685703b..5a0ec02 100644 --- a/locales/en.json +++ b/locales/en.json @@ -174,8 +174,9 @@ "load": { "nogos": "Load no-go areas", "title": "Load", - "tooltip": "{{tracksAction}} ({{tracksKey}} key)\n{{nogosAction}} ({{nogosKey}})", - "tracks": "Load tracks" + "tooltip": "{{tracksAction}} ({{tracksKey}} key)\n{{trackAsRouteAction}} ({{trackAsRouteKey}})\n{{nogosAction}} ({{nogosKey}})", + "tracks": "Load tracks", + "trackAsRoute": "Load Track as Route" }, "profile": { "car-eco": "Car (economic)",