mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added: addEventsListener() and addEventsListeners()
This commit is contained in:
parent
c270f0ad9a
commit
5990addfef
14 changed files with 484 additions and 464 deletions
|
|
@ -4,6 +4,7 @@ import { Scope } from 'Common/Enums';
|
|||
let keyScopeFake = Scope.All;
|
||||
|
||||
export const
|
||||
ScopeMenu = 'Menu',
|
||||
|
||||
doc = document,
|
||||
|
||||
|
|
@ -31,14 +32,20 @@ export const
|
|||
|
||||
fireEvent = (name, detail) => dispatchEvent(new CustomEvent(name, {detail:detail})),
|
||||
|
||||
addEventsListener = (element, events, fn, options) =>
|
||||
events.forEach(event => element.addEventListener(event, fn, options)),
|
||||
|
||||
addEventsListeners = (element, events) =>
|
||||
Object.entries(events).forEach(([event, fn]) => element.addEventListener(event, fn)),
|
||||
|
||||
// keys
|
||||
keyScopeReal = ko.observable(Scope.All),
|
||||
keyScope = value => {
|
||||
if (value) {
|
||||
if (Scope.Menu !== value) {
|
||||
if (ScopeMenu !== value) {
|
||||
keyScopeFake = value;
|
||||
if (dropdownVisibility()) {
|
||||
value = Scope.Menu;
|
||||
value = ScopeMenu;
|
||||
}
|
||||
}
|
||||
keyScopeReal(value);
|
||||
|
|
@ -50,8 +57,8 @@ export const
|
|||
|
||||
dropdownVisibility.subscribe(value => {
|
||||
if (value) {
|
||||
keyScope(Scope.Menu);
|
||||
} else if (Scope.Menu === shortcuts.getScope()) {
|
||||
keyScope(ScopeMenu);
|
||||
} else if (ScopeMenu === shortcuts.getScope()) {
|
||||
keyScope(keyScopeFake);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue