Spaces:
Running
Running
Download script.js from Mikeshu/neurozeh-redesign: direct link, hf CLI and curl.
- Browser
- Download file 4.49 kB
-
https://huggingface.co/spaces/Mikeshu/neurozeh-redesign/resolve/main/script.js
- Command line
-
hf download hf://spaces/Mikeshu/neurozeh-redesign/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Mikeshu/neurozeh-redesign/resolve/main/script.js
4.49 kB
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| // Close mobile menu if open | |
| const header = document.querySelector('custom-header'); | |
| if (header) { | |
| const shadowRoot = header.shadowRoot; | |
| const navMenu = shadowRoot.getElementById('navMenu'); | |
| const menuBtn = shadowRoot.getElementById('menuBtn'); | |
| if (navMenu.classList.contains('active')) { | |
| navMenu.classList.remove('active'); | |
| const menuIcon = menuBtn.querySelector('i'); | |
| menuIcon.setAttribute('data-feather', 'menu'); | |
| feather.replace(); | |
| } | |
| } | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| // Form submission handling with better UX | |
| const contactForm = document.querySelector('#contact form'); | |
| if (contactForm) { | |
| contactForm.addEventListener('submit', async function(e) { | |
| e.preventDefault(); | |
| const submitBtn = this.querySelector('button[type="submit"]'); | |
| const originalBtnText = submitBtn.innerHTML; | |
| try { | |
| // Show loading state | |
| submitBtn.innerHTML = ` | |
| <span class="inline-flex items-center"> | |
| <svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"> | |
| <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> | |
| <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> | |
| </svg> | |
| Отправка... | |
| </span> | |
| `; | |
| submitBtn.disabled = true; | |
| // Simulate API call | |
| await new Promise(resolve => setTimeout(resolve, 1500)); | |
| // Show success | |
| const toast = document.createElement('div'); | |
| toast.className = 'fixed top-6 right-6 bg-green-500 text-white px-6 py-3 rounded-lg shadow-lg flex items-center animate-fade-in-up z-50'; | |
| toast.innerHTML = ` | |
| <i data-feather="check-circle" class="w-5 h-5 mr-2"></i> | |
| <span>Сообщение отправлено! Мы свяжемся с вами в ближайшее время.</span> | |
| `; | |
| document.body.appendChild(toast); | |
| feather.replace(); | |
| // Remove toast after 5s | |
| setTimeout(() => { | |
| toast.classList.add('opacity-0', 'transition-opacity', 'duration-300'); | |
| setTimeout(() => toast.remove(), 300); | |
| }, 5000); | |
| // Reset form | |
| this.reset(); | |
| } catch (error) { | |
| console.error('Form submission error:', error); | |
| } finally { | |
| submitBtn.innerHTML = originalBtnText; | |
| submitBtn.disabled = false; | |
| } | |
| }); | |
| } | |
| // Enhanced animation on scroll | |
| const observerOptions = { | |
| root: null, | |
| rootMargin: '0px', | |
| threshold: 0.1 | |
| }; | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('animate-fade-in-up'); | |
| observer.unobserve(entry.target); | |
| } | |
| }); | |
| }, observerOptions); | |
| document.querySelectorAll('[class*="animate-"]').forEach(el => { | |
| observer.observe(el); | |
| }); | |
| // Initialize tooltips | |
| document.querySelectorAll('[data-tooltip]').forEach(el => { | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'absolute hidden bg-gray-900 text-white text-xs rounded py-1 px-2 whitespace-nowrap z-50'; | |
| tooltip.textContent = el.getAttribute('data-tooltip'); | |
| document.body.appendChild(tooltip); | |
| el.addEventListener('mouseenter', () => { | |
| const rect = el.getBoundingClientRect(); | |
| tooltip.style.top = `${rect.top - 30}px`; | |
| tooltip.style.left = `${rect.left + rect.width/2 - tooltip.offsetWidth/2}px`; | |
| tooltip.classList.remove('hidden'); | |
| }); | |
| el.addEventListener('mouseleave', () => { | |
| tooltip.classList.add('hidden'); | |
| }); | |
| }); | |