PageSourceSearch

https://abecgroup.com/wp-content/themes/abec/new-theme/dist/main.js?ver=1791473016

js abecgroup.com collected 2026-10-10 00:25:14 UTC 21,242 bytes, 701 lines download raw bytes

1(function () {
2    function prefersReducedMotion() {
3        return window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
4    }
5
6    function initCaseStudiesSlider(slider) {
7        var track = slider.querySelector('[data-case-slider-track]');
8        var prevButton = slider.parentElement.querySelector('[data-case-slider-prev]');
9        var nextButton = slider.parentElement.querySelector('[data-case-slider-next]');
10
11        if (!track || !prevButton || !nextButton || track.children.length < 2) {
12            return;
13        }
14
15        var isMoving = false;
16        var isDragging = false;
17        var didDrag = false;
18        var pointerId = null;
19        var startX = 0;
20        var currentOffset = 0;
21        var dragThreshold = 48;
22
23        function getGap() {
24            var styles = window.getComputedStyle(track);
25            return parseFloat(styles.columnGap || styles.gap) || 0;
26        }
27
28        function getStep() {
29            var firstCard = track.children[0];
30            return firstCard ? firstCard.getBoundingClientRect().width + getGap() : 0;
31        }
32
33        function resetMotion() {
34            track.style.transition = 'none';
35            track.style.transform = 'translate3d(0, 0, 0)';
36        }
37
38        function unlock() {
39            isMoving = false;
40            isDragging = false;
41            pointerId = null;
42            currentOffset = 0;
43        }
44
45        function finishNext() {
46            track.style.transition = 'none';
47            track.appendChild(track.children[0]);
48            track.style.transform = 'translate3d(0, 0, 0)';
49            track.offsetHeight;
50            unlock();
51        }
52
53        function finishPrev() {
54            track.style.transition = 'none';
55            track.style.transform = 'translate3d(0, 0, 0)';
56            track.offsetHeight;
57            unlock();
58        }
59
60        function moveNext() {
61            if (isMoving) {
62                return;
63            }
64
65            var step = getStep();
66
67            if (!step) {
68                return;
69            }
70
71            isMoving = true;
72            track.style.transition = 'transform 420ms ease';
73            track.style.transform = 'translate3d(-' + step + 'px, 0, 0)';
74
75            track.addEventListener('transitionend', function handleTransitionEnd(event) {
76                if (event.propertyName !== 'transform') {
77                    return;
78                }
79
80                track.removeEventListener('transitionend', handleTransitionEnd);
81                finishNext();
82            });
83        }
84
85        function movePrev() {
86            if (isMoving) {
87                return;
88            }
89
90            var step = getStep();
91            var lastCard = track.children[track.children.length - 1];
92
93            if (!step || !lastCard) {
94                return;
95            }
96
97            isMoving = true;
98            track.style.transition = 'none';
99            track.insertBefore(lastCard, track.children[0]);
100            track.style.transform = 'translate3d(-' + step + 'px, 0, 0)';
101            track.offsetHeight;
102
103            track.style.transition = 'transform 420ms ease';
104            track.style.transform = 'translate3d(0, 0, 0)';
105
106            track.addEventListener('transitionend', function handleTransitionEnd(event) {
107                if (event.propertyName !== 'transform') {
108                    return;
109                }
110
111                track.removeEventListener('transitionend', handleTransitionEnd);
112                finishPrev();
113            });
114        }
115
116        function cancelDrag() {
117            if (isMoving) {
118                return;
119            }
120
121            if (!currentOffset) {
122                resetMotion();
123                unlock();
124                return;
125            }
126
127            isMoving = true;
128            track.style.transition = 'transform 220ms ease';
129            track.style.transform = 'translate3d(0, 0, 0)';
130
131            track.addEventListener('transitionend', function handleTransitionEnd(event) {
132                if (event.propertyName !== 'transform') {
133                    return;
134                }
135
136                track.removeEventListener('transitionend', handleTransitionEnd);
137                resetMotion();
138                unlock();
139            });
140        }
141
142        function completeDraggedNext() {
143            var step = getStep();
144
145            if (!step) {
146                return;
147            }
148
149            isMoving = true;
150            track.style.transition = 'transform 420ms ease';
151            track.style.transform = 'translate3d(-' + step + 'px, 0, 0)';
152
153            track.addEventListener('transitionend', function handleTransitionEnd(event) {
154                if (event.propertyName !== 'transform') {
155                    return;
156                }
157
158                track.removeEventListener('transitionend', handleTransitionEnd);
159                finishNext();
160            });
161        }
162
163        function onPointerDown(event) {
164            if (isMoving || event.button > 0) {
165                return;
166            }
167
168            pointerId = event.pointerId;
169            startX = event.clientX;
170            currentOffset = 0;
171            didDrag = false;
172            isDragging = true;
173            track.style.transition = 'none';
174            slider.setPointerCapture(pointerId);
175        }
176
177        function onPointerMove(event) {
178            if (!isDragging || event.pointerId !== pointerId) {
179                return;
180            }
181
182            var deltaX = event.clientX - startX;
183            didDrag = Math.abs(deltaX) > 4;
184
185            if (deltaX >= 0) {
186                currentOffset = 0;
187                track.style.transform = 'translate3d(0, 0, 0)';
188                return;
189            }
190
191            currentOffset = deltaX;
192            track.style.transform = 'translate3d(' + currentOffset + 'px, 0, 0)';
193        }
194
195        function onPointerUp(event) {
196            if (!isDragging || event.pointerId !== pointerId) {
197                return;
198            }
199
200            if (slider.hasPointerCapture(pointerId)) {
201                slider.releasePointerCapture(pointerId);
202            }
203
204            isDragging = false;
205
206            if (Math.abs(currentOffset) >= dragThreshold) {
207                completeDraggedNext();
208                return;
209            }
210
211            cancelDrag();
212        }
213
214        function preventDraggedClick(event) {
215            if (!didDrag) {
216                return;
217            }
218
219            event.preventDefault();
220            event.stopPropagation();
221            didDrag = false;
222        }
223
224        prevButton.addEventListener('click', movePrev);
225        nextButton.addEventListener('click', moveNext);
226        slider.addEventListener('pointerdown', onPointerDown);
227        slider.addEventListener('pointermove', onPointerMove);
228        slider.addEventListener('pointerup', onPointerUp);
229        slider.addEventListener('pointercancel', onPointerUp);
230        slider.addEventListener('click', preventDraggedClick, true);
231    }
232
233    function initFaqItem(item) {
234        var summary = item.querySelector('.faq__question');
235        var answer = item.querySelector('.faq__answer');
236
237        if (!summary || !answer || item.dataset.faqEnhanced === 'true' || prefersReducedMotion()) {
238            return;
239        }
240
241        item.dataset.faqEnhanced = 'true';
242
243        var isAnimating = false;
244        var duration = 360;
245        var easing = 'cubic-bezier(0.22, 1, 0.36, 1)';
246
247        function clearTransition() {
248            answer.style.transition = '';
249        }
250
251        function setAnswerTransition() {
252            answer.style.transition = 'height ' + duration + 'ms ' + easing + ', opacity ' + duration + 'ms ease';
253        }
254
255        function openItem() {
256            if (isAnimating || item.open) {
257                return;
258            }
259
260            isAnimating = true;
261            item.open = true;
262            answer.style.height = '0px';
263            answer.style.opacity = '0';
264            answer.offsetHeight;
265
266            setAnswerTransition();
267            answer.style.height = answer.scrollHeight + 'px';
268            answer.style.opacity = '1';
269
270            answer.addEventListener('transitionend', function handleOpen(event) {
271                if (event.propertyName !== 'height') {
272                    return;
273                }
274
275                answer.removeEventListener('transitionend', handleOpen);
276                answer.style.height = 'auto';
277                clearTransition();
278                isAnimating = false;
279            });
280        }
281
282        function closeItem() {
283            if (isAnimating || !item.open) {
284                return;
285            }
286
287            isAnimating = true;
288            answer.style.height = answer.offsetHeight + 'px';
289            answer.style.opacity = '1';
290            answer.offsetHeight;
291
292            setAnswerTransition();
293            answer.style.height = '0px';
294            answer.style.opacity = '0';
295
296            answer.addEventListener('transitionend', function handleClose(event) {
297                if (event.propertyName !== 'height') {
298                    return;
299                }
300
301                answer.removeEventListener('transitionend', handleClose);
302                item.open = false;
303                answer.style.height = '';
304                answer.style.opacity = '';
305                clearTransition();
306                isAnimating = false;
307            });
308        }
309
310        summary.addEventListener('click', function (event) {
311            event.preventDefault();
312
313            if (item.open) {
314                closeItem();
315                return;
316            }
317
318            openItem();
319        });
320    }
321
322    function initFaqAnimations() {
323        document.querySelectorAll('.abec-new-template .faq__item').forEach(initFaqItem);
324    }
325
326    function initBlockReveals() {
327        var template = document.querySelector('.abec-new-template');
328        var blocks = document.querySelectorAll('.abec-new-main > .section');
329
330        if (!template || !blocks.length || prefersReducedMotion()) {
331            return;
332        }
333
334        var childSelectors = [
335            '.abec-new-hero__content',
336            '.abec-new-hero__stat',
337            '.trusted-logos-slider__title',
338            '.trusted-logos-slider__intro > *',
339            '.trusted-logos-slider__feature',
340            '.support-stages__title',
341            '.support-stages__card',
342            '.steps-block__title',
343            '.steps-block__step',
344            '.case-studies-slider__header',
345            '.case-studies-slider__card',
346            '.icon-grid__title',
347            '.icon-grid__item',
348            '.text-image__content',
349            '.text-image__media',
350            '.content-icon-block__content',
351            '.content-icon-block__item',
352            '.faq__title',
353            '.faq__item'
354        ].join(',');
355
356        blocks.forEach(function (block) {
357            var children = block.querySelectorAll(childSelectors);
358
359            block.classList.add('abec-new-reveal');
360
361            children.forEach(function (child, index) {
362                child.classList.add('abec-new-reveal-child');
363                child.style.setProperty('--abec-new-reveal-delay', Math.min(index * 70, 420) + 'ms');
364            });
365        });
366
367        template.classList.add('is-animations-ready');
368
369        if (!('IntersectionObserver' in window)) {
370            blocks.forEach(function (block) {
371                block.classList.add('is-visible');
372            });
373            return;
374        }
375
376        var observer = new IntersectionObserver(function (entries) {
377            entries.forEach(function (entry) {
378                if (!entry.isIntersecting) {
379                    return;
380                }
381
382                entry.target.classList.add('is-visible');
383                observer.unobserve(entry.target);
384            });
385        }, {
386            rootMargin: '0px 0px -8% 0px',
387            threshold: 0.12
388        });
389
390        blocks.forEach(function (block) {
391            observer.observe(block);
392        });
393    }
394
395    function initMobileHeaderMenu() {
396        var menu = document.querySelector('[data-abec-mobile-menu]');
397
398        if (!menu || menu.dataset.abecMobileMenuReady === 'true') {
399            return;
400        }
401
402        var toggle = menu.querySelector('[data-abec-mobile-menu-toggle]');
403        var panel = menu.querySelector('[data-abec-mobile-menu-panel]');
404        var header = document.querySelector('.abec-new-header');
405        var scrollY = 0;
406
407        if (!toggle || !panel || !header) {
408            return;
409        }
410
411        menu.dataset.abecMobileMenuReady = 'true';
412
413        function setPanelTop() {
414            var rect = header.getBoundingClientRect();
415            document.documentElement.style.setProperty('--abec-new-mobile-menu-top', Math.max(0, rect.bottom) + 'px');
416        }
417
418        function openMenu() {
419            scrollY = window.pageYOffset || document.documentElement.scrollTop || 0;
420            setPanelTop();
421            menu.classList.add('is-open');
422            document.documentElement.classList.add('abec-new-menu-open');
423            document.body.classList.add('abec-new-menu-open');
424            document.body.style.position = 'fixed';
425            document.body.style.top = '-' + scrollY + 'px';
426            document.body.style.left = '0';
427            document.body.style.right = '0';
428            document.body.style.width = '100%';
429            toggle.setAttribute('aria-expanded', 'true');
430            toggle.setAttribute('aria-label', 'Close menu');
431        }
432
433        function closeMenu() {
434            menu.classList.remove('is-open');
435            document.documentElement.classList.remove('abec-new-menu-open');
436            document.body.classList.remove('abec-new-menu-open');
437            document.body.style.position = '';
438            document.body.style.top = '';
439            document.body.style.left = '';
440            document.body.style.right = '';
441            document.body.style.width = '';
442            window.scrollTo(0, scrollY);
443            toggle.setAttribute('aria-expanded', 'false');
444            toggle.setAttribute('aria-label', 'Open menu');
445        }
446
447        function toggleMenu(event) {
448            event.preventDefault();
449
450            if (menu.classList.contains('is-open')) {
451                closeMenu();
452                return;
453            }
454
455            openMenu();
456        }
457
458        toggle.addEventListener('click', toggleMenu);
459
460        panel.addEventListener('click', function (event) {
461            if (event.target.closest('a')) {
462                closeMenu();
463            }
464        });
465
466        document.addEventListener('keydown', function (event) {
467            if (event.key === 'Escape' && menu.classList.contains('is-open')) {
468                closeMenu();
469                toggle.focus();
470            }
471        });
472
473        window.addEventListener('resize', function () {
474            if (menu.classList.contains('is-open')) {
475                if (window.innerWidth > 1180) {
476                    closeMenu();
477                    return;
478                }
479
480                setPanelTop();
481            }
482        });
483    }
484
485    function initSmoothAnchorScroll() {
486        var activeFrame = null;
487
488        function normalizePath(pathname) {
489            return (pathname || '/').replace(/\/+$/, '') || '/';
490        }
491
492        function getSamePageHash(link) {
493            if (!link.hash || link.hash === '#' || link.hasAttribute('download')) {
494                return '';
495            }
496
497            if (link.target && link.target !== '_self') {
498                return '';
499            }
500
501            var url;
502
503            try {
504                url = new URL(link.href, window.location.href);
505            } catch (error) {
506                return '';
507            }
508
509            if (
510                url.origin !== window.location.origin ||
511                normalizePath(url.pathname) !== normalizePath(window.location.pathname) ||
512                url.search !== window.location.search
513            ) {
514                return '';
515            }
516
517            return url.hash;
518        }
519
520        function getTarget(hash) {
521            if (!hash || hash === '#') {
522                return null;
523            }
524
525            var id = hash.slice(1);
526            var decodedId = id;
527
528            try {
529                decodedId = decodeURIComponent(id);
530            } catch (error) {
531                decodedId = id;
532            }
533
534            return document.getElementById(decodedId) || document.getElementsByName(decodedId)[0] || null;
535        }
536
537        function getHeaderOffset() {
538            var header = document.querySelector('.abec-new-header');
539
540            if (!header) {
541                return 0;
542            }
543
544            var styles = window.getComputedStyle(header);
545
546            if (styles.position !== 'sticky' && styles.position !== 'fixed') {
547                return 0;
548            }
549
550            return Math.ceil(header.getBoundingClientRect().height) + 18;
551        }
552
553        function getTargetY(target) {
554            if (!target) {
555                return 0;
556            }
557
558            return Math.max(0, target.getBoundingClientRect().top + window.pageYOffset - getHeaderOffset());
559        }
560
561        function easeOutCubic(progress) {
562            return 1 - Math.pow(1 - progress, 3);
563        }
564
565        function focusTarget(target) {
566            if (!target || typeof target.focus !== 'function') {
567                return;
568            }
569
570            var hadTabindex = target.hasAttribute('tabindex');
571
572            if (!hadTabindex) {
573                target.setAttribute('tabindex', '-1');
574            }
575
576            target.focus({ preventScroll: true });
577
578            if (!hadTabindex) {
579                target.addEventListener('blur', function restoreTabindex() {
580                    target.removeAttribute('tabindex');
581                }, { once: true });
582            }
583        }
584
585        function animateTo(targetY, target) {
586            var startY = window.pageYOffset || document.documentElement.scrollTop || 0;
587            var distance = targetY - startY;
588            var duration = Math.min(950, Math.max(420, Math.abs(distance) * 0.45));
589            var startTime = null;
590
591            if (activeFrame) {
592                window.cancelAnimationFrame(activeFrame);
593            }
594
595            if (!distance || prefersReducedMotion()) {
596                window.scrollTo(0, targetY);
597                focusTarget(target);
598                return;
599            }
600
601            function tick(timestamp) {
602                if (null === startTime) {
603                    startTime = timestamp;
604                }
605
606                var elapsed = timestamp - startTime;
607                var progress = Math.min(elapsed / duration, 1);
608
609                window.scrollTo(0, startY + distance * easeOutCubic(progress));
610
611                if (progress < 1) {
612                    activeFrame = window.requestAnimationFrame(tick);
613                    return;
614                }
615
616                activeFrame = null;
617                focusTarget(target);
618            }
619
620            activeFrame = window.requestAnimationFrame(tick);
621        }
622
623        function scrollToHash(hash, shouldAnimate) {
624            if ('#top' === hash) {
625                animateTo(0, null);
626                return true;
627            }
628
629            var target = getTarget(hash);
630
631            if (!target) {
632                return false;
633            }
634
635            if (false === shouldAnimate || prefersReducedMotion()) {
636                window.scrollTo(0, getTargetY(target));
637                focusTarget(target);
638                return true;
639            }
640
641            animateTo(getTargetY(target), target);
642            return true;
643        }
644
645        document.addEventListener('click', function (event) {
646            if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
647                return;
648            }
649
650            var eventTarget = event.target;
651
652            if (!eventTarget || typeof eventTarget.closest !== 'function') {
653                return;
654            }
655
656            var link = eventTarget.closest('a[href*="#"]');
657
658            if (!link || link.matches('[data-toggle], [data-bs-toggle]')) {
659                return;
660            }
661
662            var hash = getSamePageHash(link);
663
664            if (!hash) {
665                return;
666            }
667
668            if (!scrollToHash(hash, true)) {
669                return;
670            }
671
672            event.preventDefault();
673
674            if (window.history && window.history.pushState) {
675                window.history.pushState(null, '', hash);
676            } else {
677                window.location.hash = hash;
678            }
679        });
680
681        if (window.location.hash) {
682            window.setTimeout(function () {
683                scrollToHash(window.location.hash, false);
684            }, 120);
685        }
686    }
687
688    function init() {
689        initMobileHeaderMenu();
690        initSmoothAnchorScroll();
691        document.querySelectorAll('.abec-new-template [data-case-slider]').forEach(initCaseStudiesSlider);
692        initFaqAnimations();
693        initBlockReveals();
694    }
695
696    if (document.readyState === 'loading') {
697        document.addEventListener('DOMContentLoaded', init);
698    } else {
699        init();
700    }
701})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.