1 2document.addEventListener("DOMContentLoaded", function () { 3 const playButtons = document.querySelectorAll(".dw-testi-play-btn"); 4 const modal = document.getElementById("dwTestiVideoModal"); 5 const video = document.getElementById("dwTestiVideoPlayer"); 6 const videoSource = document.getElementById("dwTestiVideoSource"); 7 const closeElements = document.querySelectorAll("[data-dw-testi-video-close]"); 8 9 if (!playButtons.length || !modal || !video || !videoSource) { 10 return; 11 } 12 13 function openVideo(button) { 14 const videoSrc = button.getAttribute("data-video-src"); 15 const videoPoster = button.getAttribute("data-video-poster"); 16 const videoTitle = button.getAttribute("data-video-title") || "Testimonial video"; 17 18 if (!videoSrc) { 19 return; 20 } 21 22 video.pause(); 23 videoSource.setAttribute("src", videoSrc); 24 25 if (videoPoster) { 26 video.setAttribute("poster", videoPoster); 27 } else { 28 video.removeAttribute("poster"); 29 } 30 31 const dialog = modal.querySelector(".dw-testi-video-dialog"); 32 if (dialog) { 33 dialog.setAttribute("aria-label", videoTitle); 34 } 35 36 video.load(); 37 38 modal.classList.add("is-open"); 39 modal.setAttribute("aria-hidden", "false"); 40 document.body.classList.add("dw-testi-video-is-open"); 41 42 setTimeout(function () { 43 const playPromise = video.play(); 44 45 if (playPromise !== undefined) { 46 playPromise.catch(function () { 47 video.controls = true; 48 }); 49 } 50 }, 180); 51 } 52 53 function closeVideo() { 54 video.pause(); 55 video.currentTime = 0; 56 videoSource.setAttribute("src", ""); 57 video.removeAttribute("poster"); 58 video.load(); 59 60 modal.classList.remove("is-open"); 61 modal.setAttribute("aria-hidden", "true"); 62 document.body.classList.remove("dw-testi-video-is-open"); 63 } 64 65 playButtons.forEach(function (button) { 66 button.addEventListener("click", function () { 67 openVideo(button); 68 }); 69 }); 70 71 closeElements.forEach(function (element) { 72 element.addEventListener("click", closeVideo); 73 }); 74 75 document.addEventListener("keydown", function (event) { 76 if (event.key === "Escape" && modal.classList.contains("is-open")) { 77 closeVideo(); 78 } 79 }); 80});
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.