forked from metroman9/Theband
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
58 lines (46 loc) · 1.37 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const buyBtns = document.querySelectorAll('.place-button');
const model = document.querySelector('.model');
const modelContainer = document.querySelector('.model-container');
const closeBtns = document.querySelectorAll('.close');
function showModel(){
model.classList.add('open');
}
function hideModel() {
model.classList.remove('open');
}
for(const buyBtn of buyBtns){
buyBtn.addEventListener('click',showModel);
}
for(const closeBtn of closeBtns){
closeBtn.addEventListener('click',hideModel);
}
model.addEventListener('click',hideModel)
modelContainer.addEventListener('click',function(even){
even.stopPropagation();
})
// Mobile menu
const header = document.querySelector('#header');
const menuIcon = document.querySelector('.menu-btn');
const menuItems = document.querySelectorAll('#nav li a[href*="#"]');
const headerHeight = header.clientHeight;
menuIcon.onclick = function(){
// open
if(header.clientHeight == headerHeight){
header.style.height = 'auto';
}
// close
else{
header.style.height = null;
}
}
menuItems.forEach(menuItem => {
menuItem.onclick = function (even) {
var isParent = this.nextElementSibling && this.nextElementSibling.classList.contains('subnav');
if(isParent){
even.preventDefault();
}
else{
header.style.height = null;
}
}
});