-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (23 loc) · 1.07 KB
/
Copy pathscript.js
File metadata and controls
26 lines (23 loc) · 1.07 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
const navToggle = document.querySelector("[data-nav-toggle]");
const nav = document.querySelector("[data-nav]");
const contactForm = document.querySelector("[data-contact-form]");
navToggle?.addEventListener("click", () => {
const isOpen = nav?.classList.toggle("is-open") ?? false;
navToggle.setAttribute("aria-expanded", String(isOpen));
});
nav?.addEventListener("click", (event) => {
if (event.target instanceof HTMLAnchorElement) {
nav.classList.remove("is-open");
navToggle?.setAttribute("aria-expanded", "false");
}
});
contactForm?.addEventListener("submit", (event) => {
event.preventDefault();
const formData = new FormData(contactForm);
const name = String(formData.get("name") ?? "").trim();
const email = String(formData.get("email") ?? "").trim();
const message = String(formData.get("message") ?? "").trim();
const subject = encodeURIComponent(`Portfolio inquiry from ${name}`);
const body = encodeURIComponent(`${message}\n\nFrom: ${name}\nEmail: ${email}`);
window.location.href = `mailto:kttu@ucsd.edu?subject=${subject}&body=${body}`;
});