Merge pull request #390 from mjaschen/feature/route-loader-keyboard-shortcut

Route Loader Keyboard Shortcut
This commit is contained in:
Norbert Renner 2021-03-25 09:16:50 +01:00 committed by GitHub
commit a066adc752
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 10 deletions

View file

@ -81,8 +81,10 @@
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)+O"
"nogosKey": "$t(keyboard.shift)+N"
}'
title="Load route"
>

View file

@ -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 (

View file

@ -15,6 +15,9 @@ BR.routeLoader = function (map, layersControl, routing, pois) {
simplifyTolerance: -1,
isTestMode: false,
simplifyLastKnownGood: 0.001,
shortcut: {
open: 79, // char code for 'O'; used in conjunction with 'shift'
},
},
setDialogDraggable: function (jqDlgHeader) {
@ -84,12 +87,14 @@ BR.routeLoader = function (map, layersControl, routing, pois) {
(this._bounds = undefined), (this._trackPoints = []);
this._currentGeoJSON = {};
this._options = {
ext: 'gpx',
showTrackLayer: true,
showPointAsPoi: true,
simplifyTolerance: -1,
isTestMode: false,
simplifyLastKnownGood: 0.001,
shortcut: {
open: 79, // char code for 'O'; used in conjunction with 'shift'
},
};
},
@ -224,6 +229,8 @@ BR.routeLoader = function (map, layersControl, routing, pois) {
}.bind(this)
);
L.DomEvent.addListener(document, 'keydown', this.keydownListener, this);
// dummy, no own representation, delegating to EasyButton
var dummy = L.DomUtil.create('div');
dummy.hidden = true;
@ -382,6 +389,16 @@ BR.routeLoader = function (map, layersControl, routing, pois) {
this.onBusyChanged(false);
},
keydownListener: function (e) {
if (
BR.Util.keyboardShortcutsAllowed(e) &&
e.keyCode === this._options.shortcut.open &&
true === e.shiftKey
) {
$('#navbarLoadEditTracks').click();
}
},
});
RouteLoader.include(L.Evented.prototype);

View file

@ -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();
}
},
});

View file

@ -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)",