-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
143 lines (122 loc) · 4.1 KB
/
script.js
File metadata and controls
143 lines (122 loc) · 4.1 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
document.addEventListener("DOMContentLoaded", () => {
// Reveal animations on scroll
const revealEls = Array.from(document.querySelectorAll(".reveal"));
if (revealEls.length) {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("is-visible");
observer.unobserve(entry.target);
}
});
},
{ threshold: 0.2 }
);
revealEls.forEach((el) => observer.observe(el));
}
// Persona Tabs
const personaTabs = document.querySelectorAll(".persona-tab");
const personaPanels = document.querySelectorAll(".persona-panel");
personaTabs.forEach((tab) => {
tab.addEventListener("click", () => {
const targetPanel = tab.dataset.tab;
// Update tabs
personaTabs.forEach((t) => t.classList.remove("active"));
tab.classList.add("active");
// Update panels
personaPanels.forEach((panel) => {
panel.classList.remove("active");
if (panel.dataset.panel === targetPanel) {
panel.classList.add("active");
}
});
});
});
// Testimonial Carousel
const testimonialCards = document.querySelectorAll(".testimonial-card");
const testimonialDots = document.querySelectorAll(".testimonial-dot");
let currentTestimonial = 0;
let testimonialInterval;
function showTestimonial(index) {
testimonialCards.forEach((card, i) => {
card.classList.toggle("active", i === index);
});
testimonialDots.forEach((dot, i) => {
dot.classList.toggle("active", i === index);
});
currentTestimonial = index;
}
function nextTestimonial() {
const next = (currentTestimonial + 1) % testimonialCards.length;
showTestimonial(next);
}
function startTestimonialAutoplay() {
testimonialInterval = setInterval(nextTestimonial, 5000);
}
function stopTestimonialAutoplay() {
clearInterval(testimonialInterval);
}
// Initialize testimonial carousel
if (testimonialCards.length && testimonialDots.length) {
showTestimonial(0);
startTestimonialAutoplay();
// Dot navigation
testimonialDots.forEach((dot, index) => {
dot.addEventListener("click", () => {
stopTestimonialAutoplay();
showTestimonial(index);
startTestimonialAutoplay();
});
});
// Pause on hover
const testimonialCarousel = document.querySelector(".testimonial-carousel");
if (testimonialCarousel) {
testimonialCarousel.addEventListener("mouseenter", stopTestimonialAutoplay);
testimonialCarousel.addEventListener("mouseleave", startTestimonialAutoplay);
}
}
// Video Modal
const videoModal = document.getElementById("videoModal");
const watchDemoBtn = document.getElementById("watchDemoBtn");
const videoModalClose = document.getElementById("videoModalClose");
const videoModalBackdrop = document.querySelector(".video-modal-backdrop");
function openVideoModal() {
videoModal.classList.add("open");
document.body.classList.add("modal-open");
}
function closeVideoModal() {
videoModal.classList.remove("open");
document.body.classList.remove("modal-open");
}
if (watchDemoBtn && videoModal) {
watchDemoBtn.addEventListener("click", openVideoModal);
}
if (videoModalClose) {
videoModalClose.addEventListener("click", closeVideoModal);
}
if (videoModalBackdrop) {
videoModalBackdrop.addEventListener("click", closeVideoModal);
}
// Close modal on Escape key
document.addEventListener("keydown", (e) => {
if (e.key === "Escape" && videoModal?.classList.contains("open")) {
closeVideoModal();
}
});
// Smooth scroll for nav links
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener("click", function (e) {
const targetId = this.getAttribute("href");
if (targetId === "#") return;
const targetEl = document.querySelector(targetId);
if (targetEl) {
e.preventDefault();
targetEl.scrollIntoView({
behavior: "smooth",
block: "start",
});
}
});
});
});