Initial AI-generated site
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// Set current year in footer
|
||||
const yearEl = document.getElementById('current-year');
|
||||
if (yearEl) {
|
||||
yearEl.textContent = new Date().getFullYear();
|
||||
}
|
||||
|
||||
// Set minimum date for booking (today)
|
||||
const dateInput = document.getElementById('date');
|
||||
if (dateInput) {
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
dateInput.setAttribute('min', today);
|
||||
}
|
||||
|
||||
// Header scroll effect
|
||||
const header = document.querySelector('.site-header');
|
||||
|
||||
function handleScroll() {
|
||||
if (window.scrollY > 50) {
|
||||
header.classList.add('scrolled');
|
||||
} else {
|
||||
header.classList.remove('scrolled');
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', handleScroll, { passive: true });
|
||||
|
||||
// Mobile nav toggle
|
||||
const navToggle = document.querySelector('.nav-toggle');
|
||||
const navLinks = document.querySelector('.nav-links');
|
||||
|
||||
if (navToggle && navLinks) {
|
||||
navToggle.addEventListener('click', function() {
|
||||
const isExpanded = this.getAttribute('aria-expanded') === 'true';
|
||||
this.setAttribute('aria-expanded', !isExpanded);
|
||||
navLinks.classList.toggle('active');
|
||||
document.body.style.overflow = isExpanded ? '' : 'hidden';
|
||||
});
|
||||
|
||||
// Close menu when clicking a link
|
||||
navLinks.querySelectorAll('a').forEach(function(link) {
|
||||
link.addEventListener('click', function() {
|
||||
navToggle.setAttribute('aria-expanded', 'false');
|
||||
navLinks.classList.remove('active');
|
||||
document.body.style.overflow = '';
|
||||
});
|
||||
});
|
||||
|
||||
// Close menu on escape key
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape' && navLinks.classList.contains('active')) {
|
||||
navToggle.setAttribute('aria-expanded', 'false');
|
||||
navLinks.classList.remove('active');
|
||||
document.body.style.overflow = '';
|
||||
navToggle.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Reveal on scroll
|
||||
const revealElements = document.querySelectorAll('.reveal');
|
||||
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
|
||||
|
||||
if (prefersReducedMotion.matches) {
|
||||
revealElements.forEach(function(el) {
|
||||
el.classList.add('visible');
|
||||
});
|
||||
} else if ('IntersectionObserver' in window) {
|
||||
const revealObserver = new IntersectionObserver(function(entries) {
|
||||
entries.forEach(function(entry) {
|
||||
if (entry.isIntersecting) {
|
||||
entry.target.classList.add('visible');
|
||||
revealObserver.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
}, {
|
||||
threshold: 0.1,
|
||||
rootMargin: '0px 0px -40px 0px'
|
||||
});
|
||||
|
||||
revealElements.forEach(function(el) {
|
||||
revealObserver.observe(el);
|
||||
});
|
||||
} else {
|
||||
revealElements.forEach(function(el) {
|
||||
el.classList.add('visible');
|
||||
});
|
||||
}
|
||||
|
||||
// Smooth scroll for anchor links
|
||||
document.querySelectorAll('a[href^="#"]').forEach(function(anchor) {
|
||||
anchor.addEventListener('click', function(e) {
|
||||
const targetId = this.getAttribute('href');
|
||||
if (targetId === '#') return;
|
||||
|
||||
const target = document.querySelector(targetId);
|
||||
if (target) {
|
||||
e.preventDefault();
|
||||
const headerHeight = header.offsetHeight;
|
||||
const targetPosition = target.getBoundingClientRect().top + window.scrollY - headerHeight - 20;
|
||||
|
||||
window.scrollTo({
|
||||
top: targetPosition,
|
||||
behavior: prefersReducedMotion.matches ? 'auto' : 'smooth'
|
||||
});
|
||||
|
||||
// Set focus for accessibility
|
||||
target.setAttribute('tabindex', '-1');
|
||||
target.focus({ preventScroll: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Gallery keyboard interaction
|
||||
document.querySelectorAll('.gallery-item').forEach(function(item) {
|
||||
item.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
// Could open a lightbox here; for now just visual feedback
|
||||
this.style.transform = 'scale(0.98)';
|
||||
setTimeout(() => {
|
||||
this.style.transform = '';
|
||||
}, 150);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Form handling
|
||||
const form = document.querySelector('.booking-form');
|
||||
|
||||
if (form) {
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Simple validation
|
||||
let isValid = true;
|
||||
const requiredFields = form.querySelectorAll('[required]');
|
||||
|
||||
requiredFields.forEach(function(field) {
|
||||
if (!field.value.trim()) {
|
||||
isValid = false;
|
||||
field.style.borderColor = '#e74c3c';
|
||||
field.setAttribute('aria-invalid', 'true');
|
||||
} else {
|
||||
field.style.borderColor = '';
|
||||
field.removeAttribute('aria-invalid');
|
||||
}
|
||||
});
|
||||
|
||||
// Phone validation
|
||||
const phoneField = form.querySelector('#phone');
|
||||
if (phoneField && phoneField.value) {
|
||||
const phonePattern = /^[0-9\-\+\s]{9,15}$/;
|
||||
if (!phonePattern.test(phoneField.value.trim())) {
|
||||
isValid = false;
|
||||
phoneField.style.borderColor = '#e74c3c';
|
||||
phoneField.setAttribute('aria-invalid', 'true');
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
const btn = form.querySelector('.submit-btn');
|
||||
const originalText = btn.textContent;
|
||||
btn.textContent = 'הבקשה נשלחה בהצלחה!';
|
||||
btn.style.background = '#27ae60';
|
||||
btn.disabled = true;
|
||||
|
||||
setTimeout(function() {
|
||||
btn.textContent = originalText;
|
||||
btn.style.background = '';
|
||||
btn.disabled = false;
|
||||
form.reset();
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
|
||||
// Clear error state on input
|
||||
form.querySelectorAll('input, select, textarea').forEach(function(field) {
|
||||
field.addEventListener('input', function() {
|
||||
this.style.borderColor = '';
|
||||
this.removeAttribute('aria-invalid');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user