mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Revamp aBootstrapDropdowns
This commit is contained in:
parent
8846c453b1
commit
31bb7267ec
4 changed files with 16 additions and 23 deletions
|
|
@ -7,7 +7,7 @@ import {
|
||||||
bMobileDevice
|
bMobileDevice
|
||||||
} from 'Common/Globals';
|
} from 'Common/Globals';
|
||||||
|
|
||||||
import { pString, detectDropdownVisibility } from 'Common/Utils';
|
import { pString } from 'Common/Utils';
|
||||||
|
|
||||||
import { KeyState } from 'Common/Enums';
|
import { KeyState } from 'Common/Enums';
|
||||||
import { root, rootAdmin, rootUser, populateAuthSuffix } from 'Common/Links';
|
import { root, rootAdmin, rootUser, populateAuthSuffix } from 'Common/Links';
|
||||||
|
|
@ -48,9 +48,7 @@ class AbstractApp extends AbstractBoot {
|
||||||
$doc.addEventListener('keypress', fn);
|
$doc.addEventListener('keypress', fn);
|
||||||
$doc.addEventListener('click', fn);
|
$doc.addEventListener('click', fn);
|
||||||
|
|
||||||
key('esc, enter', KeyState.All, () => {
|
key('esc, enter', KeyState.All, () => rl.Dropdowns.detectVisibility());
|
||||||
detectDropdownVisibility();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remote() {
|
remote() {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { dropdownVisibility, data as GlobalsData } from 'Common/Globals';
|
|
||||||
import { ComposeType, SaveSettingsStep, FolderType } from 'Common/Enums';
|
import { ComposeType, SaveSettingsStep, FolderType } from 'Common/Enums';
|
||||||
import { Mime } from 'Common/Mime';
|
import { Mime } from 'Common/Mime';
|
||||||
|
|
||||||
|
|
@ -767,10 +766,6 @@ export function selectElement(element) {
|
||||||
sel.addRange(range);
|
sel.addRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const detectDropdownVisibility = (()=>
|
|
||||||
dropdownVisibility(!!GlobalsData.aBootstrapDropdowns.find(item => item.hasClass('open')))
|
|
||||||
).debounce(50);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean=} delay = false
|
* @param {boolean=} delay = false
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
10
dev/External/ko.js
vendored
10
dev/External/ko.js
vendored
|
|
@ -91,13 +91,7 @@ ko.bindingHandlers.tooltipErrorTip = {
|
||||||
};
|
};
|
||||||
|
|
||||||
ko.bindingHandlers.registrateBootstrapDropdown = {
|
ko.bindingHandlers.registrateBootstrapDropdown = {
|
||||||
init: (element) => {
|
init: element => rl.Dropdowns.registrate(element)
|
||||||
const Globals = require('Common/Globals');
|
|
||||||
if (Globals && Globals.data.aBootstrapDropdowns) {
|
|
||||||
Globals.data.aBootstrapDropdowns.push($(element));
|
|
||||||
element.addEventListener('click', () => require('Common/Utils').detectDropdownVisibility());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ko.bindingHandlers.openDropdownTrigger = {
|
ko.bindingHandlers.openDropdownTrigger = {
|
||||||
|
|
@ -110,7 +104,7 @@ ko.bindingHandlers.openDropdownTrigger = {
|
||||||
|
|
||||||
t.focus();
|
t.focus();
|
||||||
|
|
||||||
require('Common/Utils').detectDropdownVisibility();
|
rl.Dropdowns.detectVisibility();
|
||||||
fValueAccessor()(false);
|
fValueAccessor()(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
dev/bootstrap.js
vendored
18
dev/bootstrap.js
vendored
|
|
@ -1,5 +1,4 @@
|
||||||
import { detectDropdownVisibility } from 'Common/Utils';
|
import { $html, $htmlCL, data as GlobalsData, bMobileDevice, dropdownVisibility } from 'Common/Globals';
|
||||||
import { $html, $htmlCL, data as GlobalsData, bMobileDevice } from 'Common/Globals';
|
|
||||||
import * as Enums from 'Common/Enums';
|
import * as Enums from 'Common/Enums';
|
||||||
import * as Plugins from 'Common/Plugins';
|
import * as Plugins from 'Common/Plugins';
|
||||||
import { i18n } from 'Common/Translator';
|
import { i18n } from 'Common/Translator';
|
||||||
|
|
@ -30,12 +29,10 @@ export default (App) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addEventListener('unload', () => {
|
addEventListener('unload', () => GlobalsData.bUnload = true);
|
||||||
GlobalsData.bUnload = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
$htmlCL.add(bMobileDevice ? 'mobile' : 'no-mobile');
|
$htmlCL.add(bMobileDevice ? 'mobile' : 'no-mobile');
|
||||||
$html.on('click.dropdown.data-api', detectDropdownVisibility);
|
$html.on('click.dropdown.data-api', ()=>rl.Dropdowns.detectVisibility());
|
||||||
|
|
||||||
const rl = window.rl || {};
|
const rl = window.rl || {};
|
||||||
|
|
||||||
|
|
@ -51,6 +48,15 @@ export default (App) => {
|
||||||
rl.EmailModel = EmailModel;
|
rl.EmailModel = EmailModel;
|
||||||
rl.Enums = Enums;
|
rl.Enums = Enums;
|
||||||
|
|
||||||
|
rl.Dropdowns = [];
|
||||||
|
rl.Dropdowns.registrate = function(element) {
|
||||||
|
this.push(element);
|
||||||
|
element.addEventListener('click', () => rl.Dropdowns.detectVisibility());
|
||||||
|
};
|
||||||
|
rl.Dropdowns.detectVisibility = (() =>
|
||||||
|
dropdownVisibility(!!rl.Dropdowns.find(item => item.classList.contains('open')))
|
||||||
|
).debounce(50);
|
||||||
|
|
||||||
window.rl = rl;
|
window.rl = rl;
|
||||||
|
|
||||||
const start = () => {
|
const start = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue