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='{
|
data-i18n-options='{
|
||||||
"tracksAction": "$t(navbar.load.tracks)",
|
"tracksAction": "$t(navbar.load.tracks)",
|
||||||
"tracksKey": "O",
|
"tracksKey": "O",
|
||||||
|
"trackAsRouteAction": "$t(trackasroute.title)",
|
||||||
|
"trackAsRouteKey": "$t(keyboard.shift)+O",
|
||||||
"nogosAction": "$t(navbar.load.nogos)",
|
"nogosAction": "$t(navbar.load.nogos)",
|
||||||
"nogosKey": "$t(keyboard.shift)+O"
|
"nogosKey": "$t(keyboard.shift)+N"
|
||||||
}'
|
}'
|
||||||
title="Load route"
|
title="Load route"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ BR.NogoAreas = L.Control.extend({
|
||||||
enable: 78, // char code for 'n'
|
enable: 78, // char code for 'n'
|
||||||
disable: 27, // char code for 'ESC'
|
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)) {
|
if (!BR.Util.keyboardShortcutsAllowed(e)) {
|
||||||
return;
|
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) {
|
if (e.keyCode === this.options.shortcut.draw.disable && this.button.state() === BR.NogoAreas.STATE_CANCEL) {
|
||||||
this.stopDrawing(this.button);
|
this.stopDrawing(this.button);
|
||||||
} else if (
|
} else if (
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ BR.routeLoader = function (map, layersControl, routing, pois) {
|
||||||
simplifyTolerance: -1,
|
simplifyTolerance: -1,
|
||||||
isTestMode: false,
|
isTestMode: false,
|
||||||
simplifyLastKnownGood: 0.001,
|
simplifyLastKnownGood: 0.001,
|
||||||
|
shortcut: {
|
||||||
|
open: 79, // char code for 'O'; used in conjunction with 'shift'
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
setDialogDraggable: function (jqDlgHeader) {
|
setDialogDraggable: function (jqDlgHeader) {
|
||||||
|
|
@ -84,12 +87,14 @@ BR.routeLoader = function (map, layersControl, routing, pois) {
|
||||||
(this._bounds = undefined), (this._trackPoints = []);
|
(this._bounds = undefined), (this._trackPoints = []);
|
||||||
this._currentGeoJSON = {};
|
this._currentGeoJSON = {};
|
||||||
this._options = {
|
this._options = {
|
||||||
ext: 'gpx',
|
|
||||||
showTrackLayer: true,
|
showTrackLayer: true,
|
||||||
showPointAsPoi: true,
|
showPointAsPoi: true,
|
||||||
simplifyTolerance: -1,
|
simplifyTolerance: -1,
|
||||||
isTestMode: false,
|
isTestMode: false,
|
||||||
simplifyLastKnownGood: 0.001,
|
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)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
L.DomEvent.addListener(document, 'keydown', this.keydownListener, this);
|
||||||
|
|
||||||
// dummy, no own representation, delegating to EasyButton
|
// dummy, no own representation, delegating to EasyButton
|
||||||
var dummy = L.DomUtil.create('div');
|
var dummy = L.DomUtil.create('div');
|
||||||
dummy.hidden = true;
|
dummy.hidden = true;
|
||||||
|
|
@ -382,6 +389,16 @@ BR.routeLoader = function (map, layersControl, routing, pois) {
|
||||||
|
|
||||||
this.onBusyChanged(false);
|
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);
|
RouteLoader.include(L.Evented.prototype);
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,12 @@ BR.tracksLoader = function (map, layersControl, routing, pois) {
|
||||||
},
|
},
|
||||||
|
|
||||||
_keydownListener: function (e) {
|
_keydownListener: function (e) {
|
||||||
if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.open) {
|
if (
|
||||||
if (e.shiftKey) {
|
BR.Util.keyboardShortcutsAllowed(e) &&
|
||||||
$('#loadNogos').modal('show');
|
e.keyCode === this.options.shortcut.open &&
|
||||||
} else {
|
false === e.shiftKey
|
||||||
$('#navbarLoadTracks')[0].click();
|
) {
|
||||||
}
|
$('#navbarLoadTracks')[0].click();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,9 @@
|
||||||
"load": {
|
"load": {
|
||||||
"nogos": "Load no-go areas",
|
"nogos": "Load no-go areas",
|
||||||
"title": "Load",
|
"title": "Load",
|
||||||
"tooltip": "{{tracksAction}} ({{tracksKey}} key)\n{{nogosAction}} ({{nogosKey}})",
|
"tooltip": "{{tracksAction}} ({{tracksKey}} key)\n{{trackAsRouteAction}} ({{trackAsRouteKey}})\n{{nogosAction}} ({{nogosKey}})",
|
||||||
"tracks": "Load tracks"
|
"tracks": "Load tracks",
|
||||||
|
"trackAsRoute": "Load Track as Route"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"car-eco": "Car (economic)",
|
"car-eco": "Car (economic)",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue