Initial AI-generated site
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// Mobile Menu Toggle
|
||||
const menuToggle = document.querySelector('.menu-toggle');
|
||||
const navLinks = document.querySelector('.nav-links');
|
||||
const menuOverlay = document.querySelector('.menu-overlay');
|
||||
|
||||
function closeMenu() {
|
||||
menuToggle.setAttribute('aria-expanded', 'false');
|
||||
menuToggle.setAttribute('aria-label', 'פתיחת תפריט');
|
||||
navLinks.classList.remove('is-open');
|
||||
menuOverlay.classList.remove('is-visible');
|
||||
menuOverlay.setAttribute('aria-hidden', 'true');
|
||||
}
|
||||
|
||||
function openMenu() {
|
||||
menuToggle.setAttribute('aria-expanded', 'true');
|
||||
menuToggle.setAttribute('aria-label', 'סגירת תפריט');
|
||||
navLinks.classList.add('is-open');
|
||||
menuOverlay.classList.add('is-visible');
|
||||
menuOverlay.setAttribute('aria-hidden', 'false');
|
||||
}
|
||||
|
||||
if (menuToggle && navLinks && menuOverlay) {
|
||||
menuToggle.addEventListener('click', function() {
|
||||
const isExpanded = menuToggle.getAttribute('aria-expanded') === 'true';
|
||||
if (isExpanded) {
|
||||
closeMenu();
|
||||
} else {
|
||||
openMenu();
|
||||
}
|
||||
});
|
||||
|
||||
// Close menu when clicking overlay
|
||||
menuOverlay.addEventListener('click', closeMenu);
|
||||
|
||||
// Close menu when clicking a link
|
||||
navLinks.querySelectorAll('a').forEach(function(link) {
|
||||
link.addEventListener('click', closeMenu);
|
||||
});
|
||||
|
||||
// Close menu on Escape key
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape' && navLinks.classList.contains('is-open')) {
|
||||
closeMenu();
|
||||
menuToggle.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Reveal on Scroll
|
||||
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
if (!prefersReducedMotion) {
|
||||
const revealElements = document.querySelectorAll('.reveal');
|
||||
|
||||
const revealObserver = new IntersectionObserver(function(entries) {
|
||||
entries.forEach(function(entry) {
|
||||
if (entry.isIntersecting) {
|
||||
entry.target.classList.add('is-visible');
|
||||
revealObserver.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
}, {
|
||||
root: null,
|
||||
rootMargin: '0px 0px -60px 0px',
|
||||
threshold: 0.1
|
||||
});
|
||||
|
||||
revealElements.forEach(function(el) {
|
||||
revealObserver.observe(el);
|
||||
});
|
||||
} else {
|
||||
// Show all elements immediately if reduced motion is preferred
|
||||
document.querySelectorAll('.reveal').forEach(function(el) {
|
||||
el.classList.add('is-visible');
|
||||
});
|
||||
}
|
||||
|
||||
// Smooth scroll for anchor links (fallback for browsers without CSS scroll-behavior)
|
||||
document.querySelectorAll('a[href^="#"]').forEach(function(anchor) {
|
||||
anchor.addEventListener('click', function(e) {
|
||||
const targetId = this.getAttribute('href');
|
||||
if (targetId === '#') return;
|
||||
|
||||
const targetElement = document.querySelector(targetId);
|
||||
if (targetElement) {
|
||||
e.preventDefault();
|
||||
targetElement.scrollIntoView({
|
||||
behavior: prefersReducedMotion ? 'auto' : 'smooth',
|
||||
block: 'start'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Header shadow on scroll
|
||||
const header = document.querySelector('.header');
|
||||
|
||||
if (header) {
|
||||
let ticking = false;
|
||||
|
||||
window.addEventListener('scroll', function() {
|
||||
if (!ticking) {
|
||||
window.requestAnimationFrame(function() {
|
||||
if (window.pageYOffset > 50) {
|
||||
header.style.boxShadow = '0 2px 20px rgba(61, 50, 41, 0.1)';
|
||||
} else {
|
||||
header.style.boxShadow = 'none';
|
||||
}
|
||||
ticking = false;
|
||||
});
|
||||
ticking = true;
|
||||
}
|
||||
}, { passive: true });
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user