-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha2.js
883 lines (440 loc) · 16.8 KB
/
a2.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
jQuery(function($) {
"use strict";
var _extends =
Object.assign ||
function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
// parallax effect
var parallaxEffect = function parallaxEffect(container, els) {
var moveX, moveY;
if (container && els) {
container.addEventListener("mousemove", function(e) {
moveX = (e.clientX * -1) / 20;
moveY = (e.clientY * -1) / 20;
els.forEach(function(el, index) {
if (index % 2 != 0) {
moveX = -1 * moveX;
moveY = -1 * moveY;
}
el.style.transform = "translate3d(" + moveX + "px," + moveY + "px,0)";
});
});
}
};
// isScrolledIntoView
var isScrolledIntoView = function isScrolledIntoView(el) {
var rect = el.getBoundingClientRect(),
elemTop = rect.top,
elemBottom = rect.bottom,
isVisible;
// Only completely visible elements return true:
isVisible = elemTop >= -50 && elemBottom <= window.innerHeight / 2;
return isVisible;
};
// active class toggle methods
var removeClasses = function removeClasses(nodes, value) {
if (nodes)
return nodes.forEach(function(node) {
return node.classList.contains(value) && node.classList.remove(value);
});
else return false;
};
var addClass = function addClass(nodes, index, value) {
return nodes ? nodes[index].classList.add(value) : 0;
};
var App = {
initHeroSlider: function initHeroSlider() {
// hero slider
var heroSliderOptions = {
dots: false,
arrows: false,
swipe: window.innerWidth <= 576,
responsive: [
{
breakpoint: 576
}
]
};
$(".hero-right-carousel").on("breakpoint", function(
e,
slick,
breakpoint
) {
if (window.innerWidth <= 576)
slick.slickSetOption("swipe", true, false);
else slick.slickSetOption("swipe", false, false);
});
$(".hero-right-carousel").on("swipe", function(slick, dir) {
setTimeout(function() {
$(".hero-left-carousel").slick("slickGoTo", dir.currentSlide);
}, 500);
});
var heroSliderPrev = $(".hero-carousel-navigation-btn.next");
var heroSliderNext = $(".hero-carousel-navigation-btn.prev");
if (heroSliderPrev) {
heroSliderPrev.on("click", function() {
$(".hero-left-carousel").slick("slickNext");
setTimeout(function() {
$(".hero-right-carousel").slick("slickNext");
}, 500);
});
}
if (heroSliderNext) {
heroSliderNext.on("click", function() {
$(".hero-left-carousel").slick("slickPrev");
setTimeout(function() {
$(".hero-right-carousel").slick("slickPrev");
}, 500);
});
}
$(".hero-left-carousel").slick(_extends({}, heroSliderOptions));
$(".hero-right-carousel").slick(_extends({}, heroSliderOptions));
},
initServicesCircle: function initServicesCircle() {
// services circle
var circles = document.querySelectorAll(".inner-circle");
var circleContents = document.querySelectorAll(".circles-content-item");
var parent = document.querySelector(".outer-circle");
if (parent) {
var spreadCircles = function spreadCircles() {
// spread the subcircles around the circle
parent = document
.querySelector(".outer-circle")
.getBoundingClientRect();
var centerX = 0;
var centerY = 0;
Array.from(circles)
.reverse()
.forEach(function(circle, index) {
var angle = index * (360 / circles.length);
var x =
centerX +
(parent.width / 2) * Math.cos((angle * Math.PI) / 180);
var y =
centerY +
(parent.height / 2) * Math.sin((angle * Math.PI) / 180);
circle.style.transform =
"translate3d(" +
parseFloat(x).toFixed(5) +
"px," +
parseFloat(y).toFixed(5) +
"px,0)";
});
};
spreadCircles();
var resizeTimer = void 0;
window.addEventListener("resize", function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
spreadCircles();
}, 50);
});
circles.forEach(function(circle, index) {
var circlesToggleFnc = function circlesToggleFnc() {
var index = circle.dataset.circleIndex;
if (!circle.classList.contains("active")) {
removeClasses(circles, "active");
removeClasses(circleContents, "active");
addClass(circles, index, "active");
addClass(circleContents, index, "active");
}
};
circle.addEventListener("click", circlesToggleFnc, true);
circle.addEventListener("mouseover", circlesToggleFnc, true);
});
}
},
initBlogCarousel: function initBlogCarousel() {
// blog carousel
$(".blog-carousel-wrapper").slick({
centerMode: true,
slidesToShow: 3,
slideToScroll: 1,
variableWidth: true,
arrows: false,
dots: true
});
},
initResponsiveMenu: function initResponsiveMenu() {
// responsive menu
var responsiveMenu = document.querySelector(".responsive-menu");
if (responsiveMenu) {
document.querySelectorAll(".nav-trigger").forEach(function(el) {
return el.addEventListener("click", function() {
if (responsiveMenu.classList.contains("active")) {
responsiveMenu.classList.remove("active");
document.body.classList.remove("no-scroll");
} else {
responsiveMenu.classList.add("active");
document.body.classList.add("no-scroll");
}
});
});
var subLinkToggles = document.querySelectorAll(".sublinks-toggle");
subLinkToggles.forEach(function(el) {
el.addEventListener("click", function() {
var subLinks = el.nextElementSibling;
if (subLinks.classList.contains("submenu-show")) {
subLinks.classList.remove("submenu-show");
el.classList.remove("menu-opened");
} else {
removeClasses(subLinkToggles, "menu-opened");
subLinkToggles.forEach(function(c) {
if (c.nextElementSibling.classList.contains("submenu-show")) {
c.nextElementSibling.classList.remove("submenu-show");
}
});
subLinks.classList.add("submenu-show");
el.classList.add("menu-opened");
}
});
});
}
},
initHomeHeroParallax: function initHomeHeroParallax() {
// homepage hero parallax
var homeHero = document.getElementsByClassName("hero-wrapper")[0];
var homeHerorectangles = document.querySelectorAll(".hero-rectangle");
parallaxEffect(homeHero, homeHerorectangles);
},
initMainHeroParallax: function initMainHeroParallax() {
// main hero parallax
var mainHero = document.getElementsByClassName("main-hero")[0];
var mainHerorectangles = document.querySelectorAll(
".main-hero-rectangle"
);
parallaxEffect(mainHero, mainHerorectangles);
},
initSectionRectangles: function initSectionRectangles() {
// section title rectangles fill effect
var titleRectangles = document.querySelectorAll(".title-rectangle");
if (titleRectangles) {
window.addEventListener("scroll", function(e) {
removeClasses(titleRectangles, "fill");
titleRectangles.forEach(function(rect) {
if (isScrolledIntoView(rect)) rect.classList.add("fill");
});
});
}
},
initContactFormToggle: function initContactFormToggle() {
// contact form toggle
var contactFormBtn = document.getElementsByClassName(
"contact-form-box-pulse"
)[0];
var contactFormWrapper = document.querySelector(".contact-form-box");
if (contactFormBtn && contactFormWrapper) {
contactFormBtn.addEventListener("click", function() {
if (contactFormWrapper.classList.contains("form-active")) {
contactFormWrapper.classList.remove("form-active");
} else {
contactFormWrapper.classList.add("form-active");
window.scroll({
top:
window.pageYOffset +
contactFormWrapper.getBoundingClientRect().top -
30,
behavior: "smooth"
});
}
});
}
},
initBrandVideoToggle: function initBrandVideoToggle() {
// brand video toggle
var brandVideoBtn = document.querySelector(".brand-video-btn");
var brandVideoSection = document.querySelector(".brand-video");
var brandVideoContainer = document.querySelector(".video-container");
var brandVideoOverlay = document.querySelector(".overlay");
var brandVideoClose = document.querySelector(".video-container-close");
if (brandVideoBtn && brandVideoSection && brandVideoContainer) {
brandVideoBtn.addEventListener("click", function() {
var showBrandVideo = function showBrandVideo() {
var video =
brandVideoContainer.querySelector("iframe") ||
brandVideoContainer.querySelector("video source");
video.src = video.dataset.src;
if (video.tagName == "SOURCE")
brandVideoContainer.querySelector("video").load();
document.body.classList.add("no-scroll-video");
brandVideoSection.classList.add("video-opened");
brandVideoOverlay.classList.add("overlay--active");
};
if (!brandVideoSection.classList.contains("video-opened")) {
showBrandVideo();
}
});
brandVideoClose.addEventListener("click", function() {
var hideBrandVideo = function hideBrandVideo() {
var video =
brandVideoContainer.querySelector("iframe") ||
brandVideoContainer.querySelector("video source");
video.src = "";
if (video.tagName == "SOURCE")
brandVideoContainer.querySelector("video").pause();
document.body.classList.remove("no-scroll-video");
brandVideoSection.classList.remove("video-opened");
brandVideoOverlay.classList.remove("overlay--active");
};
if (brandVideoSection.classList.contains("video-opened")) {
hideBrandVideo();
}
});
}
},
initAsideCarousel: function initAsideCarousel() {
// Aside carousel
var asideCarousel = $(".page-aside-carousel");
if (asideCarousel) {
var asideCarouselNavNext = $(".page-aside-carousel-nav.next");
var asideCarouselNavPrev = $(".page-aside-carousel-nav.prev");
$(asideCarousel).slick({
slide: ".page-aside-carousel-item",
slidesToShow: 1,
slideToScroll: 1,
dots: false,
arrows: false,
autoplay: true,
autoplaySpeed: 3000,
zIndex: 1
});
asideCarouselNavNext.on("click", function() {
return asideCarousel.slick("slickNext");
});
asideCarouselNavPrev.on("click", function() {
return asideCarousel.slick("slickPrev");
});
}
},
initTabsNav: function initTabsNav() {
// tabs nav responsive
var tabsToggle = document.querySelectorAll(".mobile-tab-toggle-btn");
var tabsNav = document.querySelector(".nav-tabs-wrapper");
var tabsContent = document.querySelector(".nav.nav-tabs");
if (tabsNav && tabsContent) {
tabsToggle.forEach(function(tabsToggleBtn) {
return tabsToggleBtn.addEventListener("click", function() {
if (tabsContent.classList.contains("show-me"))
tabsContent.classList.remove("show-me");
else tabsContent.classList.add("show-me");
});
});
var links = tabsContent.querySelectorAll(".nav-item.nav-link");
links.forEach(function(link, i) {
link.addEventListener("click", function() {
window.scroll({
top:
window.pageYOffset +
document
.querySelector(".tab-pane.active.show .grid-gallery-wrapper")
.getBoundingClientRect().top -
30,
behavior: "smooth"
});
tabsContent.classList.remove("show-me");
if (i == 0) tabsContent.scrollTop = 0;
else if (i == links.length - 1)
tabsContent.scrollTop =
tabsContent.scrollHeight - tabsContent.clientHeight;
else tabsContent.scrollTop = link.offsetTop - 75;
});
});
}
},
initReferencesCarousel: function initReferencesCarousel() {
//references carousel
var referencesWrapper = $(".references-wrapper");
referencesWrapper.slick({
dots: false,
arrows: false,
autoplay: true,
autoplaySpeed: 3000,
slidesToShow: 1,
slidesToScroll: 1,
mobileFirst: true,
responsive: [
{
breakpoint: 767,
settings: "unslick"
},
{
breakpoint: 576,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
}
]
});
window.addEventListener("resize", function() {
if (window.innerWidth < 768) referencesWrapper.slick("resize");
});
},
truncateBlogListItems: function truncateBlogListItems() {
$(".blog-list-item-description").each(function() {
var textArray = $(this)
.text()
.split(" ");
while ($(this).prop("scrollHeight") > $(this).prop("offsetHeight")) {
textArray.pop();
$(this).text(textArray.join(" ") + "...");
}
});
$(window).on("resize", function() {
truncateBlogListItems();
});
},
contactForm: function() { $('form#contact-us').submit(function() {
$('form#contact-us .error').remove();
var hasError = false;
$('.requiredField').each(function() {
if($.trim($(this).val()) == '') {
var labelText = $(this).prev('label').text();
$(this).parent().append('<span class="error">'+labelText+' This field is required</span>');
$(this).addClass('inputError');
hasError = true;
} else if($(this).hasClass('email')) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(!emailReg.test($.trim($(this).val()))) {
$(this).parent().append('<span class="error"> Please enter a valid email address</span>');
$(this).addClass('inputError');
hasError = true;
}
}
});
if(!hasError) {
var formInput = $(this).serialize();
$.post('contacts.php',formInput, function(data){
$('form#contact-us').slideUp("fast", function() {
$(this).before('<p class="tick"><strong>Thank You! </strong> Your mail has arrived. The return will be made as soon as possible..</p>');
});
});
}
return false;
});
}
};
App.initHeroSlider();
App.initServicesCircle();
App.initBlogCarousel();
App.initResponsiveMenu();
App.initHomeHeroParallax();
App.initMainHeroParallax();
App.initSectionRectangles();
App.initContactFormToggle();
App.initBrandVideoToggle();
App.initAsideCarousel();
App.initTabsNav();
App.initReferencesCarousel();
App.truncateBlogListItems();
App.contactForm();
});