(function () { function initOneEaelMobileTabSlider(widget) { if (!widget || widget.dataset.mobileSliderReady === 'true') { return; } const tabs = [...widget.querySelectorAll('.eael-tab-item-trigger')]; if (!tabs.length) { return; } widget.dataset.mobileSliderReady = 'true'; widget.classList.add('eael-mobile-tab-slider'); const leftArrowSvg = ` `; const rightArrowSvg = ` `; const controls = document.createElement('div'); controls.className = 'eael-mobile-tab-controls'; controls.innerHTML = `
`; widget.appendChild(controls); const dotsWrap = controls.querySelector('.eael-mobile-tab-dots'); tabs.forEach((tab, index) => { const dot = document.createElement('button'); dot.type = 'button'; dot.className = 'eael-mobile-tab-dot'; dot.setAttribute('aria-label', `Go to ${tab.innerText.trim()}`); dot.addEventListener('click', () => { tabs[index].click(); setTimeout(updateControls, 80); }); dotsWrap.appendChild(dot); }); const dots = [...controls.querySelectorAll('.eael-mobile-tab-dot')]; function getActiveIndex() { const activeIndex = tabs.findIndex(tab => tab.classList.contains('active')); return activeIndex >= 0 ? activeIndex : 0; } function goTo(index) { const safeIndex = (index + tabs.length) % tabs.length; tabs[safeIndex].click(); setTimeout(updateControls, 80); } const swipeArea = widget.querySelector('.eael-tabs-content') || widget; let touchStartX = 0; let touchStartY = 0; let touchEndX = 0; let touchEndY = 0; function isMobileSliderView() { return window.matchMedia('(max-width: 767px)').matches; } swipeArea.addEventListener('touchstart', function (event) { if (!isMobileSliderView()) { return; } if (event.touches.length !== 1) { return; } touchStartX = event.touches[0].clientX; touchStartY = event.touches[0].clientY; }, { passive: true }); swipeArea.addEventListener('touchend', function (event) { if (!isMobileSliderView()) { return; } if (!event.changedTouches.length) { return; } touchEndX = event.changedTouches[0].clientX; touchEndY = event.changedTouches[0].clientY; const diffX = touchStartX - touchEndX; const diffY = touchStartY - touchEndY; const minSwipeDistance = 50; const isHorizontalSwipe = Math.abs(diffX) > Math.abs(diffY); if (!isHorizontalSwipe || Math.abs(diffX) < minSwipeDistance) { return; } if (diffX > 0) { // Swipe left = next tab goTo(getActiveIndex() + 1); } else { // Swipe right = previous tab goTo(getActiveIndex() - 1); } }, { passive: true }); function updateControls() { const activeIndex = getActiveIndex(); dots.forEach((dot, index) => { dot.classList.toggle('is-active', index === activeIndex); }); } controls.querySelector('.eael-mobile-tab-prev').addEventListener('click', () => { goTo(getActiveIndex() - 1); }); controls.querySelector('.eael-mobile-tab-next').addEventListener('click', () => { goTo(getActiveIndex() + 1); }); tabs.forEach(tab => { tab.addEventListener('click', () => { setTimeout(updateControls, 80); }); }); updateControls(); } function initEaelMobileTabSliders() { const widgets = [ ...document.querySelectorAll('.mobile-tabs-slider .eael-advance-tabs'), ...document.querySelectorAll('.eael-advance-tabs.mobile-tabs-slider') ]; widgets.forEach(initOneEaelMobileTabSlider); } document.addEventListener('DOMContentLoaded', initEaelMobileTabSliders); window.addEventListener('load', initEaelMobileTabSliders); if (window.jQuery) { jQuery(window).on('elementor/frontend/init', function () { initEaelMobileTabSliders(); }); } })();