Allow to mute route

This commit is contained in:
Stefan Siegl 2020-06-06 21:47:58 +02:00
parent 32d4a26dfd
commit 64202a451c
No known key found for this signature in database
GPG key ID: 73942AF5642F3DDA
2 changed files with 28 additions and 0 deletions

View file

@ -44,6 +44,33 @@ BR.OpacitySlider = L.Class.extend({
this.getElement().title = this.options.title;
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() {