Add shortcut to export route

Press 'X' to trigger the export route dialog.

Automatically populating the trackname field should work too.
This commit is contained in:
Henrik Fehlauer 2020-06-10 18:00:00 +00:00
parent 6da520ed4d
commit a420ad5c0b
3 changed files with 22 additions and 0 deletions

View file

@ -61,6 +61,8 @@
role="button" role="button"
aria-haspopup="true" aria-haspopup="true"
aria-expanded="false" aria-expanded="false"
data-i18n="[title]navbar.export-tooltip"
title="Export route"
> >
<span class="fa fa-lg fa-cloud-download" aria-hidden="true"> </span> <span class="fa fa-lg fa-cloud-download" aria-hidden="true"> </span>
<span data-i18n="navbar.export">Export</span> <span data-i18n="navbar.export">Export</span>

View file

@ -1,6 +1,12 @@
BR.Export = L.Class.extend({ BR.Export = L.Class.extend({
latLngs: [], latLngs: [],
options: {
shortcut: {
export: 88 // char code for 'x'
}
},
initialize: function(router, pois) { initialize: function(router, pois) {
this.router = router; this.router = router;
this.pois = pois; this.pois = pois;
@ -20,6 +26,8 @@ BR.Export = L.Class.extend({
this.exportButton.on('click', L.bind(this._generateTrackname, this)); this.exportButton.on('click', L.bind(this._generateTrackname, this));
L.DomUtil.get('submitExport').onclick = L.bind(this._export, this); L.DomUtil.get('submitExport').onclick = L.bind(this._export, this);
L.DomEvent.addListener(document, 'keydown', this._keydownListener, this);
this.update([]); this.update([]);
}, },
@ -116,6 +124,17 @@ BR.Export = L.Class.extend({
} }
}) })
); );
},
_keydownListener: function(e) {
if (
BR.Util.keyboardShortcutsAllowed(e) &&
e.keyCode === this.options.shortcut.export &&
!this.exportButton.hasClass('disabled')
) {
this._generateTrackname();
$('#export').modal('show');
}
} }
}); });

View file

@ -145,6 +145,7 @@
"third": "3rd alternative" "third": "3rd alternative"
}, },
"export": "Export", "export": "Export",
"export-tooltip": "Export route (X key)",
"load": { "load": {
"nogos": "No-go areas", "nogos": "No-go areas",
"title": "Load", "title": "Load",