-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
1236 lines (955 loc) · 40 KB
/
scripts.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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// $('.youtube-container').addClass('animate-slide');
var player1;
var player2;
var player3;
function onYouTubeIframeAPIReady() {
player1 = new YT.Player('player1', {
height: '1280',
width: '720',
videoId: 'af8yqwVbaO0',
playerVars: {
controls: 0,
enablejsapi: 1,
modestbranding: 1,
disablekb: 0,
rel: 0, // Disable related videos
iv_load_policy: 3, // Disable annotations
autoplay: 1,
loop: 1,
mute: 1,
start: 4, // Start playing from 0:03
showinfo: 0,
hd: 1, // Enable highest definition
},
events: {
onReady: onPlayer1Ready,
onStateChange: onPlayer1StateChange,
},
});
player2 = new YT.Player('player2', {
height: '1280',
width: '720',
videoId: 'af8yqwVbaO0',
playerVars: {
controls: 0,
enablejsapi: 1,
modestbranding: 1,
disablekb: 0,
rel: 0, // Disable related videos
iv_load_policy: 3, // Disable annotations
autoplay: 1,
loop: 1,
mute: 1,
start: 4, // Start playing from 0:03
showinfo: 0,
hd: 1,
},
events: {
onReady: onPlayer2Ready,
onStateChange: onPlayer2StateChange,
},
});
player3 = new YT.Player('player3', {
height: '1280',
width: '720',
videoId: 'YYM2N4oyS9s',
playerVars: {
controls: 0,
enablejsapi: 1,
modestbranding: 1,
disablekb: 0,
rel: 0, // Disable related videos
iv_load_policy: 3, // Disable annotations
autoplay: 1,
loop: 1,
mute: 1,
start: 4, // Start playing from 0:03
showinfo: 0,
hd: 1, // Enable highest definition
},
events: {
onReady: onPlayer3Ready,
onStateChange: onPlayer3StateChange,
},
});
}
function onPlayer1Ready(event) {
// Set up time intervals for player 1
var intervals = [
{ start: 4, end: 7 },
{ start: 12, end: 15 },
{ start: 96, end: 116 },
];
var currentInterval = 0;
function playNextInterval() {
var interval = intervals[currentInterval];
player1.seekTo(interval.start);
player1.playVideo();
setTimeout(function() {
player1.pauseVideo();
currentInterval = (currentInterval + 1) % intervals.length;
playNextInterval();
}, (interval.end - interval.start) * 1000);
}
// Play the first interval for player 1
playNextInterval();
}
function onPlayer1StateChange(event) {
// Remove overlays when player 1 is paused
if (event.data === YT.PlayerState.PAUSED) {
player1.getOptions('playerVars').modestbranding = 1;
}
}
function onPlayer2Ready(event) {
var intervals = [
// { start: 22, end: 27 },
// { start: 32, end: 34 },
// { start: 40, end: 48 },
// { start: 64, end: 67 },
{ start: 4, end: 7 },
{ start: 12, end: 15 },
{ start: 21.5, end: 27 },
{ start: 41, end: 45 },
];
var currentInterval = 0;
function playNextInterval() {
var interval = intervals[currentInterval];
player2.seekTo(interval.start);
player2.playVideo();
setTimeout(function() {
player2.pauseVideo();
currentInterval = (currentInterval + 1) % intervals.length;
playNextInterval();
}, (interval.end - interval.start) * 1000);
}
// Play the first interval for player 2
playNextInterval();
}
function onPlayer2StateChange(event) {
// Remove overlays when player 2 is paused
if (event.data === YT.PlayerState.PAUSED) {
player2.getOptions('playerVars').modestbranding = 1;
}
}
// player 3
function onPlayer3Ready(event) {
var intervals = [
{ start: 240, end: 255 },
];
var currentInterval = 0;
function playNextInterval() {
var interval = intervals[currentInterval];
player3.seekTo(interval.start);
player3.playVideo();
setTimeout(function() {
player3.pauseVideo();
currentInterval = (currentInterval + 1) % intervals.length;
playNextInterval();
}, (interval.end - interval.start) * 1000);
}
// Play the first interval for player 3
playNextInterval();
}
function onPlayer3StateChange(event) {
// Remove overlays when player 3 is paused
if (event.data === YT.PlayerState.PAUSED) {
player3.getOptions('playerVars').modestbranding = 1;
}
}
// Animate numbers
$(window).scroll(function() {
if ($('.counter-section').length) {
var counterSectionOffset = $('.counter-section').offset().top;
var windowHeight = $(window).height();
var scrollPosition = $(window).scrollTop();
if (scrollPosition > counterSectionOffset - windowHeight + 200) {
// Check if the counters have already animated
if ($('#counter1').text() === '0') {
// Counter animation starts
$('#counter1').prop('Counter', 0).animate({
Counter: 200
}, {
duration: 2000,
easing: 'swing',
step: function(now) {
$(this).text(Math.ceil(now));
// Calculate the percentage of counter progress
var percentage = (now / 200) * 100;
// Set the width of the .counter-fill element accordingly
$('.counter-fill-1').css('width', percentage + '%');
},
complete: function() {
$(this).text('+200'); // Set the final value
$('.counter-fill-1').css('width', '100%'); // Set the width to full
}
});
// Similar animation for the other counters...
$('#counter2').prop('Counter', 0).animate({
Counter: 10000
}, {
duration: 2000,
easing: 'swing',
step: function(now) {
$(this).text(Math.ceil(now));
var percentage = (now / 10000) * 100;
$('.counter-fill-2').css('width', percentage + '%');
},
complete: function() {
$(this).text('+10.000');
$('.counter-fill-2').css('width', '100%');
}
});
var currentYear = new Date().getFullYear();
var years = currentYear - 1975;
$('#counter3').prop('Counter', 0).animate({
Counter: years
}, {
duration: 2000,
easing: 'swing',
step: function(now) {
$(this).text(Math.ceil(now));
var percentage = (now / years) * 100;
$('.counter-fill-3').css('width', percentage + '%');
},
complete: function() {
$(this).text('+' + years);
$('.counter-fill-3').css('width', '100%');
}
});
}
} else {
// Reset counters and width
$('#counter1').text('0').siblings('.counter-fill-1').css('width', '0');
$('#counter2').text('0').siblings('.counter-fill-2').css('width', '0');
$('#counter3').text('0').siblings('.counter-fill-3').css('width', '0');
}
}
});
// Function to debounce the scroll event
function debounce(func, delay) {
let timeout;
return function() {
clearTimeout(timeout);
timeout = setTimeout(func, delay);
};
}
document.addEventListener("DOMContentLoaded", function() {
// Function to handle the scroll event
function handleScroll() {
var footer = $('#footer');
if (footer.length === 0) {
return; // Return if the footer element doesn't exist
}
var footerOffset = footer.offset().top;
var windowHeight = $(window).height();
var scrollPosition = $(window).scrollTop();
if (scrollPosition > footerOffset - windowHeight) {
// User has scrolled to the "footer" div
footer.addClass('slide-right');
footer.css({ opacity: 1 });
} else {
// User has scrolled away from the "footer" div
setTimeout(function() {
footer.css({ opacity: 0 });
footer.removeClass('slide-right');
}, 200); // Wait for 200 milliseconds before removing the class
}
}
// Attach the scroll event listener after the DOM is fully loaded
$(window).on('scroll', debounce(handleScroll, 200));
});
/// PRODUCTS PAGE
$(document).ready(function() {
if ($('#divA').length) {
var divA = $('#divA');
var divB = $('#divB');
var divC = $('#divC');
var btnIndustrias = $('#btnIndustrias');
var btnProductos = $('#btnProductos');
var btnSoluciones = $('#btnSoluciones');
btnIndustrias.on('click', function() {
divB.stop().fadeOut(150, function() {
divC.stop().fadeOut(0);
divA.stop().fadeIn(150);
});
// Toggle active class on buttons
btnIndustrias.addClass('active');
btnProductos.removeClass('active');
btnSoluciones.removeClass('active');
});
btnProductos.on('click', function() {
divA.stop().fadeOut(150, function() {
divC.stop().fadeOut(0);
divB.stop().fadeIn(150);
});
// Toggle active class on buttons
btnIndustrias.removeClass('active');
btnProductos.addClass('active');
btnSoluciones.removeClass('active');
});
btnSoluciones.on('click', function() {
divA.stop().fadeOut(150, function() {
divB.stop().fadeOut(0);
divC.stop().fadeIn(0);
});
// Toggle active class on buttons
btnSoluciones.addClass('active');
btnIndustrias.removeClass('active');
btnProductos.removeClass('active');
});
}
// scroll for mobile
$(window).on('scroll', function() {
if ($('#divA').length) {
var windowHeight = $(window).height();
var scrollTop = $(window).scrollTop();
var viewportTop = scrollTop + windowHeight;
var viewportBottom = scrollTop + windowHeight / 2
$('.list-group, .card, .badge').each(function() {
var elementOffset = $(this).offset().top;
if (elementOffset < viewportTop && elementOffset > viewportBottom) {
$(this).delay(20000).removeClass('touch');
} else {
$(this).delay(20000).addClass('touch');
}
});
}
});
if ($('#divA').length) {
// Preload images
$('.card').each(function() {
var imageSrc = $(this).attr('data');
var img = new Image();
img.src = imageSrc;
});
// Mouseenter event handler
$('.card').on('mouseenter', function() {
var imageSrc = $(this).attr('data');
setTimeout(function() {
$('#productos_img_wrapper').removeClass('hide_this');
$('#productos_img_wrapper').addClass('show_this');
$('#productos_img').attr('src', imageSrc);
}, 500);
});
// Mouseleave event handler
$('.card').on('mouseleave', function() {
setTimeout(function() {
$('#productos_img_wrapper').removeClass('show_this');
$('#productos_img_wrapper').addClass('hide_this');
}, 200);
});
$(window).scroll(function() {
var talkSectionOffset = $('#talk_wrap').offset().top;
var windowHeight = $(window).height();
var scrollPosition = $(window).scrollTop();
var isTalkSectionVisible = $(window).height() + $(window).scrollTop() > $('#talk_wrap').offset().top;
if (isTalkSectionVisible) {
// Disable pointer events for #products
$('#products').css('pointer-events', 'none');
$('#productos_img_wrapper').removeClass('show_this');
$('#productos_img_wrapper').addClass('hide_this');
} else {
// Enable pointer events for #products
$('#products').css('pointer-events', 'all');
}
});
}
// DROPDOWN MENU
// Enable dropdown on mouseover
$(document).on('mouseover', '.nav-item.dropdown', function() {
if (!$("#navbarNav").hasClass('show')) {
$(this).addClass('show');
$(this).children('.dropdown-menu').addClass('show');
}
}).on('mouseout', '.nav-item.dropdown', function() {
if (!$("#navbarNav").hasClass('show')) {
$(this).removeClass('show');
$(this).children('.dropdown-menu').removeClass('show');
}
});
// Disable click event for dropdown toggle
$(document).on('click', '.nav-item.dropdown > .nav-link.dropdown-toggle', function() {
return false;
});
if ($('#industries').length) {
const minPerSlide = $('#industries').length && !$('.no-slide').length ? 6 : 2;
const items = document.querySelectorAll('.carousel .carousel-item');
items.forEach((el) => {
let next = el.nextElementSibling;
for (let i = 1; i < minPerSlide; i++) {
if (!next) {
// wrap carousel by using first child
next = items[0];
}
el.appendChild(next.cloneNode(true).children[0]);
next = next.nextElementSibling;
}
});
}
if ($('#industries').length) {
// BEHAVIOR
// Variable to keep track of .card-link hover
let cardLinkHovered = false;
// Variable to track the click state
let isClicked = false;
// Variable to track if a transition is ongoing
let isTransitioning = false;
// Function to reset all cards
function resetAllCards() {
$(".carousel-item .card").removeClass("hovered clicked");
$(".carousel-item .card-img").show();
$(".carousel-item .card-link").show();
}
// Function to reset the click state after a delay
function resetClickState() {
setTimeout(() => {
isClicked = false;
isTransitioning = false;
}, 500); // Adjust the delay (in milliseconds) as needed
}
// Prevent clicks inside .card from bubbling up
$(".carousel-item .card").click(function(event) {
event.stopPropagation(); // This stops the click from reaching the document
});
// This includes preventing clicks on links within .card from bubbling up
$(".carousel-item .card a").click(function(event) {
event.stopPropagation(); // This ensures link functionality is preserved without triggering resetAllCards
});
// Document-level click listener for resetting cards
$(document).click(function() {
resetAllCards(); // This will only be called if clicks occur outside of .card
});
// Add event listener for mouseenter on carousel items
$(".carousel-item .card").mouseenter(function() {
if (!isClicked && !isTransitioning) {
resetAllCards();
$(this).addClass("hovered");
$(this).find(".card-link a").addClass("trigger");
// Set a timeout to trigger a click after 1.5 seconds
hoverTimeout = setTimeout(() => {
if (!isClicked && !isTransitioning) {
$(this).click(); // Simulate a click
}
}, 850);
}
}).mouseleave(function() {
clearTimeout(hoverTimeout);
if (!isClicked && !isTransitioning) {
$(this).find(".card-link a").removeClass("trigger");
setTimeout(() => {
$(this).find(".card-img").show();
}, 180);
setTimeout(() => {
$(".carousel-item .card").removeClass("clicked");
}, 230);
setTimeout(() => {
$(this).find(".card-link").show();
}, 300);
$(this).removeClass("hovered");
}
if (!$(this).hasClass("clicked")) {
$(".carousel-item .card-img").show();
}
$(".carousel-item .card-link").show();
});
// Add click event handler for carousel items
$(".carousel-item .card").click(function() {
if (!isClicked && !isTransitioning) {
isClicked = true;
isTransitioning = true;
$(".carousel-item .card-img").show();
$(".carousel-item .card-link").show();
setTimeout(() => {
if ($(this).hasClass("clicked")) {
$(this).find(".card-img").hide();
$(this).find(".card-link").hide();
isTransitioning = false;
}
}, 100);
$(".carousel-item .card").removeClass("clicked");
$(this).addClass("clicked");
resetClickState();
}
});
// Event listener for .card-link mouseover
$(".card-link a").mouseover(function() {
if (isClicked) {
// Prevent triggering the mouseover if clicked
return;
}
cardLinkHovered = true;
});
// Check for any card with the class "hovered"
// If found, reset all cards
setInterval(function() {
if ($(".carousel-item .card.hovered").length > 0) {
resetAllCards();
}
}, 100);
// Handler to reset card state if mouse hovers over carousel control arrows
$(".carousel-control-prev, .carousel-control-next").mouseenter(function () {
resetAllCards();
});
if ($('#talk_img_back').length) {
const $backgroundImage = $("#talk_img_back");
let isAnimationDone = false;
function resetAnimation() {
isAnimationDone = false;
$backgroundImage.css("left", "-100%");
}
function animateBackgroundImage() {
if (!isAnimationDone && $(window).scrollTop() > 0) { // Check if the user has scrolled down
$backgroundImage.css("left", "0"); /* Slide the image to the left */
isAnimationDone = true;
}
}
$(window).scroll(function () {
if ($(window).scrollTop() === 0) {
resetAnimation();
} else {
animateBackgroundImage();
}
});
}
}
let isAnimating = false;
// Function to start the animation when the page loads
function startAnimation() {
if (isAnimating) return;
isAnimating = true;
var overlay = $('#transition-overlay');
var content = $('#content');
var logo = $('#logo');
if (!overlay.hasClass('transition-overlay-internal')) {
logo.fadeIn('fast');
}
content.addClass('visible');
logo.addClass('anima');
setTimeout(function() {
logo.fadeOut('fast', function() {
overlay.removeClass('transition-overlay-on');
overlay.addClass('transition-overlay-off');
$("#full-content").show();
$('body').removeClass("main");
// Add the "fade-up" class to elements with the class "#hero__content .translate"
$("#hero__content .translate").addClass("fade-up");
});
}, 1000);
}
// Call the startAnimation function after a certain delay (adjust as needed)
setTimeout(startAnimation, 400);
// Event delegation for navbar link clicks
$(document).on("click", ".navbar a", function(event) {
// Check if the link is under #industriesDropdown
if ($(this).closest("#industriesDropdown").length === 0) {
// Prevent the default link action
event.preventDefault();
// Store the href in a variable
var linkHref = event.currentTarget.href;
// Change the class of "transition-overlay" to "transition-overlay-on"
$("#transition-overlay").removeClass("transition-overlay-off").addClass("transition-overlay-on");
$("#transition-overlay").addClass("transition-overlay-internal");
// Delay for 0.5 seconds (500 milliseconds) and then continue with the link action
setTimeout(function() {
window.location.href = linkHref;
}, 500);
}
});
if ($('.image-ticker').length) {
window.onload = function(){
var windowWidth = window.innerWidth;
var elementWidth = 290;
var numElToAppend = Math.ceil(windowWidth/elementWidth) * 1;
var parentElSelector = '.image-ticker ul';
var elSelector = 'li';
var parentEl = document.querySelector(parentElSelector);
var itemEls = parentEl.querySelectorAll(elSelector);
if(numElToAppend > itemEls.length){
var numElToAppendFraction = numElToAppend/itemEls.length;
var fullRepeat = ~~numElToAppendFraction;
var partialRepeat = Math.ceil((numElToAppendFraction-fullRepeat)*10);
}
for(var i = 0; i < fullRepeat; i++){
for(var j = 0; j<itemEls.length;j++){
parentEl.appendChild(itemEls[j].cloneNode(true));
}
}
var itemsToAppend = Array.prototype.slice.call(itemEls, 0, partialRepeat);
for(var i = 0; i< itemsToAppend.length; i++){
// console.log(itemsToAppend[i]);
parentEl.appendChild(itemsToAppend[i].cloneNode(true));
}
}
}
$(window).on("scroll", function() {
if ($('.slide-up').length) {
$(".slide-up").each(function(index) {
const slideDiv = $(this);
const scrollPosition = $(window).scrollTop();
const elementPosition = $(this).offset().top;
if (elementPosition - scrollPosition < $(window).height()) {
slideDiv.addClass("active");
} else {
slideDiv.removeClass("active");
}
});
}
if ($('.slide-right').length) {
$(".slide-right").each(function(index) {
const slideDiv = $(this);
const scrollPosition = $(window).scrollTop();
const elementPosition = $(this).offset().top;
if (elementPosition - scrollPosition < $(window).height()) {
setTimeout(() => {
slideDiv.addClass("active");
}, 700);
} else {
slideDiv.removeClass("active");
}
});
}
if ($('.slide-left').length) {
$(".slide-left").each(function(index) {
const slideDiv = $(this);
const scrollPosition = $(window).scrollTop();
const elementPosition = $(this).offset().top;
if (elementPosition - scrollPosition < $(window).height()) {
setTimeout(() => {
slideDiv.addClass("active");
}, 700);
} else {
slideDiv.removeClass("active");
}
});
}
if ($('.image-container').length) {
$(".image-container").each(function(index) {
const slideImage = $(this).find("img");
const scrollPosition = $(window).scrollTop();
const elementPosition = $(this).offset().top;
if (elementPosition - scrollPosition < $(window).height()) {
slideImage.addClass("active");
} else {
slideImage.removeClass("active");
}
});
}
});
// /// MENU ITEM INCLUDE + CURRENT
// function addCurrentClassToMenuItem(currentPageId) {
// $('#navbarNav .nav-item').find('[data-key="' + currentPageId + '"]').parent().addClass('current');
// $('#navbarNav .nav-item').find('[data-key="' + currentPageId + '"]').addClass('current');
// if (currentPageClass) {
// $('.dropdown-item[data-key="' + currentPageClass + '"]').addClass('current-link');
// }
// }
// // Get the current page ID
// var currentPageId = $('body').attr('id');
// var currentPageClass = $('body').attr('class'); // Assuming only one class
// // Add "current" class to menu items for the initial page load
// addCurrentClassToMenuItem(currentPageId,currentPageClass);
// // Load menu content dynamically and add "current" class after loading
// if ($('.include').length) {
// fetch("./includes/menu_top.html")
// .then(response => {
// return response.text();
// })
// .then(data => {
// document.querySelector(".menu_top").innerHTML = data;
// // Call the function to add "current" class to the dynamically loaded menu item
// addCurrentClassToMenuItem(currentPageId);
// });
// }
// Get the current page ID
var currentPageId = $('body').attr('id');
var currentPageClass = $('body').attr('class'); // Assuming only one class
// Add "current" class to menu items for the initial page load
addCurrentClassToMenuItem(currentPageId, currentPageClass);
function addCurrentClassToMenuItem(currentPageId, currentPageClass) {
$('#navbarNav .nav-item').find('[data-key="' + currentPageId + '"]').parent().addClass('current');
$('#navbarNav .nav-item').find('[data-key="' + currentPageId + '"]').addClass('current');
// Add "current" class to footer menu item
$('#footer .navbar-nav .nav-item').find('[data-key="' + currentPageId + '"]').addClass('current');
setTimeout(() => {
$('#footer .navbar-nav .nav-item').find('[data-key="' + currentPageId + '"]').addClass('current');
}, 500);
if (currentPageClass) {
$('.dropdown-item[data-key="' + currentPageClass + '"]').addClass('current-link');
$('#footer .dropdown-item[data-key="' + currentPageClass + '"]').addClass('current-link');
} else {
// console.log("no current page class");
}
}
// Load menu content dynamically and add "current" class after loading
if ($('.include').length) {
fetch("./includes/menu_top.html")
.then(response => {
return response.text();
})
.then(data => {
document.querySelector(".menu_top").innerHTML = data;
// Call the function to add "current" class to the dynamically loaded menu item
addCurrentClassToMenuItem(currentPageId, currentPageClass);
document.querySelector(".form-check-input").addEventListener("change", function() {
var isChecked = $(this).prop('checked');
var language = isChecked ? 'en' : 'es'; // Toggle between 'en' and 'es'
loadLanguageFile(language);
});
});
}
// Check if the footer element exists
var footerElement = document.querySelector(".footer");
if (footerElement) {
// If the footer element exists, proceed with fetching and adding content
if ($('.include').length) {
fetch("./includes/footer.html")
.then(response => {
return response.text();
})
.then(data => {
// Update the footer content
footerElement.innerHTML = data;
addCurrentClassToMenuItem(currentPageId, currentPageClass);
// console.log(currentPageId);
});
}
} else {
console.error("Footer element with class 'footer' not found.");
}
$(".navbar-toggler").click(function() {
$("#navbarNav").toggleClass("show");
$(".dropdown-menu").toggleClass("show");
$(this).toggleClass("showing");
$(".menu_top").removeClass("slide-out_2");
$("#navbarNav.show .dropdown-menu").removeClass("slide-in_2");
$(".menu_top").removeClass("slide-out");
$("#navbarNav.show .dropdown-menu").removeClass("slide-in");
if ($("#navbarNav").hasClass("show")) {
$("#industriesDropdown").on("click", function(event) {
$(".menu_top").removeClass("slide-out_2");
$("#navbarNav.show .dropdown-menu").removeClass("slide-in_2");
$(".menu_top").addClass("slide-out");
$("#navbarNav.show .dropdown-menu").addClass("slide-in");
event.preventDefault();
});
$("#back").on("click", function(event) {
$(".menu_top").removeClass("slide-out");
$("#navbarNav.show .dropdown-menu").removeClass("slide-in");
$(".menu_top").addClass("slide-out_2");
$("#navbarNav.show .dropdown-menu").addClass("slide-in_2");
event.preventDefault();
});
}
});
if ($('.parallax-container').length) {
// We define the parallax text
const $parallaxText = $(".parallax-text");
// on scroll we show the parallax
$(window).on("scroll", function() {
const scrollY = $(window).scrollTop();
const translateY = scrollY * -0.3; // Adjust the speed here
$parallaxText.css("transform", `translateY(${translateY}px)`);
});
setTimeout(() => {
$('.parallax-text h1').addClass('active');
$('.parallax-text p').addClass('active');
}, 2200);
}
if ($('#block__about_wrapper').length) {
const $images = $('.image');
let currentIndex = 0;
let isAnimating = false; // Flag to track animation state
function showImage(index) {
$images.eq(index).addClass('visible').removeClass('hidden');
}
function hideImage(index) {
$images.eq(index).addClass('hidden').removeClass('visible');
}
function changeImage(direction) {
if (isAnimating) return;
isAnimating = true;
hideImage(currentIndex);
if (direction === 'next') {
currentIndex = (currentIndex + 1) % $images.length;
} else if (direction === 'prev') {
currentIndex = (currentIndex - 1 + $images.length) % $images.length;
}
showImage(currentIndex);
setTimeout(function () {