{% if app.user %}<span class="curso-compartir" data-actividad-id="{{ actividad.id }}" data-actividad-tipo="{{ tipo }}"></span><div id="sharePopup" class="share-popup"><div class="share-popup-content"><span class="share-close">×</span><h3>Compartir curso</h3><div class="share-buttons"><a href="#" class="share-button share-whatsapp" data-share="whatsapp"><i class="fab fa-whatsapp"></i></a><a href="#" class="share-button share-telegram" data-share="telegram"><i class="fab fa-telegram"></i></a><a href="#" class="share-button share-facebook" data-share="facebook"><i class="fab fa-facebook"></i></a><a href="#" class="share-button share-twitter" data-share="twitter"><i class="fab fa-twitter"></i></a><a href="#" class="share-button share-linkedin" data-share="linkedin"><i class="fab fa-linkedin"></i></a><a href="#" class="share-button share-email" data-share="email"><i class="fas fa-envelope"></i></a><a href="#" class="share-button share-copy" data-share="copy"><i class="fas fa-copy"></i></a></div></div></div><script>document.addEventListener('DOMContentLoaded', function() {// Inicializar botón de compartirconst compartirBtn = document.querySelector('.curso-compartir[data-actividad-id="{{ actividad.id }}"][data-actividad-tipo="{{ tipo }}"]');const sharePopup = document.getElementById('sharePopup');const closeBtn = document.querySelector('.share-close');if (compartirBtn) {compartirBtn.addEventListener('click', function(e) {e.preventDefault();sharePopup.style.display = 'block';});}// Cerrar el popup al hacer clic en la Xif (closeBtn) {closeBtn.addEventListener('click', function() {sharePopup.style.display = 'none';});}// Cerrar el popup al hacer clic fuera del contenidowindow.addEventListener('click', function(event) {if (event.target === sharePopup) {sharePopup.style.display = 'none';}});// Funcionalidad de compartirconst shareButtons = document.querySelectorAll('.share-button');const pageUrl = window.location.href;const pageTitle = document.getElementById('course_name').innerText;shareButtons.forEach(button => {button.addEventListener('click', function(e) {e.preventDefault();const shareType = this.getAttribute('data-share');switch(shareType) {case 'whatsapp':window.open(`https://api.whatsapp.com/send?text=${encodeURIComponent(pageTitle + ' ' + pageUrl)}`, '_blank');break;case 'telegram':window.open(`https://t.me/share/url?url=${encodeURIComponent(pageUrl)}&text=${encodeURIComponent(pageTitle)}`, '_blank');break;case 'facebook':window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(pageUrl)}`, '_blank');break;case 'twitter':window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(pageUrl)}&text=${encodeURIComponent(pageTitle)}`, '_blank');break;case 'linkedin':window.open(`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(pageUrl)}`, '_blank');break;case 'email':window.location.href = `mailto:?subject=${encodeURIComponent(pageTitle)}&body=${encodeURIComponent(pageUrl)}`;break;case 'copy':navigator.clipboard.writeText(pageUrl).then(() => {// Mostrar mensaje de éxitoconst copyButton = document.querySelector('.share-copy');const originalIcon = copyButton.innerHTML;copyButton.innerHTML = '<i class="fas fa-check"></i>';setTimeout(() => {copyButton.innerHTML = originalIcon;}, 2000);});break;}});});});</script>{% endif %}