-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
87 lines (75 loc) · 2.5 KB
/
script.js
File metadata and controls
87 lines (75 loc) · 2.5 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
// Mobile Menu Toggle
const menuToggle = document.querySelector('.menu-toggle');
const navLinks = document.querySelector('.nav-links');
menuToggle.addEventListener('click', () => {
menuToggle.classList.toggle('active');
navLinks.classList.toggle('active');
});
// Close mobile menu when clicking on a link
document.querySelectorAll('.nav-link').forEach(link => {
link.addEventListener('click', () => {
menuToggle.classList.remove('active');
navLinks.classList.remove('active');
});
});
// FAQ Accordion
document.querySelectorAll('.faq-question').forEach(question => {
question.addEventListener('click', () => {
const currentlyActive = document.querySelector('.faq-question.active');
if(currentlyActive && currentlyActive !== question) {
currentlyActive.classList.toggle('active');
currentlyActive.nextElementSibling.style.maxHeight = 0;
}
question.classList.toggle('active');
const answer = question.nextElementSibling;
if(question.classList.contains('active')) {
answer.style.maxHeight = answer.scrollHeight + 'px';
} else {
answer.style.maxHeight = 0;
}
});
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if(targetId === '#') return;
const targetElement = document.querySelector(targetId);
if(targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
}
});
});
// Form submission
const contactForm = document.getElementById('contactForm');
if(contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Get form values
const formData = new FormData(this);
const data = {};
formData.forEach((value, key) => {
data[key] = value;
});
// Here you would typically send the data to a server
console.log('Form submitted:', data);
// Show success message
alert('Thank you for your message! We will get back to you soon.');
this.reset();
});
}
// Sticky navbar on scroll
window.addEventListener('scroll', function() {
const navbar = document.querySelector('.navbar');
if(window.scrollY > 100) {
navbar.style.backgroundColor = 'rgba(26, 26, 26, 0.95)';
navbar.style.padding = '15px 0';
} else {
navbar.style.backgroundColor = 'rgba(0, 0, 0, 0.2)';
navbar.style.padding = '20px 0';
}
});