Files
cnt-sindikatua/assets/scripts/site.js

61 lines
2.2 KiB
JavaScript
Raw Normal View History

2025-07-25 11:51:47 +00:00
// jQuery( document ).ready( function( $ ) {
// console.log('modal')
2025-07-14 07:33:32 +00:00
2025-07-25 11:51:47 +00:00
// $(document).ready(function () {
// const $videoModal = $('#videoModal');
// const $modalIframe = $('#modalVideoIframe');
// const $modalTitle = $('#videoModalLabel');
2025-07-14 07:33:32 +00:00
2025-07-25 11:51:47 +00:00
// // 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')
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 = '';
});
2025-07-14 07:33:32 +00:00
});