Merge pull request #390 from mjaschen/feature/route-loader-keyboard-shortcut
Route Loader Keyboard Shortcut
This commit is contained in:
commit
a066adc752
5 changed files with 38 additions and 10 deletions
|
|
@ -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"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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)",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue