1class d{constructor(){const t=document.querySelectorAll("button[data-s-video-toggle]");Array.from(t).forEach((e,i)=>{new a(e,i)})}}class a{constructor(t,e=0){this.options={url:"",container:null,aspectRatio:"auto",hideTrigger:!0,showCloseButton:!0,hideClass:"hidden",toggleContent:"close"},this.videoOpen=!1,this.openContent="",this.trigger=t,this.options.url=t.getAttribute("data-s-video-toggle"),this.options.container=t.hasAttribute("data-s-video-toggle-container")?document.querySelector(t.getAttribute("data-s-video-toggle-container")):t.parentElement,this.options.aspectRatio=t.hasAttribute("data-s-video-toggle-aspect-ratio")?t.getAttribute("data-s-video-toggle-aspect-ratio"):this.options.aspectRatio,this.options.showCloseButton=t.hasAttribute("data-s-video-toggle-show-close-button")?t.getAttribute("data-s-video-toggle-show-close-button")==="true":this.options.showCloseButton,this.options.hideTrigger=t.hasAttribute("data-s-video-toggle-hide-trigger")?t.getAttribute("data-s-video-toggle-hide-trigger")==="true":this.options.hideTrigger,this.options.hideClass=t.hasAttribute("data-s-video-toggle-hide-class")?t.getAttribute("data-s-video-toggle-hide-class"):this.options.hideClass,this.options.toggleContent=t.hasAttribute("data-s-video-toggle-toggle-content")?t.getAttribute("data-s-video-toggle-toggle-content"):this.options.toggleContent,this.videoContent=document.createElement("div"),this.videoContent.classList.add("video-toggle__content"),this.videoContent.classList.add(this.options.hideClass),this.videoContent.id="videoToggleContent"+e,this.videoIFrame=document.createElement("iframe"),this.videoIFrame.classList.add("video-toggle__iframe"),this.videoIFrame.setAttribute("title","Video embed"),this.videoIFrame.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),this.videoIFrame.setAttribute("allowfullscreen",""),this.videoIFrame.setAttribute("width","100%"),this.videoIFrame.setAttribute("height","100%"),this.videoContent.appendChild(this.videoIFrame),this.options.container.appendChild(this.videoContent),this.options.container.classList.add("video-toggle__container"),this.options.showCloseButton&&(this.videoCloseButton=document.createElement("button"),this.videoCloseButton.classList.add("video-toggle__close"),this.videoCloseButton.classList.add(this.options.hideClass),this.videoCloseButton.setAttribute("aria-label","Close video"),this.videoCloseButton.setAttribute("title","Close video"),this.videoCloseButton.addEventListener("click",this.closeVideo.bind(this)),this.options.container.appendChild(this.videoCloseButton)),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls","videoToggleContent"+e),t.addEventListener("click",this.toggleVideo.bind(this))}toggleVideo(t){this.videoOpen?this.closeVideo(t):this.openVideo(t)}clearVideoContainer(){const t=this.options.container.querySelectorAll(".video-toggle__close"),e=this.options.container.querySelectorAll(".video-toggle__content"),i=this.options.container.querySelectorAll(".video-toggle__iframe");Array.from(t).forEach(o=>{o.classList.add(this.options.hideClass)}),Array.from(e).forEach(o=>{o.classList.add(this.options.hideClass)}),Array.from(i).forEach(o=>{o.setAttribute("src","")})}openVideo(t){if(this.clearVideoContainer(),this.trigger.setAttribute("aria-expanded","true"),this.videoContent.classList.remove(this.options.hideClass),this.videoIFrame.setAttribute("src",this.options.url+"?autoplay=1"),this.options.showCloseButton&&this.videoCloseButton.classList.remove(this.options.hideClass),this.options.hideTrigger?this.trigger.classList.add(this.options.hideClass):(this.openContent=this.trigger.innerHTML,this.trigger.innerHTML=this.options.toggleContent),this.options.aspectRatio!=="auto"){const e=this.options.aspectRatio.split(":"),i=parseInt(e[0]),o=parseInt(e[1]),n=this.options.container.offsetWidth*o/i;this.options.container.style.height=n+"px"}this.videoOpen=!0,document.dispatchEvent(new CustomEvent("s:video:open",{detail:this.videoContent}))}closeVideo(t){this.trigger.setAttribute("aria-expanded","false"),this.videoContent.classList.add(this.options.hideClass),this.videoIFrame.setAttribute("src",""),this.options.showCloseButton&&this.videoCloseButton.classList.add(this.options.hideClass),this.options.hideTrigger?this.trigger.classList.remove(this.options.hideClass):this.trigger.innerHTML=this.openContent,this.options.aspectRatio!=="auto"&&(this.options.container.style.height=""),this.videoOpen=!1,document.dispatchEvent(new CustomEvent("s:v
1ideo:close",{detail:this.videoContent}));const e=this.options.container.querySelector("[data-s-video-toggle]");e&&e.classList.remove(this.options.hideClass)}}export{d as default};
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.