Allow to mute route
This commit is contained in:
parent
32d4a26dfd
commit
64202a451c
2 changed files with 28 additions and 0 deletions
|
|
@ -44,6 +44,33 @@ BR.OpacitySlider = L.Class.extend({
|
||||||
this.getElement().title = this.options.title;
|
this.getElement().title = this.options.title;
|
||||||
|
|
||||||
this.options.callback(value / 100);
|
this.options.callback(value / 100);
|
||||||
|
|
||||||
|
if (this.options.muteKeyCode) {
|
||||||
|
L.DomEvent.addListener(document, 'keydown', this._keydownListener, this);
|
||||||
|
L.DomEvent.addListener(document, 'keyup', this._keyupListener, this);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_keydownListener: function(e) {
|
||||||
|
// Suppress shortcut handling when a text input field is focussed
|
||||||
|
if (document.activeElement.type == 'text' || document.activeElement.type == 'textarea') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.keyCode === this.options.muteKeyCode && !e.repeat) {
|
||||||
|
this.options.callback(0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_keyupListener: function(e) {
|
||||||
|
// Suppress shortcut handling when a text input field is focussed
|
||||||
|
if (document.activeElement.type == 'text' || document.activeElement.type == 'textarea') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.keyCode === this.options.muteKeyCode && !e.repeat) {
|
||||||
|
this.options.callback(this.input.val() / 100);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getElement: function() {
|
getElement: function() {
|
||||||
|
|
|
||||||
|
|
@ -284,6 +284,7 @@
|
||||||
new BR.OpacitySliderControl({
|
new BR.OpacitySliderControl({
|
||||||
id: 'route',
|
id: 'route',
|
||||||
title: i18next.t('map.opacity-slider'),
|
title: i18next.t('map.opacity-slider'),
|
||||||
|
muteKeyCode: 77, // m
|
||||||
callback: L.bind(routing.setOpacity, routing)
|
callback: L.bind(routing.setOpacity, routing)
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue