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:
parent
29530919b5
commit
e4e1c8a19e
2 changed files with 53 additions and 36 deletions
88
js/index.js
88
js/index.js
|
|
@ -92,45 +92,61 @@
|
|||
deleteRouteButton = L.easyButton(
|
||||
'fa-trash-o',
|
||||
function() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
clearRoute();
|
||||
},
|
||||
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) {
|
||||
router.setOptions(evt.options);
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@
|
|||
"attribution-osm-long": "OpenStreetMap contributors",
|
||||
"attribution-osm-short": "OpenStreetMap",
|
||||
"clear-route": "Clear route data",
|
||||
"clear-route-tooltip": "Clear route data (Backspace key)",
|
||||
"copyright": "Copyright",
|
||||
"cycling": "Cycling",
|
||||
"delete-last-point": "Delete last point (Z key)",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue