-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (34 loc) · 1.11 KB
/
app.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
35
36
37
38
39
40
// debugger;
function toggleClass(e, className){
if (e.className.indexOf(className) !== -1){
e.className = e.className.replace(className,'');
}
else{
e.className = e.className.replace(`/\s+/g`,' ') + ' ' + className;
}
return e;
}
function toggleDisplay(e){
const curDisplayStyle = e.style.display;
if (curDisplayStyle === 'none' || curDisplayStyle === ''){
e.style.display = 'block';
}
else{
e.style.display = 'none';
}
}
function toggleMenuDisplay(e){
const dropdown = e.currentTarget.parentNode;
const menu = dropdown.querySelector('.menu-dropdown');
const menuIcon = dropdown.querySelector('#menu-svg');
const closeIcon = dropdown.querySelector('#close-svg')
const title = dropdown.querySelector('.title')
console.log('clicked')
toggleClass(menu,'hide');
toggleClass(closeIcon,'bring-to-front')
toggleClass(title, 'send-to-back')
toggleClass(menuIcon,'hide');
}
const menuButton = document.querySelector('.dropdown');
const dropdownOptions = document.querySelectorAll('.dropdown .menu-dropdown .dropdown-bullets');
menuButton.addEventListener('click', toggleMenuDisplay);