Download script.js from Linardtip1/deepsite-project-tu9rf: direct link, hf CLI and curl.
- Browser
- Download file 2.92 kB
-
https://huggingface.co/spaces/Linardtip1/deepsite-project-tu9rf/resolve/main/script.js
- Command line
-
hf download hf://spaces/Linardtip1/deepsite-project-tu9rf/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Linardtip1/deepsite-project-tu9rf/resolve/main/script.js
2.92 kB
| // === Mobile Menu === | |
| const burgerBtn = document.getElementById('burgerBtn'); | |
| const closeMenuBtn = document.getElementById('closeMenuBtn'); | |
| const mobileMenu = document.getElementById('mobileMenu'); | |
| const mobileLinks = mobileMenu.querySelectorAll('.mobile-menu__link'); | |
| function openMenu() { | |
| mobileMenu.classList.add('active'); | |
| document.body.style.overflow = 'hidden'; | |
| } | |
| function closeMenu() { | |
| mobileMenu.classList.remove('active'); | |
| document.body.style.overflow = ''; | |
| } | |
| burgerBtn.addEventListener('click', openMenu); | |
| closeMenuBtn.addEventListener('click', closeMenu); | |
| // Close on overlay click | |
| mobileMenu.querySelector('.mobile-menu__overlay').addEventListener('click', closeMenu); | |
| // Close on link click | |
| mobileLinks.forEach(link => { | |
| link.addEventListener('click', closeMenu); | |
| }); | |
| // === Modal for Photo/Video === | |
| const modal = document.getElementById('modal'); | |
| const modalClose = document.getElementById('modalClose'); | |
| const modalContent = document.getElementById('modalContent'); | |
| const portfolioItems = document.querySelectorAll('.portfolio__item'); | |
| function openModal(src, type) { | |
| modalContent.innerHTML = ''; | |
| if (type === 'video') { | |
| const video = document.createElement('video'); | |
| video.src = src; | |
| video.controls = true; | |
| video.autoplay = true; | |
| video.style.maxWidth = '90vw'; | |
| video.style.maxHeight = '85vh'; | |
| video.style.borderRadius = '10px'; | |
| modalContent.appendChild(video); | |
| } else { | |
| const img = document.createElement('img'); | |
| img.src = src; | |
| img.alt = 'Фото'; | |
| modalContent.appendChild(img); | |
| } | |
| modal.classList.add('active'); | |
| document.body.style.overflow = 'hidden'; | |
| } | |
| function closeModal() { | |
| modal.classList.remove('active'); | |
| modalContent.innerHTML = ''; | |
| document.body.style.overflow = ''; | |
| } | |
| portfolioItems.forEach(item => { | |
| item.addEventListener('click', () => { | |
| const src = item.getAttribute('data-src'); | |
| const type = item.getAttribute('data-type') || 'image'; | |
| openModal(src, type); | |
| }); | |
| }); | |
| modalClose.addEventListener('click', closeModal); | |
| modal.addEventListener('click', (e) => { | |
| if (e.target === modal) { | |
| closeModal(); | |
| } | |
| }); | |
| // Close on Escape | |
| document.addEventListener('keydown', (e) => { | |
| if (e.key === 'Escape') { | |
| if (modal.classList.contains('active')) { | |
| closeModal(); | |
| } | |
| if (mobileMenu.classList.contains('active')) { | |
| closeMenu(); | |
| } | |
| } | |
| }); | |
| // === Header scroll effect === | |
| const header = document.getElementById('header'); | |
| let lastScroll = 0; | |
| window.addEventListener('scroll', () => { | |
| const currentScroll = window.pageYOffset; | |
| if (currentScroll > 50) { | |
| header.style.boxShadow = '0 4px 32px rgba(0,0,0,0.3)'; | |
| } else { | |
| header.style.boxShadow = 'none'; | |
| } | |
| lastScroll = currentScroll; | |
| }); |