ADD styles & js

This commit is contained in:
2025-07-30 11:26:07 +00:00
parent cd6bac2844
commit 63612a3d3d
2 changed files with 31 additions and 57 deletions

View File

@ -1,61 +1,31 @@
// jQuery( document ).ready( function( $ ) {
// console.log('modal')
// $(document).ready(function () {
// const $videoModal = $('#videoModal');
// const $modalIframe = $('#modalVideoIframe');
// const $modalTitle = $('#videoModalLabel');
// // Cuando se abre el modal
// $videoModal.on('show.bs.modal', function (event) {
// const $button = $(event.relatedTarget);
// const videoUrl = $button.data('video-url');
// const videoTitle = $button.data('video-title');
// const videoAllow = $button.data('video-allow');
// const separator = videoUrl.includes('?') ? '&' : '?';
// const autoplayUrl = videoUrl + separator + 'autoplay=1';
// $modalIframe.attr('src', autoplayUrl);
// $modalIframe.attr('title', videoTitle);
// $modalIframe.attr('allow', videoAllow);
// $modalTitle.text(videoTitle);
// });
// // Cuando se cierra el modal, parar el vídeo
// $videoModal.on('hide.bs.modal', function () {
// $modalIframe.attr('src', '');
// });
// });
// });
console.log('hello')
// Modal vídeos
document.addEventListener('DOMContentLoaded', function() {
const videoModal = document.getElementById('videoModal');
const modalIframe = document.getElementById('modalVideoIframe');
const modalTitle = document.getElementById('videoModalLabel');
// Cuando se abre el modal
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');
// Añadir autoplay al URL si no lo tiene
const separator = videoUrl.includes('?') ? '&' : '?';
const autoplayUrl = videoUrl + separator + 'autoplay=1';
modalIframe.src = autoplayUrl;
modalIframe.title = videoTitle;
modalIframe.allow = videoAllow;
modalTitle.textContent = videoTitle;
});
// Cuando se cierra el modal, parar el vídeo
videoModal.addEventListener('hide.bs.modal', function () {
modalIframe.src = '';
});
});
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