1window.addEventListener("DOMContentLoaded", function(e) { 2 3 /* Video blocks */ 4 (function() { 5 6 /* Check click event on every possible video (loaded ) */ 7 document.body.addEventListener('click', function(e) { 8 for (var target = e.target; target && target != this; target = target.parentNode) { 9 if (target.matches('.wpuacf-video')) { 10 set_play_event(target); 11 break; 12 } 13 } 14 }); 15 16 function set_play_event($video) { 17 var $iframe = $video.querySelector('iframe[data-src]'); 18 $iframe.setAttribute('src', $iframe.getAttribute('data-src')); 19 $video.setAttribute('data-is-loading', 1); 20 setTimeout(function() { 21 $video.setAttribute('data-is-playing', 1); 22 }, 500); 23 } 24 }()); 25 26 /* FAQ */ 27 (function() { 28 document.body.addEventListener('click', function(e) { 29 var $wrapper, wasExpanded; 30 for (var target = e.target; target && target != this; target = target.parentNode) { 31 if (target.matches('.wpuacfflexfaq-list__item .field-question[itemprop="name"] button')) { 32 $wrapper = target.closest('.wpuacfflexfaq-list__item'); 33 wasExpanded = (target.getAttribute('aria-expanded') == 'true'); 34 target.setAttribute('aria-expanded', wasExpanded ? 'false' : 'true'); 35 $wrapper.setAttribute('data-is-open', wasExpanded ? 'false' : 'true'); 36 break; 37 } 38 } 39 }); 40 }()); 41 42 /* Force autoplay on mobile videos */ 43 (function() { 44 document.body.addEventListener('touchstart', function() { 45 var $videos = document.querySelectorAll('[data-wpu-acf-video="1"][autoplay]'); 46 for (var i = 0, len = $videos.length; i < len; i++) { 47 if (!$videos[i].playing) { 48 $videos[i].play(); 49 } 50 } 51 }, { 52 once: true 53 }); 54 }()); 55 56 /* Responsive videos & lazy loading */ 57 (function() { 58 var windowWidth = window.innerWidth, 59 $videos = document.querySelectorAll('[data-wpu-acf-video="1"][autoplay]'); 60 61 check_videos_sources(); 62 63 /* Check resize */ 64 window.addEventListener('resize', function() { 65 windowWidth = window.innerWidth; 66 check_videos_sources(); 67 }); 68 69 /* Allow ajax reload */ 70 window.addEventListener('wpu-acf-video-check-sources', function() { 71 $videos = document.querySelectorAll('[data-wpu-acf-video="1"][autoplay]'); 72 check_videos_sources(); 73 }); 74 75 /* Intersect only */ 76 if ("IntersectionObserver" in window) { 77 var lazyVideos = [].slice.call(document.querySelectorAll('[data-wpu-acf-video="1"][data-intersect-only]')); 78 var lazyVideoObserver = new IntersectionObserver(function(entries, observer) { 79 entries.forEach(function(video) { 80 if (video.isIntersecting) { 81 set_query_source(video.target, true); 82 } 83 }); 84 }, { 85 rootMargin: "300px", 86 }); 87 88 lazyVideos.forEach(function(lazyVideo) { 89 lazyVideoObserver.observe(lazyVideo); 90 }); 91 } 92 93 function check_videos_sources() { 94 for (var i = 0, len = $videos.length; i < len; i++) { 95 set_query_source($videos[i], false); 96 } 97 } 98 99 function set_query_source($video, hasIntersect) { 100 var $source = $video.querySelector('source'), 101 currentSrc = $source.getAttribute('src'), 102 dataSrc = $source.getAttribute('data-src'); 103 104 /* Not needed */ 105 if (!dataSrc) { 106 return; 107 } 108 109 /* Source is already ok */ 110 if (currentSrc == dataSrc) { 111 return; 112 } 113 114 /* Intersect only video */ 115 if ($video.getAttribute('data-intersect-only') == '1' && !hasIntersect) { 116 return; 117 } 118 119 /* Mobile only video */ 120 if ($video.getAttribute('data-mobile-only') == '1' && windowWidth > 768) { 121 return; 122 } 123 124 /* Desktop only video */ 125 if ($video.getAttribute('data-desktop-only') == '1' && windowWidth <= 768) { 126 return; 127 } 128 129 /* Set source */ 130 $source.setAttribute('src', dataSrc); 131 $video.load(); 132 $video.play(); 133 } 134 135 }()); 136 137});
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.