-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
112 lines (87 loc) · 2.81 KB
/
script.js
File metadata and controls
112 lines (87 loc) · 2.81 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
const faders = document.querySelectorAll('.fade-in');
const appearOptions = {
threshold: 0.3,
rootMargin: "0px 0px -100px 0px"
};
const appearOnScroll = new IntersectionObserver(function(entries, appearOnScroll) {
entries.forEach(entry => {
if (!entry.isIntersecting) return;
entry.target.classList.add('appear');
appearOnScroll.unobserve(entry.target);
});
}, appearOptions);
faders.forEach(fader => {
appearOnScroll.observe(fader);
});
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth'
});
}
});
});
const tabs = document.querySelectorAll('.tab');
const panels = document.querySelectorAll('.tab-panel');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
const target = tab.dataset.tab;
tabs.forEach(t => t.classList.remove('active'));
panels.forEach(p => p.classList.remove('active'));
tab.classList.add('active');
document.getElementById(target).classList.add('active');
});
});
// for CTA
const form = document.querySelector('form');
if (form) {
form.addEventListener('submit', function(e) {
e.preventDefault();
const inputs = form.querySelectorAll('input[required], textarea[required]');
let hasError = false;
inputs.forEach(input => {
if (!input.value.trim()) {
input.style.borderColor = 'red';
hasError = true;
} else {
input.style.borderColor = '#ccc';
}
});
if (hasError) {
alert('Please fill in all required fields.');
return;
}
const confirmed = confirm("Are you sure you want to submit this quote request?");
if (confirmed) {
form.submit();
}
});
}
window.addEventListener('load', () => {
document.querySelectorAll('.fade-in').forEach(el => {
el.classList.add('appear');
});
const header = document.querySelector('header.hero-section');
if (header) {
header.style.background = '#002838';
}
});
const carousel = document.getElementById("carousel");
const images = carousel.getElementsByTagName("img");
const total = images.length;
let angle = 0;
for (let i = 0; i < total; i++) {
const theta = (360 / total) * i;
images[i].style.transform = `rotateY(${theta}deg) translateZ(400px)`;
}
document.querySelector(".next").addEventListener("click", () => {
angle -= 360 / total;
carousel.style.transform = `rotateY(${angle}deg)`;
});
document.querySelector(".prev").addEventListener("click", () => {
angle += 360 / total;
carousel.style.transform = `rotateY(${angle}deg)`;
});