PageSourceSearch

https://www.plantentuinmeise.be/dist/vite/site/js/showcase_video_controller.BfBGM8Ls.js

js plantentuinmeise.be collected 2026-09-24 09:14:00 UTC 5,963 bytes, 2 lines download raw bytes

1import{C as n}from"./site.B0Uxz9u8.js";import"./password-strength.AqUmoxgQ.js";const s=class s extends n{constructor(){super(...arguments),this.player=null,this.isPlaying=!1,this.videoElement=null,this.rewindTimeout=null,this.resizeDebounceTimeout=null,this.isInCarousel=!1,this.shouldBeVisible=!0,this.handleResize=()=>{this.resizeDebounceTimeout!==null&&clearTimeout(this.resizeDebounceTimeout),this.resizeDebounceTimeout=window.setTimeout(()=>{const e=this.checkShouldShowVideo();e!==this.shouldBeVisible?(this.shouldBeVisible=e,e?this.showVideo():this.hideVideo()):this.shouldBeVisible&&this.player&&this.scaleVideo()},150)}}connect(){const e=document.getElementById("showcase")??this.element.parentNode;if(this.isInCarousel=e.querySelector(".carousel--showcase")!==null,this.shouldBeVisible=this.checkShouldShowVideo(),!this.shouldBeVisible){this.element.classList.add("is-hidden"),window.addEventListener("resize",this.handleResize);return}this.videoUrlValue.includes("vimeo")?this.initVimeo():this.initYouTube(),window.addEventListener("resize",this.handleResize),this.updateControlUI()}disconnect(){window.removeEventListener("resize",this.handleResize),this.rewindTimeout!==null&&clearTimeout(this.rewindTimeout),this.resizeDebounceTimeout!==null&&clearTimeout(this.resizeDebounceTimeout)}toggleVideo(){this.player!==null&&(this.videoUrlValue.includes("vimeo")?this.toggleVimeo(this.player):this.toggleYouTube(this.player))}handleKeydown(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.toggleVideo())}pause(){this.player&&(this.videoUrlValue.includes("vimeo")?this.player.pause():this.player.pauseVideo(),this.isPlaying=!1,this.updateControlUI(),this.playerTarget.classList.remove("playing"))}initVimeo(){typeof window.Vimeo>"u"?this.loadVimeoScript(()=>this.createVimeoPlayer()):this.createVimeoPlayer()}loadVimeoScript(e){const i=document.head.querySelector('[src="https://player.vimeo.com/api/player.js"]');if(i){i.addEventListener("load",e);return}const t=document.createElement("script");t.src="https://player.vimeo.com/api/player.js",t.onload=e,document.head.appendChild(t)}getPlayerDimensions(){const e=this.playerTarget.clientWidth,i=Math.round(this.playerTarget.clientWidth/16*9);return{width:e,height:i}}createVimeoPlayer(){this.hasPlaceholderTarget&&this.placeholderTarget.remove(),this.player=new window.Vimeo.Player(this.playerTarget,{...this.getPlayerDimensions(),url:this.videoUrlValue,background:!this.isInCarousel,byline:!1,muted:!0,title:!1,autoplay:!this.isInCarousel,controls:!1});const e=this.player;e.on("play",()=>{this.playerTarget.classList.add("playing"),this.videoElement=this.playerTarget.children[0],this.isPlaying=!0,this.updateControlUI(),this.scaleVideo()}),e.on("pause",()=>{this.isPlaying=!1,this.updateControlUI(),this.hasControlTarget||this.element.remove()}),e.on("error",()=>{this.element.remove()})}initYouTube(){if(!document.head.querySelector('[src="https://www.youtube.com/iframe_api"]')){const i=document.createElement("script");i.src="https://www.youtube.com/iframe_api",document.head.appendChild(i)}this.enqueueYouTubeInit(()=>this.createYouTubePlayer())}enqueueYouTubeInit(e){if(typeof window.YT<"u"&&typeof window.YT.Player<"u"){e();return}const i=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{i!==void 0&&i(),e()}}createYouTubePlayer(){if(!this.hasPlaceholderTarget)return;const e=this.getYouTubeID(this.videoUrlValue);this.player=new window.YT.Player(this.placeholderTarget,{...this.getPlayerDimensions(),videoId:e,events:{onReady:i=>i.target.mute(),onError:()=>this.element.remove(),onStateChange:i=>this.handleYouTubeStateChange(i)},playerVars:{autoplay:this.isInCarousel?0:1,controls:0,iv_load_policy:3,modestbranding:1,playsinline:1,loop:1,playlist:e}})}handleYouTubeStateChange(e){const i=e.target;if(e.data===window.YT.PlayerState.PLAYING){this.rewindTimeout!==null&&clearTimeout(this.rewindTimeout);const t=i.getDuration(),o=i.getCurrentTime();if(Number.isFinite(t)&&t>1&&Number.isFinite(o)){const a=t-o;a>.6&&(this.rewindTimeout=window.setTimeout(()=>i.seekTo(0),(a-.3)*1e3))}this.playerTarget.classList.add("playing"),this.isPlaying=!0,this.updateControlUI(),this.videoElement=this.playerTarget.querySelector("iframe"),this.scaleVideo()}e.data===window.YT.PlayerState.PAUSED&&(this.isPlaying=!1,this.updateControlUI())}toggleVimeo(e){e.getPaused().then(i=>{i?e.play():e.pause()})}toggleYouTube(e){e.getPlayerState()===window.YT.PlayerState.PLAYING?e.pauseVideo():e.playVideo()}updateControlUI(){this.hasControlTarget&&(this.controlTarget.ariaPressed=this.isPlaying?"true":"false",this.hasPlayIconTarget&&this.playIconTarget.classList.toggle("is-hidden",this.isPlaying),this.hasPauseIconTarget&&this.pauseIconTarget.classList.toggle("is-hidden",!this.isPlaying))}scaleVideo(){if(!this.videoElement)return;const e=this.playerTarget.clientWidth/this.playerTarget.clientHeight,i=16/9;if(e>i){const t=this.playerTarget.getBoundingClientRect().width/this.videoElement.clientWidth;this.videoElement.style.transform=`scale(${t})`}else{const t=this.playerTarget.getBoundingClientRect().height/this.videoElement.clientHeight;this.videoElement.style.transform=`scale(${t})`}}getYouTubeID(e){const i=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/,t=e.match(i);return t&&t[2].length===11?t[2]:""}checkShouldShowVideo(){if(this.videoOnMobileValue)return!0;const e=document.getElementById("showcase")??this.element.parentNode,i=e.clientHeight/e.clientWidth;return Number(i.toFixed(1))<.7}showVideo(){this.element.classList.remove("is-hidden"),this.player||(this.videoUrlValue.includes("vimeo")?this.initVimeo():this.initYouTube(),this.updateControlUI())}hideVideo(){this.player&&this.pause(),this.element.classList.add("is-hidden")}};s.targets=["player","placeholder","control","playIcon","pauseIcon"],s.values={videoUrl:String,videoOnMobile:Boolean,pauseL
1abel:String};let l=s;export{l as default};
2//# sourceMappingURL=showcase_video_controller.BfBGM8Ls.js.map

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.