1(function () { 2 'use strict'; 3 4 function initSlider(root) { 5 if (root.dataset.rfp360Ready === '1') { 6 return; 7 } 8 root.dataset.rfp360Ready = '1'; 9 10 var slides = Array.prototype.slice.call(root.querySelectorAll('.rfp360-slide')); 11 var track = root.querySelector('.rfp360-slides-track'); 12 var dots = Array.prototype.slice.call(root.querySelectorAll('.rfp360-dot')); 13 var logos = Array.prototype.slice.call(root.querySelectorAll('.rfp360-logo-item')); 14 var prev = root.querySelector('.rfp360-prev'); 15 var next = root.querySelector('.rfp360-next'); 16 var autoPlay = root.getAttribute('data-autoplay') === '1'; 17 var speed = parseInt(root.getAttribute('data-speed') || '3000', 10); 18 var current = 0; 19 var currentLogo = 0; 20 var timer = null; 21 22 if (!slides.length) { 23 return; 24 } 25 26 function normalize(index) { 27 if (index < 0) return slides.length - 1; 28 if (index >= slides.length) return 0; 29 return index; 30 } 31 32 function normalizeLogo(index) { 33 if (!logos.length) return -1; 34 if (index < 0) return logos.length - 1; 35 if (index >= logos.length) return index % logos.length; 36 return index; 37 } 38 39 function moveActiveLogoIntoView(behavior) { 40 var activeLogo = logos[currentLogo]; 41 var logoTrack = root.querySelector('.rfp360-logo-track'); 42 43 // Do not use Element.scrollIntoView() here. When the slider is below 44 // the fold, scrollIntoView() can move the entire page to the slider 45 // as soon as the plugin initializes. We only need horizontal movement 46 // inside the logo strip, so adjust that container's scroll position. 47 if (!activeLogo || !logoTrack) { 48 return; 49 } 50 51 var targetLeft = activeLogo.offsetLeft - ((logoTrack.clientWidth - activeLogo.offsetWidth) / 2); 52 var maxLeft = Math.max(0, logoTrack.scrollWidth - logoTrack.clientWidth); 53 targetLeft = Math.max(0, Math.min(targetLeft, maxLeft)); 54 55 if (typeof logoTrack.scrollTo === 'function') { 56 logoTrack.scrollTo({ 57 left: targetLeft, 58 top: logoTrack.scrollTop, 59 behavior: behavior || 'smooth' 60 }); 61 } else { 62 logoTrack.scrollLeft = targetLeft; 63 } 64 } 65 66 function show(index, logoIndex) { 67 current = normalize(index); 68 currentLogo = typeof logoIndex === 'number' ? normalizeLogo(logoIndex) : normalizeLogo(current); 69 70 if (track) { 71 track.style.transform = 'translate3d(' + (-current * 100) + '%, 0, 0)'; 72 } 73 74 slides.forEach(function (slide, slideIndex) { 75 var active = slideIndex === current; 76 slide.classList.toggle('is-active', active); 77 slide.setAttribute('aria-hidden', active ? 'false' : 'true'); 78 }); 79 80 dots.forEach(function (dot, dotIndex) { 81 dot.classList.toggle('is-active', dotIndex === current); 82 dot.setAttribute('aria-selected', dotIndex === current ? 'true' : 'false'); 83 }); 84 85 logos.forEach(function (logo, logoIndexLoop) { 86 logo.classList.toggle('is-active', logoIndexLoop === currentLogo); 87 logo.setAttribute('aria-current', logoIndexLoop === currentLogo ? 'true' : 'false'); 88 }); 89 90 moveActiveLogoIntoView('smooth'); 91 } 92 93 function restartAutoplay() { 94 if (timer) window.clearInterval(timer); 95 if (!autoPlay || slides.length < 2) return; 96 timer = window.setInterval(function () { 97 show(current + 1); 98 }, Math.max(speed || 3000, 3000)); 99 } 100 101 function bindClick(el, handler) { 102 if (!el) return; 103 el.addEventListener('click', function () { 104 handler(); 105 restartAutoplay(); 106 }); 107 } 108 109 bindClick(prev, function () { show(current - 1); }); 110 bindClick(next, function () { show(current + 1); }); 111 112 dots.forEach(function (dot) { 113 bindClick(dot, function () { 114 show(parseInt(dot.getAttribute('data-slide-target') || '0', 10)); 115 }); 116 }); 117 118 logos.forEach(function (logo, logoIndex) { 119 bindClick(logo, function () { 120 show(parseInt(logo.getAttribute('data-slide-target') || String(logoIndex), 10), logoIndex); 121 }); 122 }); 123 124 root.addEventListener('mouseenter', function () { 125 if (timer) window.clearInterval(timer); 126 }); 127 root.addEventListener('mouseleave', restartAutoplay); 128 129 show(0, 0); 130 restartAutoplay(); 131 } 132 133 function boot() { 134 document.querySelectorAll('.rfp360-customer-slider').forEach(initSlider); 135 } 136 137 if (document.readyState === 'loading') { 138 document.addEventListener('DOMContentLoaded', boot); 139 } else {
140 boot(); 141 } 142})();
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.