-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
124 lines (99 loc) · 2.99 KB
/
Copy pathscript.js
File metadata and controls
124 lines (99 loc) · 2.99 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
/* --------------- General Stuff ---------------- */
const header = document.querySelector(".header");
const submit = document.getElementById("contact_form");
const button = document.getElementById("button");
const hamburger = document.querySelector(".hamburger");
const hamburgerMenu = document.querySelector(".hamburger__bg");
const hamburgerLink = document.querySelectorAll(".hamburger__link");
/* --------------- Sticky Navbar ---------------- */
function stickyNavbar() {
header.classList.toggle("scrolled", window.pageYOffset > 0);
}
stickyNavbar();
window.addEventListener("scroll", stickyNavbar);
/* --------------- Hamburger Menu Form ---------------- */
/*
let classList1 = hamburgerMenu.classList;
let classList2 = hamburger.classList;
let classList3 = header.classList;
let listMenu = [...classList1];
let listHambur = [...classList2];
let listHeader = [...classList3];
console.log(listMenu);
function toggleHamburger() {
// let isOpen = false;
if (
listMenu.includes("open") &&
listHambur.includes("open") &&
listHeader.includes("open")
) {
console.log("open");
// isOpen = true;
}
if (isOpen) {
hamburgerMenu.addEventListener("click", () => {
hamburgerMenu.classList.remove("open");
});
}
}
toggleHamburger();
*/
hamburger.addEventListener("click", () => {
hamburgerMenu.classList.toggle("open");
hamburger.classList.toggle("open");
header.classList.toggle("open");
});
hamburgerLink.forEach((hamburgerLink) =>
hamburgerLink.addEventListener("click", () => {
hamburgerMenu.classList.remove("open");
})
);
/* --------------- emailJS Form ---------------- */
button.addEventListener("click", function () {
const fromName = document.getElementById("from_name");
const phoneNum = document.getElementById("phone_num");
const email = document.getElementById("email_id");
let isFormValid = false;
if (
fromName.checkValidity() &&
phoneNum.checkValidity() &&
email.checkValidity()
) {
isFormValid = true;
}
if (isFormValid) {
let params = {
from_name: fromName.value,
phone_num: phoneNum.value,
email_id: email.value,
company_name: document.getElementById("company_name").value,
message: document.getElementById("message").value,
};
emailjs
.send("service_bttgcu6", "template_2i0vj61", params)
.then(function sendEmail() {
const alertMessageEl = document.querySelector(".alert__message");
alertMessageEl.style.display = "block";
setTimeout(() => {
alertMessageEl.style.color = "rgb(61, 61, 61)";
}, 3000);
});
}
});
/* --------------- Image Touch Mechanic ----------------
const galleryImage = document.querySelector(".gallery__item");
if (
function isTouchDevice() {
return (
"ontouchstart" in window ||
navigator.maxTouchPoints > 0 ||
navigator.msMaxTouchPoints > 0
);
}
) {
galleryImage.addEventListener("touchStart", () => {
// galleryImage.classList.add(".touch");
console.log("aaaa");
});
}
*/