-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
578 lines (503 loc) · 18.1 KB
/
script.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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
//Navbar for smaller screens sizes
const toggleButton = document.getElementById("toggle-logo");
const sidebar = document.querySelector(".sidebar");
const navbarList = document.getElementById("navbar-list");
toggleButton.addEventListener("click", function () {
sidebar.classList.toggle("active");
});
document.addEventListener("click", function (event) {
const isClickInsideNavbar =
navbarList.contains(event.target) || toggleButton.contains(event.target);
const isSidebarActive = sidebar.classList.contains("active");
if (!isClickInsideNavbar && isSidebarActive && window.innerWidth <= 768) {
sidebar.classList.remove("active");
}
});
//Loader Screen JS
window.onload = function () {
// Ensure that the "Tap to Open" text only shows after everything is loaded
const loadingBar = document.querySelector(".loading-bar");
// Simulate a brief delay to enhance user experience, if needed
setTimeout(() => {
loadingBar.classList.remove("loading-bar");
loadingBar.classList.add("tap-to-open");
// Setting the text content
loadingBar.innerHTML =
'Tap to Open <i class="bi bi-arrow-right"></i>';
}, 100); // Adjust the delay as desired
document.querySelector("#loader").addEventListener("click", function () {
// Hide the loader and show the main content
document.querySelector("#loader").style.display = "none";
// Initialize AOS (or any other animations) after the loader is removed
setTimeout(() => {
AOS.init();
}, 500); // Adjust the delay time as needed
});
};
//For Section Video Play while:hover
document.addEventListener("DOMContentLoaded", () => {
const buttons = document.querySelectorAll(".cta-button");
const video = document.getElementById("hover-video");
buttons.forEach((button) => {
button.addEventListener("mouseenter", () => {
video.play();
video.style.filter = "grayscale(0%)";
video.style.transform = "translateY(-10px)";
});
button.addEventListener("mouseleave", () => {
video.pause();
video.currentTime = 0;
video.style.filter = "grayscale(100%)";
video.style.transform = "translateY(0)";
});
});
});
//Activate Tooltip Bootstrap Function
document.addEventListener("DOMContentLoaded", () => {
const tooltipTriggerList = Array.from(
document.querySelectorAll('[data-bs-toggle="tooltip"]')
);
tooltipTriggerList.forEach((tooltipTriggerEl) => {
try {
new bootstrap.Tooltip(tooltipTriggerEl);
} catch (error) {
console.error("Error initializing tooltip:", tooltipTriggerEl, error);
}
});
});
//Smooth BG Animation :hover
document.addEventListener("DOMContentLoaded", () => {
const sectionContent = document.getElementById("section-content");
const ctaButtons = sectionContent.querySelectorAll(".cta-button");
const newBackgroundImage =
"linear-gradient(to top, #d5d4d0 0%, #d5d4d0 1%, #eeeeec 31%, #efeeec 75%, #e9e9e7 100%)";
const originalBackgroundImage =
"linear-gradient(315deg, #2d3436 0%, #d3d3d3 74%)";
const updateMousePosition = (e) => {
const rect = sectionContent.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
sectionContent.style.setProperty("--mouse-x", `${x}px`);
sectionContent.style.setProperty("--mouse-y", `${y}px`);
};
const applyNewBackground = () => {
sectionContent.style.setProperty("--new-bg", newBackgroundImage);
};
const resetBackground = () => {
sectionContent.style.setProperty("--new-bg", originalBackgroundImage);
};
ctaButtons.forEach((button) => {
button.addEventListener("mouseenter", (e) => {
updateMousePosition(e);
applyNewBackground();
sectionContent.classList.add("hover");
sectionContent.classList.remove("leave");
});
button.addEventListener("mouseleave", () => {
sectionContent.classList.remove("hover");
sectionContent.classList.add("leave");
});
button.addEventListener("click", (e) => {
updateMousePosition(e);
applyNewBackground();
sectionContent.classList.add("leave");
setTimeout(() => {
resetBackground();
sectionContent.classList.remove("leave");
}, 1500); // Duration of the animation
});
});
});
//Make Let's Talk Smooth Movement
document.addEventListener("DOMContentLoaded", () => {
const buttons = document.querySelectorAll(
".btn-grad.lets-talk, .btn-grad.lets-talk-nav"
);
const contactSection = document.getElementById("contact-section");
buttons.forEach((button) => {
button.addEventListener("click", () => {
contactSection.scrollIntoView({ behavior: "smooth" });
});
});
});
document.querySelector(".click").addEventListener("click", function () {
document.documentElement.classList.add("no-scroll");
document.body.classList.add("no-scroll");
Swal.fire({
html: `
<div class="bgblue">
<div class="card">
<h1><span class="icon2"></span> CODEX61814</h1>
<p>Copyright © 2024. All Rights Reserved.</p>
<div class="custom-button-container">
<button class="custom-button">Exit <i class="bi bi-box-arrow-right"></i></button>
</div>
</div>
</div>
`,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
backdrop: "rgba(0, 0, 0, 0.8)", // Added backdrop property
didClose: () => {
document.documentElement.classList.remove("no-scroll");
document.body.classList.remove("no-scroll");
},
});
document
.querySelector(".custom-button")
.addEventListener("click", function () {
Swal.close();
});
});
// Existing code for dropdown toggle and icon changes
document.querySelectorAll(".scroll-dropdown-header i").forEach((icon) => {
// Click event to toggle the dropdown content and icon
icon.addEventListener("click", () => {
const container = icon.closest(".scroll-dropdown-container");
container.classList.toggle("active");
// Toggle between 'bi-caret-down' and 'bi-caret-down-fill' classes on click
if (container.classList.contains("active")) {
icon.classList.remove("bi-caret-down");
icon.classList.add("bi-caret-down-fill");
} else {
icon.classList.remove("bi-caret-down-fill");
icon.classList.add("bi-caret-down");
}
});
// Mouseover event to change the icon to 'bi-caret-down-fill' on hover
icon.addEventListener("mouseover", () => {
if (!icon.classList.contains("bi-caret-down-fill")) {
icon.classList.add("bi-caret-down-fill");
icon.classList.remove("bi-caret-down");
}
});
// Mouseout event to revert the icon to 'bi-caret-down' if not active
icon.addEventListener("mouseout", () => {
const container = icon.closest(".scroll-dropdown-container");
if (!container.classList.contains("active")) {
icon.classList.remove("bi-caret-down-fill");
icon.classList.add("bi-caret-down");
}
});
});
document.querySelectorAll(".btn-grad.book-now").forEach((button) => {
button.addEventListener("click", () => {
// Locate the target container for scrolling
const container = document.querySelector(".scroll-dropdown-container");
if (container) {
// Smoothly scroll to the container
container.scrollIntoView({ behavior: "smooth" });
// Trigger the icon click event after scrolling
setTimeout(() => {
const icon = container.querySelector(".scroll-dropdown-header i");
if (icon) {
// If the container is already open, close it first
if (container.classList.contains("open")) {
icon.click(); // Close
}
// Open the container after a slight delay
setTimeout(() => {
icon.click(); // Open
}, 100); // Adjust delay for smooth UX
}
}, 500); // Adjust this duration as needed for optimal timing
}
});
});
function disableScroll() {
document.body.style.overflow = "hidden";
document.body.style.position = "fixed";
document.body.style.width = "100%";
}
function enableScroll() {
document.body.style.overflowY = "auto";
document.body.style.overflowX = "hidden";
document.body.style.position = "static";
document.body.style.width = "auto";
}
function showNotification(planTitle = "$199 - STARTUP PLAN") {
const notifContainer = document.getElementById("notif-container");
const notifMain = document.getElementById("notif-main");
const notifTitle = document.querySelector(".notif-title");
notifContainer.classList.add("fade-out");
notifContainer.addEventListener(
"transitionend",
function onFadeOut() {
notifTitle.textContent = planTitle;
notifContainer.classList.remove("fade-out");
notifContainer.classList.add("fade-in");
notifMain.style.display = "block";
notifMain.classList.add("show");
notifContainer.addEventListener(
"transitionend",
() => {
notifContainer.classList.remove("fade-in");
},
{ once: true }
);
notifContainer.removeEventListener("transitionend", onFadeOut);
},
{ once: true }
);
}
function handleCloseNotification() {
const notifMain = document.getElementById("notif-main");
const contactSection = document.querySelector("#contact-section.builder");
disableScroll();
Swal.fire({
title: "Are you sure?",
text: "You won't be able to revert this!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, delete it!",
background: "#29292c",
color: "#fff",
customClass: {
popup: "swal2-dark",
},
padding: "1.5rem",
}).then((result) => {
if (result.isConfirmed) {
Swal.fire({
title: "Deleted!",
text: "Your file has been deleted.",
icon: "success",
background: "#29292c",
color: "#fff",
customClass: {
popup: "swal2-dark",
},
padding: "1.5rem",
confirmButtonColor: "#3085d6",
}).then(() => {
enableScroll();
notifMain.classList.add("fade-out");
notifMain.addEventListener(
"transitionend",
function onClose() {
notifMain.style.display = "none";
notifMain.classList.remove("fade-out", "show");
notifMain.removeEventListener("transitionend", onClose);
},
{ once: true }
);
});
} else {
notifMain.style.display = "block";
notifMain.classList.add("show");
if (contactSection) {
setTimeout(() => {
contactSection.scrollIntoView({ behavior: "smooth" });
enableScroll();
setTimeout(() => {
contactSection.focus();
}, 800);
}, 200);
} else {
console.error(
"Contact section with ID 'contact-section' and class 'builder' not found."
);
}
}
});
}
document.getElementById("show-notif-button-1").addEventListener("click", () => {
showNotification("$199 - STARTUP PLAN");
});
document.getElementById("show-notif-button-2").addEventListener("click", () => {
showNotification("$399 - GROWTH PLAN");
});
document.getElementById("show-notif-button-3").addEventListener("click", () => {
showNotification("$599 - PREMIUM PLAN");
});
document
.getElementById("notif-close-icon")
.addEventListener("click", handleCloseNotification);
document.querySelectorAll(".scroll-button").forEach((button) => {
button.addEventListener("click", () => {
const notifMain = document.getElementById("notif-main");
notifMain.style.display = "block";
notifMain.classList.add("show");
});
});
function showNotification(planTitle = "$199 - STARTUP PLAN") {
const notifContainer = document.getElementById("notif-container");
const notifTitle = document.querySelector(".notif-title");
const contactSection = document.getElementById("contact-section");
contactSection.scrollIntoView({ behavior: "smooth" });
setTimeout(() => {
notifContainer.classList.add("fade-out");
notifContainer.addEventListener(
"transitionend",
function onFadeOut() {
notifTitle.textContent = planTitle;
notifContainer.classList.remove("fade-out");
notifContainer.classList.add("fade-in");
notifContainer.addEventListener(
"transitionend",
() => {
notifContainer.classList.remove("fade-in");
},
{ once: true }
);
notifContainer.removeEventListener("transitionend", onFadeOut);
},
{ once: true }
);
}, 500);
}
document.getElementById("show-notif-button-1").addEventListener("click", () => {
showNotification("$199 - STARTUP PLAN");
});
document.getElementById("show-notif-button-2").addEventListener("click", () => {
showNotification("$399 - GROWTH PLAN");
});
document.getElementById("show-notif-button-3").addEventListener("click", () => {
showNotification("$599 - PREMIUM PLAN");
});
function getSelectedPlan() {
const notifMain = document.getElementById("notif-main");
const subscriptionInput = document.querySelector(
"input[name='subscription']"
);
const notifTitle = document.querySelector(".notif-title");
const selectedPlan =
notifMain && notifMain.classList.contains("show")
? notifTitle.textContent
: "NO PLANS CHOOSED";
subscriptionInput.value = selectedPlan;
return selectedPlan;
}
document
.getElementById("contact-form")
.addEventListener("submit", function (event) {
getSelectedPlan();
setTimeout(() => {
const subscriptionInput = document.querySelector(
"input[name='subscription']"
);
const notifTitle = document.querySelector(".notif-title");
subscriptionInput.value = "NO PLANS CHOOSED";
notifTitle.textContent = "NO PLANS CHOOSED";
const notifMain = document.getElementById("notif-main");
if (notifMain) {
notifMain.classList.remove("show");
notifMain.style.display = "none";
}
}, 300);
});
document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById("contact-form");
const submitButton = form.querySelector(".form-button");
const loader = submitButton.querySelector(".custom-container");
const buttonText = submitButton.querySelector(".button-text");
const notifMain = document.getElementById("notif-main");
// Form submit event listener
form.addEventListener("submit", function (event) {
event.preventDefault(); // Prevent default form submission
// Show loader and hide the button text
loader.style.display = "block";
buttonText.style.display = "none";
// Collect form data using FormData
const formData = new FormData(form);
// Asynchronous form submission using Fetch API
fetch(form.action, {
method: "POST",
body: formData,
})
.then((response) => response.json()) // Parse JSON response
.then((data) => {
console.log("Form submitted successfully:", data);
// Reset the form after successful submission
form.reset();
// Hide notification container if it's visible
if (notifMain && getComputedStyle(notifMain).display !== "none") {
notifMain.style.display = "none";
}
// Show success alert
disableScroll(); // Disable scroll when alert is shown
Swal.fire({
title: "Good job!",
text: "Your message was sent successfully!",
icon: "success",
confirmButtonText: "OK",
background: "#29292c", // Dark background
color: "#fff", // White text
customClass: {
popup: "dark-alert",
title: "dark-alert-title",
confirmButton: "dark-alert-button",
},
backdrop: "rgba(0, 0, 0, 0.8)", // Dark backdrop
padding: "1rem", // Padding around the alert
}).then(() => {
enableScroll(); // Re-enable scroll after the alert
});
})
.catch((error) => {
console.error("Form submission error:", error);
// Show error alert
disableScroll(); // Disable scroll when alert is shown
Swal.fire({
title: "Oops!",
text: "Something went wrong. Please try again later.",
icon: "error",
confirmButtonText: "OK",
background: "#29292c", // Dark background
color: "#fff", // White text
customClass: {
popup: "dark-alert",
title: "dark-alert-title",
confirmButton: "dark-alert-button",
},
backdrop: "rgba(0, 0, 0, 0.8)", // Dark backdrop
padding: "1rem", // Padding around the alert
}).then(() => {
enableScroll(); // Re-enable scroll after the alert
window.location.reload(); // Reload the page
});
})
.finally(() => {
// Always hide the loader and show the button text
loader.style.display = "none";
buttonText.style.display = "block";
});
});
});
const originalFavicon = "./img/favicon.ico";
const grayFavicon = "./img/favicon-gray.ico";
const favicon = document.getElementById("favicon");
// Function to change favicon instantly (for leaving the site)
function changeFaviconInstant(src) {
if (favicon) {
favicon.href = src;
favicon.style.opacity = 1; // Ensure i 6t stays visible without transition delay
}
}
// Function to change favicon with a smooth transition (for entering the site)
function changeFaviconSmooth(src) {
if (favicon) {
favicon.style.opacity = 0; // Fade out quickly
setTimeout(() => {
favicon.href = src;
favicon.style.opacity = 1; // Fade back in
}, 100); // Short fade-out time for faster switch
}
}
// Handle visibility change (switching tabs)
document.addEventListener("visibilitychange", function () {
if (document.visibilityState === "hidden") {
changeFaviconInstant(grayFavicon); // Immediate change when leaving
} else if (document.visibilityState === "visible") {
changeFaviconSmooth(originalFavicon); // Smooth transition when returning
}
});
window.addEventListener("blur", function () {
changeFaviconInstant(grayFavicon);
});
window.addEventListener("focus", function () {
changeFaviconSmooth(originalFavicon);
});