Diferencia entre revisiones de «MediaWiki:Common.js»
Ir a la navegación
Ir a la búsqueda
Página creada con «→Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página: $(document).ready(function() { // Crear el div del mensaje si no existe 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>'); } $('.copy-…» |
Move language switcher to server hook |
||
| (No se muestran 5 ediciones intermedias de 2 usuarios) | |||
| Línea 1: | Línea 1: | ||
$( function () { | |||
$( '.copiar-portapapeles' ).on( 'click', function () { | |||
var textoACopiar = $( this ).data( 'texto-a-copiar' ); | |||
var $temp = $( '<textarea>' ); | |||
$( | $( 'body' ).append( $temp ); | ||
$temp.val( textoACopiar ).select(); | |||
try { | |||
document.execCommand( 'copy' ); | |||
mw.notify( '¡Texto copiado al portapapeles!', { type: 'success' } ); | |||
} catch ( e ) { | |||
mw.notify( 'Error al copiar el texto.', { type: 'error' } ); | |||
} | |||
$temp.remove(); | |||
} ); | |||
} ); | |||
}); | |||
Revisión actual - 15:33 19 may 2026
$( function () {
$( '.copiar-portapapeles' ).on( 'click', function () {
var textoACopiar = $( this ).data( 'texto-a-copiar' );
var $temp = $( '<textarea>' );
$( 'body' ).append( $temp );
$temp.val( textoACopiar ).select();
try {
document.execCommand( 'copy' );
mw.notify( '¡Texto copiado al portapapeles!', { type: 'success' } );
} catch ( e ) {
mw.notify( 'Error al copiar el texto.', { type: 'error' } );
}
$temp.remove();
} );
} );