Add shortcut for clear route dialog

Use 'Backspace' to show the dialog allowing to clear the route.

The 'Del' key could then be used in the future to possibly allow to
delete individual selected items like POIs or no-go areas.
This commit is contained in:
Henrik Fehlauer 2020-06-07 18:00:00 +00:00
parent 29530919b5
commit e4e1c8a19e
2 changed files with 53 additions and 36 deletions

View file

@ -92,45 +92,61 @@
deleteRouteButton = L.easyButton( deleteRouteButton = L.easyButton(
'fa-trash-o', 'fa-trash-o',
function() { function() {
bootbox.prompt({ clearRoute();
size: 'small',
title: i18next.t('map.clear-route'),
inputType: 'checkbox',
inputOptions: [
{
text: i18next.t('map.delete-route'),
value: 'route'
},
{
text: i18next.t('map.delete-nogo-areas'),
value: 'nogo'
},
{
text: i18next.t('map.delete-pois'),
value: 'pois'
}
],
value: ['route'],
callback: function(result) {
if (result !== null) {
if (result.indexOf('route') !== -1) {
routing.clear();
}
if (result.indexOf('nogo') !== -1) {
nogos.clear();
}
if (result.indexOf('pois') !== -1) {
pois.clear();
}
onUpdate();
urlHash.onMapMove();
}
}
});
}, },
i18next.t('map.clear-route') i18next.t('map.clear-route-tooltip')
); );
L.DomEvent.addListener(
document,
'keydown',
function(e) {
if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === 8 && !$('.modal.show').length) {
// char code for 'backspace'
clearRoute();
}
},
this
);
function clearRoute() {
bootbox.prompt({
size: 'small',
title: i18next.t('map.clear-route'),
inputType: 'checkbox',
inputOptions: [
{
text: i18next.t('map.delete-route'),
value: 'route'
},
{
text: i18next.t('map.delete-nogo-areas'),
value: 'nogo'
},
{
text: i18next.t('map.delete-pois'),
value: 'pois'
}
],
value: ['route'],
callback: function(result) {
if (result !== null) {
if (result.indexOf('route') !== -1) {
routing.clear();
}
if (result.indexOf('nogo') !== -1) {
nogos.clear();
}
if (result.indexOf('pois') !== -1) {
pois.clear();
}
onUpdate();
urlHash.onMapMove();
}
}
});
}
function updateRoute(evt) { function updateRoute(evt) {
router.setOptions(evt.options); router.setOptions(evt.options);

View file

@ -80,6 +80,7 @@
"attribution-osm-long": "OpenStreetMap contributors", "attribution-osm-long": "OpenStreetMap contributors",
"attribution-osm-short": "OpenStreetMap", "attribution-osm-short": "OpenStreetMap",
"clear-route": "Clear route data", "clear-route": "Clear route data",
"clear-route-tooltip": "Clear route data (Backspace key)",
"copyright": "Copyright", "copyright": "Copyright",
"cycling": "Cycling", "cycling": "Cycling",
"delete-last-point": "Delete last point (Z key)", "delete-last-point": "Delete last point (Z key)",