-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathscript.js
More file actions
52 lines (46 loc) · 1.6 KB
/
Copy pathscript.js
File metadata and controls
52 lines (46 loc) · 1.6 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
(function () {
"use strict";
const header = document.querySelector(".header");
const navToggle = document.querySelector(".nav-toggle");
const navLinks = document.querySelector(".nav-links");
const contactForm = document.getElementById("contact-form");
// Header scroll: add background when scrolled
function onScroll() {
if (window.scrollY > 60) {
header.classList.add("scrolled");
} else {
header.classList.remove("scrolled");
}
}
window.addEventListener("scroll", onScroll, { passive: true });
onScroll();
// Mobile menu toggle
if (navToggle && navLinks) {
navToggle.addEventListener("click", function () {
navLinks.classList.toggle("open");
navToggle.setAttribute("aria-expanded", navLinks.classList.contains("open"));
});
// Close menu when clicking a link (smooth scroll then close)
navLinks.querySelectorAll("a").forEach(function (link) {
link.addEventListener("click", function () {
navLinks.classList.remove("open");
});
});
}
// Contact form: prevent default and show simple feedback
if (contactForm) {
contactForm.addEventListener("submit", function (e) {
e.preventDefault();
const btn = contactForm.querySelector('button[type="submit"]');
const originalText = btn.textContent;
btn.textContent = "Sent! We'll be in touch.";
btn.disabled = true;
// In production you would send the form data to a server here
setTimeout(function () {
btn.textContent = originalText;
btn.disabled = false;
contactForm.reset();
}, 3000);
});
}
})();