Diferencia entre revisiones de «MediaWiki:Common.js»
Ir a la navegación
Ir a la búsqueda
Sin resumen de edición |
Sin resumen de edición |
||
| Línea 4: | Línea 4: | ||
} | } | ||
// Delegación: capturar clicks en .copy-text aunque se creen luego | |||
$(document).on('click', '.copy-text', function() { | |||
var text = $(this).attr('data-copy'); | var text = $(this).attr('data-copy'); | ||
if (!text) return; | if (!text) return; | ||
Revisión del 18:16 17 jul 2025
$(document).ready(function() {
if ($('#copy-message').length === 0) {
$('body').append('<div id="copy-message" style="position:fixed; bottom:20px; right:20px; background:#4CAF50; color:white; padding:8px 12px; border-radius:4px; display:none; font-weight:bold; z-index:9999;">¡Copiado!</div>');
}
// Delegación: capturar clicks en .copy-text aunque se creen luego
$(document).on('click', '.copy-text', function() {
var text = $(this).attr('data-copy');
if (!text) return;
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => {
$('#copy-message').fadeIn(200).delay(1000).fadeOut(200);
}, () => {
alert('Error al copiar');
});
} else {
var $temp = $('<textarea>');
$('body').append($temp);
$temp.val(text).select();
document.execCommand('copy');
$temp.remove();
$('#copy-message').fadeIn(200).delay(1000).fadeOut(200);
}
});
});