2018-10-09 11:35:22 +02:00
|
|
|
import { delegate } from '@utils';
|
2018-09-11 17:51:44 +02:00
|
|
|
|
2018-10-09 11:35:22 +02:00
|
|
|
delegate('click', 'body', event => {
|
2018-09-11 17:51:44 +02:00
|
|
|
if (!event.target.closest('.dropdown')) {
|
|
|
|
[...document.querySelectorAll('.dropdown')].forEach(element =>
|
|
|
|
element.classList.remove('open', 'fade-in-down')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-10-09 11:35:22 +02:00
|
|
|
delegate('click', '.dropdown-button', event => {
|
2018-09-11 17:51:44 +02:00
|
|
|
event.stopPropagation();
|
|
|
|
const parent = event.target.closest('.dropdown-button').parentElement;
|
|
|
|
if (parent.classList.contains('dropdown')) {
|
|
|
|
parent.classList.toggle('open');
|
|
|
|
}
|
|
|
|
});
|