2025-07-25 11:51:47 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
2025-08-07 12:05:32 +00:00
|
|
|
|
|
|
|
// modal videos
|
2025-07-25 11:51:47 +00:00
|
|
|
const videoModal = document.getElementById('videoModal');
|
|
|
|
const modalIframe = document.getElementById('modalVideoIframe');
|
|
|
|
const modalTitle = document.getElementById('videoModalLabel');
|
|
|
|
|
2025-07-30 11:26:07 +00:00
|
|
|
if ( videoModal || modalIframe || modalTitle ) {
|
|
|
|
// when modal open...
|
|
|
|
videoModal.addEventListener('show.bs.modal', function (event) {
|
|
|
|
const button = event.relatedTarget;
|
|
|
|
const videoUrl = button.getAttribute('data-video-url');
|
|
|
|
const videoTitle = button.getAttribute('data-video-title');
|
|
|
|
const videoAllow = button.getAttribute('data-video-allow');
|
|
|
|
|
|
|
|
// Add autoplay to URL
|
|
|
|
const separator = videoUrl.includes('?') ? '&' : '?';
|
|
|
|
const autoplayUrl = videoUrl + separator + 'autoplay=1';
|
|
|
|
|
|
|
|
modalIframe.src = autoplayUrl;
|
|
|
|
modalIframe.title = videoTitle;
|
|
|
|
modalIframe.allow = videoAllow;
|
|
|
|
modalTitle.textContent = videoTitle;
|
|
|
|
});
|
|
|
|
|
|
|
|
// When modal close, video stops.
|
|
|
|
videoModal.addEventListener('hide.bs.modal', function () {
|
|
|
|
modalIframe.src = '';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}); //end DMContentLoaded
|