-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
68 lines (59 loc) · 2.29 KB
/
scripts.js
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
document.addEventListener("DOMContentLoaded", () => {
// Smooth scrolling for navigation links
const navLinks = document.querySelectorAll(".menu .links a");
navLinks.forEach((link) => {
link.addEventListener("click", (e) => {
e.preventDefault();
const targetId = link.getAttribute("href");
const targetElement = document.querySelector(targetId);
targetElement.scrollIntoView({ behavior: "smooth" });
});
});
// Services section interactivity
const serviceItems = document.querySelectorAll("#servicos li");
serviceItems.forEach((item) => {
item.addEventListener("mouseenter", () => {
item.style.transform = "scale(1.05)";
});
item.addEventListener("mouseleave", () => {
item.style.transform = "scale(1)";
});
});
// Form submission
const contactForm = document.querySelector("#contato form");
contactForm.addEventListener("submit", (e) => {
e.preventDefault();
const name = document.querySelector("#name").value;
const email = document.querySelector("#email").value;
const message = document.querySelector("#message").value;
// Basic form validation
if (name.trim() === "" || email.trim() === "" || message.trim() === "") {
alert("Por favor, preencha todos os campos do formulário.");
return;
}
// You would typically send this data to a server here
// For now, we'll just log it to the console and show a success message
console.log("Form submitted:", { name, email, message });
alert(`Obrigado por entrar em contato, ${name}! Responderemos em breve.`);
contactForm.reset();
});
// Gallery image modal
const galleryImages = document.querySelectorAll("#galeria .gallery img");
const body = document.body;
galleryImages.forEach((img) => {
img.addEventListener("click", () => {
const modal = document.createElement("div");
modal.classList.add("image-modal");
modal.innerHTML = `
<div class="modal-content">
<img src="${img.src}" alt="${img.alt}">
<button class="close-modal">×</button>
</div>
`;
body.appendChild(modal);
modal.querySelector(".close-modal").addEventListener("click", () => {
body.removeChild(modal);
});
});
});
});