mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Cleanup Dropdowns handling
This commit is contained in:
parent
ffcd9990eb
commit
04f4538700
5 changed files with 14 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import 'External/User/ko';
|
||||
|
||||
import { isArray, pString } from 'Common/Utils';
|
||||
import { mailToHelper, setLayoutResizer } from 'Common/UtilsUser';
|
||||
import { mailToHelper, setLayoutResizer, dropdownsDetectVisibility } from 'Common/UtilsUser';
|
||||
|
||||
import {
|
||||
FolderType,
|
||||
|
|
@ -88,7 +88,8 @@ class AppUser extends AbstractApp {
|
|||
const fn = (ev=>$htmlCL.toggle('rl-ctrl-key-pressed', ev.ctrlKey)).debounce(500);
|
||||
addEventsListener(doc, ['keydown','keyup'], fn);
|
||||
|
||||
shortcuts.add('escape,enter', '', () => rl.Dropdowns.detectVisibility());
|
||||
shortcuts.add('escape,enter', '', dropdownsDetectVisibility);
|
||||
addEventListener('click', dropdownsDetectVisibility);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export const
|
|||
SettingsGet = Settings.get,
|
||||
SettingsCapa = Settings.capa,
|
||||
|
||||
dropdowns = [],
|
||||
dropdownVisibility = ko.observable(false).extend({ rateLimit: 0 }),
|
||||
|
||||
moveAction = ko.observable(false),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { MessageFlagsCache, addRequestedMessage } from 'Common/Cache';
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { MessageSetAction, ComposeType/*, FolderType*/ } from 'Common/EnumsUser';
|
||||
import { doc, createElement, elementById } from 'Common/Globals';
|
||||
import { doc, createElement, elementById, dropdowns, dropdownVisibility } from 'Common/Globals';
|
||||
import { plainToHtml } from 'Common/Html';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
import { EmailModel } from 'Model/Email';
|
||||
|
|
@ -15,6 +15,10 @@ import Remote from 'Remote/User/Fetch';
|
|||
|
||||
export const
|
||||
|
||||
dropdownsDetectVisibility = (() =>
|
||||
dropdownVisibility(!!dropdowns.find(item => item.classList.contains('show')))
|
||||
).debounce(50),
|
||||
|
||||
/**
|
||||
* @param {string} link
|
||||
* @returns {boolean}
|
||||
|
|
|
|||
7
dev/External/User/ko.js
vendored
7
dev/External/User/ko.js
vendored
|
|
@ -2,8 +2,9 @@ import 'External/ko';
|
|||
import ko from 'ko';
|
||||
import { HtmlEditor } from 'Common/Html';
|
||||
import { timeToNode } from 'Common/Translator';
|
||||
import { elementById, addEventsListeners } from 'Common/Globals';
|
||||
import { elementById, addEventsListeners, dropdowns } from 'Common/Globals';
|
||||
import { isArray } from 'Common/Utils';
|
||||
import { dropdownsDetectVisibility } from 'Common/UtilsUser';
|
||||
import { EmailAddressesComponent } from 'Component/EmailAddresses';
|
||||
import { ThemeStore } from 'Stores/Theme';
|
||||
import { moveMessagesToFolder } from 'Common/Folders';
|
||||
|
|
@ -231,7 +232,7 @@ Object.assign(ko.bindingHandlers, {
|
|||
|
||||
registerBootstrapDropdown: {
|
||||
init: element => {
|
||||
rl.Dropdowns.register(element);
|
||||
dropdowns.push(element);
|
||||
element.ddBtn = new BSN.Dropdown(element.querySelector('.dropdown-toggle'));
|
||||
}
|
||||
},
|
||||
|
|
@ -243,7 +244,7 @@ Object.assign(ko.bindingHandlers, {
|
|||
el.open || el.toggle();
|
||||
// el.focus();
|
||||
|
||||
rl.Dropdowns.detectVisibility();
|
||||
dropdownsDetectVisibility();
|
||||
fValueAccessor()(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
9
dev/bootstrap.js
vendored
9
dev/bootstrap.js
vendored
|
|
@ -1,4 +1,4 @@
|
|||
import { dropdownVisibility, Settings } from 'Common/Globals';
|
||||
import { Settings } from 'Common/Globals';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
import { root } from 'Common/Links';
|
||||
|
|
@ -18,13 +18,6 @@ export default App => {
|
|||
}
|
||||
};
|
||||
|
||||
rl.Dropdowns = [];
|
||||
rl.Dropdowns.register = function(element) { this.push(element); };
|
||||
rl.Dropdowns.detectVisibility = (() =>
|
||||
dropdownVisibility(!!rl.Dropdowns.find(item => item.classList.contains('show')))
|
||||
).debounce(50);
|
||||
addEventListener('click', ()=>rl.Dropdowns.detectVisibility());
|
||||
|
||||
rl.route = {
|
||||
root: () => {
|
||||
rl.route.off();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue