-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
73 lines (62 loc) · 1.99 KB
/
main.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
//change navbar styles on scroll
window.addEventListener("scroll", () => {
document
.querySelector("nav")
.classList.toggle("window-scroll", window.scrollY > 100);
});
//show or hide faq answer
const faq = document.querySelectorAll(".faq");
faq.forEach((faq) => {
faq.addEventListener("click", () => {
faq.classList.toggle("open");
//change icon
const icon = faq.querySelector(".faq__icon i");
if (icon.className === "uil uil-plus") {
icon.className = "uil uil-minus";
} else {
icon.className = "uil uil-plus";
}
});
});
//show/hide nav menu
const menu = document.querySelector(".nav__menu");
const menuBtn = document.querySelector("#open-menu-btn");
const closeBtn = document.querySelector("#close-menu-btn");
menuBtn.addEventListener("click", () => {
menu.style.display = "flex";
closeBtn.style.display = "inline-block";
menuBtn.style.display = "none";
});
// close nav menu
const closeNav = () => {
menu.style.display = "none";
closeBtn.style.display = "none";
menuBtn.style.display = "inline-block";
};
function formSubmitBtn($event) {
/**
* Checks the validity of the form.
* Return if invalid; HTML5 validation errors should display.
*/
if (!$event.target.form.checkValidity()) {
return;
}
/**
* Form is client-side valid; taking over the remainder of processing.
*/
$event.preventDefault();
grecaptcha.ready(function() {
grecaptcha.execute("6LcYuLkpAAAAAGWDdPvO0UwzXsEsICHqkniMD4-y", { action: 'submit' }).then(function(token) {
/**
* Adds the token g-recaptcha-response token to our hidden form element.
* ** Notice ** we our referencing the specific form's input element by name here (do not use IDs).
*/
$event.target.form.elements['g-recaptcha-response'].value = token;
/**
* Use the form API directly to submit the form.
*/
$event.target.form.submit();
});
});
}
closeBtn.addEventListener("click", closeNav);