-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
129 lines (109 loc) · 5.26 KB
/
script.js
File metadata and controls
129 lines (109 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
const navLinksItems = document.querySelectorAll('.nav-links a');
hamburger.addEventListener('click', () => {
navLinks.classList.toggle('active');
hamburger.innerHTML = navLinks.classList.contains('active') ?
'<i class="fas fa-times"></i>' : '<i class="fas fa-bars"></i>';
document.body.style.overflow = navLinks.classList.contains('active') ? 'hidden' : '';
});
// Close mobile menu when clicking a link
navLinksItems.forEach(link => {
link.addEventListener('click', () => {
navLinks.classList.remove('active');
hamburger.innerHTML = '<i class="fas fa-bars"></i>';
document.body.style.overflow = '';
});
});
// Header scroll effect
window.addEventListener('scroll', () => {
const header = document.getElementById('header');
header.classList.toggle('scrolled', window.scrollY > 50);
});
// Menu category filtering
const menuButtons = document.querySelectorAll('.menu-categories button');
const menuItems = document.querySelectorAll('.menu-item');
menuButtons.forEach(button => {
button.addEventListener('click', () => {
// Remove active class from all buttons
menuButtons.forEach(btn => btn.classList.remove('active'));
// Add active class to clicked button
button.classList.add('active');
const category = button.getAttribute('data-category');
menuItems.forEach(item => {
if (category === 'all' || item.getAttribute('data-category') === category) {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
});
});
// Testimonial slider
let currentTestimonial = 0;
const testimonials = document.querySelectorAll('.testimonial');
function showTestimonial(index) {
testimonials.forEach(testimonial => {
testimonial.style.display = 'none';
});
testimonials[index].style.display = 'block';
}
function nextTestimonial() {
currentTestimonial = (currentTestimonial + 1) % testimonials.length;
showTestimonial(currentTestimonial);
}
// Show first testimonial initially
showTestimonial(0);
// Rotate testimonials every 5 seconds
setInterval(nextTestimonial, 5000);
// Scroll animation with Intersection Observer
const observerOptions = {
threshold: 0.1,
rootMargin: "0px 0px -100px 0px"
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('in-view');
// Stop observing after animation triggers
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe all elements that need animation
document.querySelectorAll('.about-text, .about-image, .menu-item, .gallery-item, .testimonial, .reservation-form, .reservation-info').forEach(element => {
observer.observe(element);
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
}
});
});
// Close menu when clicking outside
document.addEventListener('click', function(e) {
if (!e.target.closest('nav') && navLinks.classList.contains('active')) {
navLinks.classList.remove('active');
hamburger.innerHTML = '<i class="fas fa-bars"></i>';
document.body.style.overflow = '';
}
});
// Form submission
document.querySelector('.reservation-form').addEventListener('submit', function(e) {
e.preventDefault();
alert('Thank you for your reservation! We will contact you shortly to confirm.');
this.reset();
});
document.querySelector('.newsletter-form').addEventListener('submit', function(e) {
e.preventDefault();
alert('Thank you for subscribing to our newsletter!');
this.reset();
});