document.addEventListener('DOMContentLoaded', () => { const headerUsefulLinks = document.querySelector('.useful-links'); const headerLogoCart = document.querySelector('.header-logo__cart'); const searchForm = document.querySelector('.search_wrap'); const shoppingCart = document.querySelector('.shopping-cart'); const shoppingCartLogo = document.querySelector('.logo-shopping-cart'); headerUsefulLinks.addEventListener('click', (event) => { if (event.target.closest('.search-title')) { searchForm.classList.add('search_opened'); setTimeout(() => (searchForm.style.opacity = 1), 0); } if (event.target.closest('.search_close')) { searchForm.style.opacity = 0; setTimeout(() => searchForm.classList.remove('search_opened'), 500); } if (event.target.closest('.cart-title')) { shoppingCart.style.display = 'block'; setTimeout(() => (shoppingCart.style.opacity = 1), 0); } if (event.target.closest('.close-icon')) { shoppingCart.style.opacity = 0; setTimeout(() => (shoppingCart.style.display = 'none'), 500); } }); headerLogoCart.addEventListener('click', (event) => { console.log(event.target); if (event.target.closest('.logo-cart-title')) { shoppingCartLogo.style.display = 'block'; setTimeout(() => (shoppingCartLogo.style.opacity = 1), 0); } if (event.target.closest('.logo-close-icon')) { shoppingCartLogo.style.opacity = 0; setTimeout(() => (shoppingCartLogo.style.display = 'none'), 500); } }); });