-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
324 lines (277 loc) · 11.8 KB
/
script.js
File metadata and controls
324 lines (277 loc) · 11.8 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
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
"use strict"
const buttonPlatforms = document.querySelector(".button__platforms");
const buttonLanguages = document.querySelector(".button__languages");
const buttonOther = document.querySelector(".button__other");
const technologySliderContainer = document.querySelector(".technology_slider_container");
const technologyOptions = document.querySelector(".technology_options");
let technologyButtons = [buttonPlatforms, buttonLanguages, buttonOther];
const faqChat = document.querySelector(".faq_chat_slider");
const buttonQuestion = document.querySelector(".button__question");
const answers = document.querySelectorAll(".answer");
const buttonBack = document.querySelector(".button__back");
const buttonNext = document.querySelector(".button__next")
const solutionTitle = document.querySelector(".solution_title");
const slider = document.querySelector(".slider_container");
let solutionTitleValues = ["Food Delivery", "Women's Clothing Webstore", "Furniture Constructor"];
const Burger = document.querySelector(".burger_menu");
const BurgerButton = document.querySelector(".button__menu");
const backDrop = document.querySelector(".backdrop");
let burgerTranslateValue = "300";
let burgerButtonClicks = 0;
let translateValue = "1100";
if (document.documentElement.clientWidth < 1348 && document.documentElement.clientWidth > 700) {
translateValue = "640";
}
if (document.documentElement.clientWidth < 700) {
translateValue = "311";
}
const address = document.querySelector("#email");
const emailContainer = document.querySelector(".email_container");
const name = document.querySelector("#name");
const checkbox=document.querySelector("#agree")
const nameContainer = document.querySelector(".name_container");
let timeout=null;
function validate(name, email,checkbox) {
return !!(name && email && checkbox);
}
const label=document.querySelector(".agree_label");
checkbox.addEventListener("click",event=>{
if (!checkbox.checked){
if(!label.classList.contains("wrong")){
label.classList.add("wrong")
checkbox.style.boxShadow="inset 0 0 0 1px rgba(255, 85, 93, 1)";
}
}
else{
if(label.classList.contains("wrong")){
label.classList.remove("wrong")
checkbox.style.boxShadow="unset";
}
}
})
function agree(){
if (!checkbox.checked){
if(!label.classList.contains("wrong")){
label.classList.add("wrong")
checkbox.style.boxShadow="inset 0 0 0 1px rgba(255, 85, 93, 1)";
}
return false;
}
else{
if(label.classList.contains("wrong")){
label.classList.remove("wrong")
checkbox.style.boxShadow="unset";
}
return true;
}
}
function emailValidate() {
let reg = /^([a-z0-9_\.-])+@[a-z0-9-]+\.([a-z]{2,4}\.)?[a-z]{2,4}$/i;
if (!address.value) {
if (emailContainer.classList.contains("wrong_email")) {
emailContainer.classList.remove("wrong_email");
}
emailContainer.classList.add("wrong");
return false;
} else if (!reg.test(address.value)) {
if (emailContainer.classList.contains("wrong")) {
emailContainer.classList.remove("wrong");
}
emailContainer.classList.add("wrong_email");
return false;
} else {
if (emailContainer.classList.contains("wrong")) {
emailContainer.classList.remove("wrong");
} else if (emailContainer.classList.contains("wrong_email")) {
emailContainer.classList.remove("wrong_email");
}
return true;
}
}
function nameValidate() {
if (name.value.trim()) {
if (nameContainer.classList.contains("wrong")) {
nameContainer.classList.remove("wrong");
}
return true;
} else {
if (!nameContainer.classList.contains("wrong")) {
nameContainer.classList.add("wrong");
}
name.value = "";
return false;
}
}
const form = document.querySelector("#contacts_form");
name.addEventListener("input",event=>{
clearTimeout(timeout);
timeout=setTimeout(nameValidate,500)
})
address.addEventListener("input",event=>{
clearTimeout(timeout);
timeout=setTimeout(emailValidate,1000);
})
form.addEventListener("submit", event => {
event.preventDefault();
if (!validate(nameValidate(), emailValidate(),agree())) {
event.returnValue = false;
} else {
address.value = "";
name.value = "";
checkbox.checked=false;
}
})
BurgerButton.addEventListener("click", () => {
BurgerButton.classList.toggle("button__menu_close");
Burger.style.transform = `translateX(0)`;
backDrop.style.display = "block"
burgerButtonClicks++;
if (burgerButtonClicks > 1) {
Burger.style.transform = `translateX(${burgerTranslateValue}px)`;
backDrop.style.display = "none"
burgerButtonClicks = 0;
}
document.addEventListener("click", event => {
let target = event.target;
if (target.className === "backdrop") {
BurgerButton.classList.remove("button__menu_close");
Burger.style.transform = `translateX(${burgerTranslateValue}px)`;
backDrop.style.display = "none";
burgerButtonClicks = 0;
}
})
})
let solutionTitleCurrentValue = 0;
buttonBack.setAttribute("disabled", "disabled");
buttonNext.addEventListener("click", () => {
solutionTitleCurrentValue++;
if (buttonBack.hasAttribute("disabled")) {
buttonBack.removeAttribute("disabled")
}
solutionTitle.textContent = solutionTitleValues[solutionTitleCurrentValue % 3]
slider.style.transform = `translateX(-${translateValue * solutionTitleCurrentValue}px)`
if (solutionTitleCurrentValue === 2) {
buttonNext.setAttribute("disabled", "disabled")
}
})
buttonBack.addEventListener("click", () => {
if (buttonNext.hasAttribute("disabled")) {
buttonNext.removeAttribute("disabled")
}
solutionTitleCurrentValue--;
solutionTitle.textContent = solutionTitleValues[solutionTitleCurrentValue % 3]
if (solutionTitleCurrentValue === 0) {
buttonBack.setAttribute("disabled", "disabled")
slider.style.transform = `translateX(0)`
} else {
slider.style.transform = `translateX(-${translateValue * solutionTitleCurrentValue}px)`
}
})
technologyOptions.addEventListener("click", event => {
const target = event.target;
if (target.tagName === "BUTTON") {
if (target.className === buttonPlatforms.className) {
technologySliderContainer.style.transform = `translateX(0px)`
} else if (target.className === buttonLanguages.className) {
technologySliderContainer.style.transform = `translateX(-${translateValue}px)`;
} else {
technologySliderContainer.style.transform = `translateX(-${translateValue * 2}px)`;
}
for (let i of technologyButtons) {
i.className === target.className ? i.classList.add("underline") : i.classList.remove("underline");
}
}
})
const navList = document.querySelector(".home_page_nav_list");
const servicesSection = document.querySelector("#services");
const aboutUsSection = document.querySelector("#about_us");
const casesSection = document.querySelector("#cases");
const workflowSection = document.querySelector("#workflow");
const ourTeamSection = document.querySelector("#our_team");
const technologySection = document.querySelector("#technology");
const faqSection = document.querySelector("#faq");
const contactUsSection = document.querySelector("#contact_us");
const homePageSection=document.querySelector("#home_page");
const footer=document.querySelector("#footer_menu");
const homePage=document.querySelector("#home_page");
homePageSection.addEventListener("click", event => {
let target = event.target;
if(target.className==="link__mailto"){
event.stopPropagation();
}
else{
event.preventDefault();
}
if (target.classList.contains("services_link")) {
servicesSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "about_us_link") {
aboutUsSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "cases_link") {
casesSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "workflow_link") {
workflowSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "our_team_link") {
ourTeamSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "technology_link") {
technologySection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "faq_link") {
faqSection.scrollIntoView({behavior: "smooth"});
} else if (target.classList.contains("contact_us_link")) {
contactUsSection.scrollIntoView({behavior: "smooth"});
}else if (target.classList.contains("home_page_link")) {
homePage.scrollIntoView({behavior: "smooth"});
}
})
casesSection.addEventListener("click",event=>{
let target = event.target;
if (target.classList.contains("contact_us_link")) {
contactUsSection.scrollIntoView({behavior: "smooth"});
}
})
footer.addEventListener("click", event => {
event.preventDefault();
let target = event.target;
if (target.classList.contains("services_link")) {
servicesSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "about_us_link") {
aboutUsSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "cases_link") {
casesSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "workflow_link") {
workflowSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "our_team_link") {
ourTeamSection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "technology_link") {
technologySection.scrollIntoView({behavior: "smooth"});
} else if (target.className === "faq_link") {
faqSection.scrollIntoView({behavior: "smooth"});
} else if (target.classList.contains("contact_us_link")) {
contactUsSection.scrollIntoView({behavior: "smooth"});
}else if (target.classList.contains("home_page_link")) {
homePage.scrollIntoView({behavior: "smooth"});
}
})
let chatTranslateValue = "88";
let buttonQuestionClicks = 0;
buttonQuestion.addEventListener("click", () => {
faqChat.style.transform = `translateY(-88px)`;
let promise = new Promise(function (resolve, reject) {
setTimeout(() => faqChat.style.transform = `translateY(-188px)`, 300);
resolve(setTimeout(() => {
answers[1].innerHTML = "<p class=\"description\">\n" +
" We provide custom solutions for e-commerce, technologies we use are:\n" +
" </p>\n" +
" <ul>\n" +
" <li><p class=\"dot description\">Taking a sprint with a bunch of tasks into work, our\n" +
" employees\n" +
" implement and test the task,\n" +
" after which we provide a demo to the customer.</p></li>\n" +
" <li><p class=\"dot description\">The client validates the work and agrees on the next set of\n" +
" tasks.</p></li>\n" +
" <li><p class=\"dot description\">Close and continuous execution of tasks brings the product as\n" +
" close as possible to the customer's vision.</p></li>\n" +
" </ul>"
faqChat.style.transform = `translateY(-354px)`
}, 1000))
})
})