-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.js
109 lines (92 loc) · 3.15 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
// NavBar
const burger = document.querySelector("#burger");
const menu = document.querySelector("#menu");
burger.addEventListener('click', function () {
if (menu.classList.contains('hidden')) {
menu.classList.remove('hidden');
}
else {
menu.classList.add('hidden');
}
})
// Leads
const cards = document.querySelectorAll('.card');
cards.forEach(el => {
el.addEventListener('mouseenter', () => {
const eleInfo = el.querySelector('.card__information');
el.classList.toggle('card--active');
if (!el.classList.contains('card--active'))
eleInfo.classList.toggle('card__information--collapse')
else
setTimeout(() => eleInfo.classList.toggle('card__information--collapse'), 270);
});
});
// Form Submission
// function submitForm(formId) {
// const form = document.getElementById(formId);
// form.addEventListener("submit", function (e) {
// e.preventDefault();
// const data = new FormData(form);
// const action = e.target.action;
// fetch(action, {
// method: 'POST',
// body: data,
// })
// .then(() => {
// // alert("Success!");
// // Display the success popup
// // const successPopup = document.getElementById('successPopup');
// // successPopup.style.display = 'block';
// // // Hide the popup after a delay (e.g., 3 seconds)
// // setTimeout(() => {
// // successPopup.style.display = 'none';
// // }, 3000);
// const successPopup = document.getElementById('successPopup');
// successPopup.style.display = 'flex'; // Use 'flex' to center content vertically
// setTimeout(() => {
// successPopup.style.display = 'none';
// }, 5000);
// })
// .catch(error => {
// console.error('Error!', error.message);
// });
// });
// }
// window.addEventListener("load", function () {
// submitForm('register-form');
// submitForm('contact-form');
// });
function submitForm(formId) {
const form = document.getElementById(formId);
const loadingSpinner = document.getElementById('loadingSpinner');
form.addEventListener("submit", function (e) {
e.preventDefault();
loadingSpinner.classList.remove('hidden'); // Show the loading spinner
const data = new FormData(form);
const action = e.target.action;
fetch(action, {
method: 'POST',
body: data,
})
.then(() => {
// Hide the loading spinner
loadingSpinner.classList.add('hidden');
// Display the success popup
const successPopup = document.getElementById('successPopup');
successPopup.style.display = 'flex'; // Use 'flex' to center content vertically
// Hide the popup after a delay (e.g., 5 seconds)
setTimeout(() => {
successPopup.style.display = 'none';
}, 5000);
})
.catch(error => {
console.error('Error!', error.message);
// Hide the loading spinner on error
loadingSpinner.classList.add('hidden');
});
});
}
window.addEventListener("load", function () {
submitForm('register-form');
submitForm('contact-form');
});