forked from ducompsoc/durhack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfaqs.js
34 lines (31 loc) · 1.02 KB
/
faqs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
export function faqLogic() {
/**
* Make FAQs clickable and unclickable.
*/
function closeQuestions() {
const open = document.querySelector('.faqs .question:not(.closed)');
if (open) {
const answer = open.querySelector('.answer')
answer.onanimationend = (e) => {
answer.onanimationend = (e) => {
};
answer.classList.remove('fade-out');
open.classList.add('closed');
}
answer.classList.add('fade-out');
}
}
document.addEventListener('click', () => {
closeQuestions();
});
document.querySelectorAll('.faqs .question').forEach(element => {
element.querySelector('.title').addEventListener('click', event => {
const isClosed = element.classList.contains('closed');
closeQuestions();
if (isClosed) {
element.classList.remove('closed');
}
event.stopPropagation();
});
});
}