1if (window.NodeList && !NodeList.prototype.forEach) { 2 NodeList.prototype.forEach = Array.prototype.forEach; 3} 4 5if (!String.prototype.includes) { 6 String.prototype.includes = function (search, start) { 7 'use strict'; 8 9 if (search instanceof RegExp) { 10 throw TypeError('first argument must not be a RegExp'); 11 } 12 if (start === undefined) { start = 0; } 13 return this.indexOf(search, start) !== -1; 14 }; 15} 16 17(function ($) { 18 /** 19 * Init the functions. 20 */ 21 function init() { 22 removeEmptyP(); 23 checkFirstSlide(); 24 setupCarousels(); 25 setupButtonRoles(); 26 27 $(document).on('click', '.neuropace-carousel--play-button', playVideo); 28 29 window.addEventListener('resize', function () { 30 var iframe = document.querySelector('.neuropace-video-frame'); 31 if (!iframe) return; 32 $(iframe).height($(iframe).width() * 0.5625); 33 }); 34 } 35 36 function removeEmptyP() { 37 var paragraphs = document.querySelectorAll('.neuropace-carousel p'); 38 if (!paragraphs.length) return; 39 40 paragraphs.forEach(function (p) { 41 if (p.innerHTML) return; 42 p.parentNode.removeChild(p); 43 }); 44 } 45 46 function checkFirstSlide() { 47 var wrappers = document.querySelectorAll('.neuropace-carousel-wrapper'); 48 if (!wrappers.length) return; 49 50 wrappers.forEach(function (wrapper) { 51 var slides = wrapper.querySelectorAll('.neuropace-carousel-item'); 52 if (!slides.length) return; 53 54 var contentButton = slides[0].querySelector('.neuropace-carousel-content-wrapper .neuropace-carousel-button'); 55 56 if (contentButton) { 57 wrapper.classList.add('has-content-button'); 58 } 59 }); 60 } 61 62 function setupButtonRoles() { 63 var buttons = document.querySelectorAll('.neuropace-carousel button'); 64 if (!buttons.length) return; 65 66 buttons.forEach(function (button) { 67 if (!button.getAttribute('role') || 'button' !== button.getAttribute('role')) { 68 button.setAttribute('role', 'button'); 69 } 70 }); 71 } 72 73 /** 74 * Override window._load_script function from Active Campaign script. 75 */ 76 function setupCarousels() { 77 var els = document.querySelectorAll('.neuropace-carousel'); 78 if (!els.length) return; 79
80 els.forEach(function (el) { 81 if (el.firstChild.tagName && 'br' === el.firstChild.tagName.toLowerCase()) { 82 el.removeChild(el.querySelector('br')); 83 } 84 85 var slider = tns({ 86 container: el, 87 items: 1, 88 autoplay: false, 89 loop: false, 90 controlsPosition: 'bottom', 91 controlsText: ["", ""] 92 }); 93 94 slider.events.on('indexChanged', onIndexChanged); 95 }); 96 } 97 98 function onIndexChanged(slider) { 99 var items = slider.container.querySelectorAll('.neuropace-carousel-item'); 100 if (!items.length) return; 101 102 items.forEach(function (item) { 103 var contentButton; 104 var wrapper; 105 106 if (!item.classList.contains('tns-slide-active')) { 107 stopVideo(item); 108 } else { 109 contentButton = item.querySelector('.neuropace-carousel-content-wrapper .neuropace-carousel-button'); 110 wrapper = item.parentNode.parentNode.parentNode.parentNode.parentNode.classList; 111 112 if (contentButton && wrapper) { 113 wrapper.add('has-content-button'); 114 } else { 115 wrapper.remove('has-content-button'); 116 } 117 } 118 }); 119 } 120 121 function playVideo() { 122 var parentNode = this.parentNode.parentNode.parentNode.parentNode; 123 var videoUrl = parentNode.dataset.videoUrl; 124 if (!videoUrl || videoUrl === '') return; 125 126 var iframe = parentNode.querySelector('.neuropace-video-frame'); 127 if (!iframe) return; 128 129 iframe.classList.add('neuropace-carousel-video--is-playing'); 130 iframe.src = videoUrl; 131 } 132 133 function stopVideo(slide) { 134 var iframe = slide.querySelector('.neuropace-video-frame'); 135 if (!iframe) return; 136 137 iframe.classList.remove('neuropace-carousel-video--is-playing'); 138 iframe.src = ''; 139 } 140 141 if (neuropaceCarouselData.isVcEditable) { 142 window.addEventListener('load', function (e) { 143 init(); 144 }); 145 } else { 146 init(); 147 } 148 149})(jQuery);
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.