mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Lexical: Worked on toolbar styling, got format submenu working
This commit is contained in:
@ -1,7 +1,16 @@
|
||||
|
||||
|
||||
|
||||
export function handleDropdown(toggle: HTMLElement, menu: HTMLElement, onOpen: Function|undefined = undefined, onClose: Function|undefined = undefined) {
|
||||
interface HandleDropdownParams {
|
||||
toggle: HTMLElement;
|
||||
menu: HTMLElement;
|
||||
showOnHover?: boolean,
|
||||
onOpen?: Function | undefined;
|
||||
onClose?: Function | undefined;
|
||||
}
|
||||
|
||||
export function handleDropdown(options: HandleDropdownParams) {
|
||||
const {menu, toggle, onClose, onOpen, showOnHover} = options;
|
||||
let clickListener: Function|null = null;
|
||||
|
||||
const hide = () => {
|
||||
@ -27,8 +36,13 @@ export function handleDropdown(toggle: HTMLElement, menu: HTMLElement, onOpen: F
|
||||
}
|
||||
};
|
||||
|
||||
toggle.addEventListener('click', event => {
|
||||
const toggleShowing = (event: MouseEvent) => {
|
||||
menu.hasAttribute('hidden') ? show() : hide();
|
||||
});
|
||||
};
|
||||
toggle.addEventListener('click', toggleShowing);
|
||||
if (showOnHover) {
|
||||
toggle.addEventListener('mouseenter', toggleShowing);
|
||||
}
|
||||
|
||||
menu.addEventListener('mouseleave', hide);
|
||||
}
|
Reference in New Issue
Block a user