Add shortcut to toggle elevation chart
Press 'E' to show/hide the elevation chart.
This commit is contained in:
parent
844a9038ee
commit
b8b1e436e6
3 changed files with 15 additions and 1 deletions
|
|
@ -910,6 +910,8 @@
|
||||||
id="elevation-btn"
|
id="elevation-btn"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
aria-label="Toggle elevation chart"
|
aria-label="Toggle elevation chart"
|
||||||
|
data-i18n="[title]footer.elevation-chart"
|
||||||
|
title="Toggle elevation chart"
|
||||||
>
|
>
|
||||||
<span class="fa fa-area-chart"></span>
|
<span class="fa fa-area-chart"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,10 @@ BR.Elevation = L.Control.Elevation.extend({
|
||||||
bottom: 30,
|
bottom: 30,
|
||||||
left: 60
|
left: 60
|
||||||
},
|
},
|
||||||
theme: 'steelblue-theme'
|
theme: 'steelblue-theme',
|
||||||
|
shortcut: {
|
||||||
|
toggle: 69 // char code for 'e'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onAdd: function(map) {
|
onAdd: function(map) {
|
||||||
|
|
@ -30,6 +33,8 @@ BR.Elevation = L.Control.Elevation.extend({
|
||||||
L.DomEvent.on(this._container, 'mouseup', this._dragEndHandler, this);
|
L.DomEvent.on(this._container, 'mouseup', this._dragEndHandler, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
L.DomEvent.addListener(document, 'keydown', this._keydownListener, this);
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -64,5 +69,11 @@ BR.Elevation = L.Control.Elevation.extend({
|
||||||
|
|
||||||
layer.on('mouseout', this._hidePositionMarker.bind(this));
|
layer.on('mouseout', this._hidePositionMarker.bind(this));
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_keydownListener: function(e) {
|
||||||
|
if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.toggle) {
|
||||||
|
$('#elevation-btn').click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
"ascend": "Ascend",
|
"ascend": "Ascend",
|
||||||
"cost": "Cost",
|
"cost": "Cost",
|
||||||
"distance": "Distance",
|
"distance": "Distance",
|
||||||
|
"elevation-chart": "Toggle elevation chart (E key)",
|
||||||
"energy-per-100km": "Energy per 100 km",
|
"energy-per-100km": "Energy per 100 km",
|
||||||
"hours": "hours",
|
"hours": "hours",
|
||||||
"hours-abbrev": "h",
|
"hours-abbrev": "h",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue