webapp - ESLint + Prettier with pre-commit hooks (#54)
resolves #47 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/54
This commit is contained in:
parent
2acb619a11
commit
f8927b426e
83 changed files with 7137 additions and 5113 deletions
|
|
@ -1,17 +1,25 @@
|
|||
import type { DirectiveBinding } from 'vue';
|
||||
|
||||
interface ClickOutsideElement extends HTMLElement {
|
||||
clickOutsideEvent?: (event: MouseEvent) => void;
|
||||
}
|
||||
|
||||
export default {
|
||||
beforeMount(el: any, binding: any) {
|
||||
el.clickOutsideEvent = function (event: any) {
|
||||
// Check if the clicked element is neither the element
|
||||
// to which the directive is applied nor its child
|
||||
if (!(el === event.target || el.contains(event.target))) {
|
||||
// Invoke the provided method
|
||||
binding.value(event);
|
||||
}
|
||||
};
|
||||
document.addEventListener("click", el.clickOutsideEvent);
|
||||
},
|
||||
unmounted(el: any) {
|
||||
// Remove the event listener when the bound element is unmounted
|
||||
document.removeEventListener("click", el.clickOutsideEvent);
|
||||
},
|
||||
beforeMount(el: ClickOutsideElement, binding: DirectiveBinding<(event: MouseEvent) => void>) {
|
||||
el.clickOutsideEvent = function (event: MouseEvent) {
|
||||
// Check if the clicked element is neither the element
|
||||
// to which the directive is applied nor its child
|
||||
if (!(el === event.target || el.contains(event.target as Node))) {
|
||||
// Invoke the provided method
|
||||
binding.value(event);
|
||||
}
|
||||
};
|
||||
document.addEventListener('click', el.clickOutsideEvent);
|
||||
},
|
||||
unmounted(el: ClickOutsideElement) {
|
||||
// Remove the event listener when the bound element is unmounted
|
||||
if (el.clickOutsideEvent) {
|
||||
document.removeEventListener('click', el.clickOutsideEvent);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue