item.length > 0);
const videoId = url[url.length – 1];
return `https://www.youtube.com/embed/${videoId}?autoplay=1&mute=0&controls=0&showinfo=0&rel=0&modestbranding=1`;
},
displayModal(event) {
event.preventDefault();
this.link = this.mountYoutubeEmbedURL(event.currentTarget.href);
this.$refs.modal.showModal();
setTimeout(() => {
this.$refs.modal.addEventListener(‘click’, this.backdropClick.bind(this));
}, 0);
},
closeModal() {
this.link = ”;
this.$refs.modal.close();
this.$refs.modal.removeEventListener(‘click’, this.backdropClick);
},
backdropClick(event) {
if (event.target === this.$refs.modal) {
this.closeModal();
}
},
init() {
if(typeof YT_VIDEO_BASE_URL === ‘undefined’) {
return;
}
const videoId = url[url.length – 1];
return `https://www.youtube.com/embed/${videoId}?autoplay=1&mute=0&controls=0&showinfo=0&rel=0&modestbranding=1`;
},
displayModal(event) {
event.preventDefault();
this.link = this.mountYoutubeEmbedURL(event.currentTarget.href);
this.$refs.modal.showModal();
setTimeout(() => {
this.$refs.modal.addEventListener(‘click’, this.backdropClick.bind(this));
}, 0);
},
closeModal() {
this.link = ”;
this.$refs.modal.close();
this.$refs.modal.removeEventListener(‘click’, this.backdropClick);
},
backdropClick(event) {
if (event.target === this.$refs.modal) {
this.closeModal();
}
},
init() {
if(typeof YT_VIDEO_BASE_URL === ‘undefined’) {
return;
}
document.querySelectorAll(`a[href^=’${YT_VIDEO_BASE_URL}’]`).forEach((link) => {
link.addEventListener(‘click’, this.displayModal.bind(this));
});
document.addEventListener(‘keydown’, (event) => {
if (event.key === ‘Escape’ && this.link) {
this.closeModal();
}
});
}
}”
>