Files
cnt-sindikatua/assets/scripts/site.js
2025-07-30 11:26:07 +00:00

32 lines
1.2 KiB
JavaScript

// Modal vídeos
document.addEventListener('DOMContentLoaded', function() {
const videoModal = document.getElementById('videoModal');
const modalIframe = document.getElementById('modalVideoIframe');
const modalTitle = document.getElementById('videoModalLabel');
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