forked from platzi/curso-frontend-developer-practico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
57 lines (42 loc) · 1.62 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
// toogle = intercambiar
// Menu desktop
const menuEmail = document.querySelector('.navbar-email');
const desktopMenu = document.querySelector('.desktop-menu');
// Menu mobile
const hamburguerIconMenu = document.querySelector('.menu');
const mobileMenu = document.querySelector('.mobile-menu');
// My order
const carritoIconMenu = document.querySelector('.navbar-shopping-cart');
const aside = document.querySelector('.product-detail');
// Menu desktop
menuEmail.addEventListener('click', toogleDesktopMenu);
// Menu mobile
hamburguerIconMenu.addEventListener('click', toogleMobileMenu);
// My order
carritoIconMenu.addEventListener('click', toogleMyCarritoMenu);
function toogleDesktopMenu() {
const isMyCarritoClosed = aside.classList.contains('inactive');
if (!isMyCarritoClosed) {
aside.classList.add('inactive');
}
desktopMenu.classList.toggle('inactive');
}
function toogleMobileMenu() {
// const isMyCarritoClosed = aside.classList.contains('inactive');
// if (!isMyCarritoClosed) {
// aside.classList.add('inactive');
// }
aside.classList.add('inactive');
mobileMenu.classList.toggle('inactive');
}
function toogleMyCarritoMenu() {
// const isMobileMenuClosed = mobileMenu.classList.contains('inactive');
// const isDesktopMenuClosed = desktopMenu.classList.contains('inactive');
// if (!isMobileMenuClosed || !isDesktopMenuClosed) {
// mobileMenu.classList.add('inactive');
// desktopMenu.classList.add('inactive');
// }
mobileMenu.classList.add('inactive');
desktopMenu.classList.add('inactive');
aside.classList.toggle('inactive');
}