-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
241 lines (203 loc) · 7.1 KB
/
script.js
File metadata and controls
241 lines (203 loc) · 7.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
// Smooth scroll behavior for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const header = document.querySelector('.header');
const secondaryNav = document.querySelector('.secondary-nav');
const headerHeight = header ? header.offsetHeight : 0;
const navHeight = secondaryNav ? secondaryNav.offsetHeight : 0;
const offset = headerHeight + navHeight;
const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - offset;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
});
// Adjust secondary nav sticky position based on header height
document.addEventListener('DOMContentLoaded', function () {
const header = document.querySelector('.header');
const secondaryNav = document.querySelector('.secondary-nav');
if (header && secondaryNav) {
function updateSecondaryNavPosition() {
const headerHeight = header.offsetHeight;
secondaryNav.style.top = headerHeight + 'px';
}
updateSecondaryNavPosition();
window.addEventListener('resize', updateSecondaryNavPosition);
}
});
// Mobile menu toggle (if needed for future enhancement)
document.addEventListener('DOMContentLoaded', function () {
// Floating contact button visibility on scroll
const floatingBtn = document.getElementById('floatingContactBtn');
window.addEventListener('scroll', function () {
const header = document.querySelector('.header');
// Header shadow effect
if (window.scrollY > 100) {
header.style.boxShadow = '0 4px 20px rgba(0, 0, 0, 0.2)';
} else {
header.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 0.1)';
}
// Show floating button after scrolling 200px
if (floatingBtn) {
if (window.scrollY > 300) {
floatingBtn.classList.add('visible');
} else {
floatingBtn.classList.remove('visible');
}
}
});
// Prevent dropdown from closing when clicking inside it
document.querySelectorAll('.dropdown').forEach(dropdown => {
dropdown.addEventListener('click', function (e) {
e.stopPropagation();
});
});
// Contact form submission handling
const contactForm = document.getElementById('contact-form');
if (contactForm) {
contactForm.addEventListener('submit', function (e) {
e.preventDefault();
// Get form data
const formData = {
firstName: document.getElementById('firstName').value,
lastName: document.getElementById('lastName').value,
email: document.getElementById('email').value,
mobile: document.getElementById('mobile').value,
company: document.getElementById('company').value,
jobTitle: document.getElementById('jobTitle').value,
message: document.getElementById('message').value
};
// Log form data (in a real application, you would send this to a server)
console.log('Form submitted:', formData);
// Show success message
alert('Thank you for contacting us! We will get back to you soon.');
// Reset form
contactForm.reset();
});
}
// Carousel functionality
const slides = document.querySelectorAll('.carousel-slide');
const dots = document.querySelectorAll('.carousel-dot');
let currentSlide = 0;
let carouselInterval;
// Function to show a specific slide
function showSlide(index) {
// Update slides
slides.forEach((slide, i) => {
slide.classList.remove('active');
if (i === index) {
slide.classList.add('active');
}
});
// Update dots
dots.forEach((dot, i) => {
dot.classList.remove('active');
if (i === index) {
dot.classList.add('active');
}
});
currentSlide = index;
}
// Function to go to next slide
function nextSlide() {
const nextIndex = (currentSlide + 1) % slides.length;
showSlide(nextIndex);
}
// Function to go to previous slide
function prevSlide() {
const prevIndex = (currentSlide - 1 + slides.length) % slides.length;
showSlide(prevIndex);
}
// Auto-advance carousel every 10 seconds
function startCarousel() {
carouselInterval = setInterval(nextSlide, 10000);
}
// Stop auto-advance (useful when user manually navigates)
function stopCarousel() {
clearInterval(carouselInterval);
}
// Restart auto-advance after manual navigation
function restartCarousel() {
stopCarousel();
startCarousel();
}
// Event listeners for dot navigation
dots.forEach((dot, index) => {
dot.addEventListener('click', function () {
showSlide(index);
restartCarousel();
});
});
// Event listeners for arrow navigation
const prevArrow = document.querySelector('.carousel-arrow-left');
const nextArrow = document.querySelector('.carousel-arrow-right');
if (prevArrow) {
prevArrow.addEventListener('click', function () {
prevSlide();
restartCarousel();
});
}
if (nextArrow) {
nextArrow.addEventListener('click', function () {
nextSlide();
restartCarousel();
});
}
// Initialize carousel
if (slides.length > 0) {
showSlide(currentSlide);
startCarousel();
}
// Cloud Continuum Tabs
const cloudTabBtns = document.querySelectorAll('.cloud-tab-btn');
const cloudTabPanels = document.querySelectorAll('.cloud-tab-panel');
cloudTabBtns.forEach(btn => {
btn.addEventListener('click', function () {
const targetTab = this.getAttribute('data-tab');
// Remove active class from all buttons and panels
cloudTabBtns.forEach(b => b.classList.remove('active'));
cloudTabPanels.forEach(p => p.classList.remove('active'));
// Add active class to clicked button and corresponding panel
this.classList.add('active');
document.getElementById(targetTab).classList.add('active');
});
});
// Mobile menu toggle
const mobileMenuToggle = document.getElementById('mobileMenuToggle');
const navbar = document.querySelector('.navbar');
const navMenu = document.getElementById('navMenu');
if (mobileMenuToggle) {
mobileMenuToggle.addEventListener('click', function () {
navbar.classList.toggle('active');
mobileMenuToggle.classList.toggle('active');
});
// Toggle dropdown on mobile
const navItems = document.querySelectorAll('.nav-item');
navItems.forEach(item => {
const link = item.querySelector('.nav-link');
const dropdown = item.querySelector('.dropdown');
if (dropdown && link) {
link.addEventListener('click', function (e) {
if (window.innerWidth <= 768) {
e.preventDefault();
item.classList.toggle('active');
}
});
}
});
// Close menu when clicking outside
document.addEventListener('click', function (e) {
if (window.innerWidth <= 768) {
if (!navbar.contains(e.target) && !mobileMenuToggle.contains(e.target)) {
navbar.classList.remove('active');
mobileMenuToggle.classList.remove('active');
}
}
});
}
});