Diferencia entre revisiones de «MediaWiki:Common.js»

De Vanaheim Wiki
Ir a la navegación Ir a la búsqueda
Sin resumen de edición
Move language switcher to server hook
 
(No se muestra una edición intermedia del mismo usuario)
Línea 1: Línea 1:
$(function() {
$( function () {
    // Busca todos los elementos con la clase 'copiar-portapapeles'
$( '.copiar-portapapeles' ).on( 'click', function () {
    $('.copiar-portapapeles').on('click', function() {
var textoACopiar = $( this ).data( 'texto-a-copiar' );
        var textoACopiar = $(this).data('texto-a-copiar');
var $temp = $( '<textarea>' );
       
 
        // Crea un elemento de texto temporal para copiar su contenido
$( 'body' ).append( $temp );
        var $temp = $("<textarea>");
$temp.val( textoACopiar ).select();
        $("body").append($temp);
 
        $temp.val(textoACopiar).select();
try {
       
document.execCommand( 'copy' );
        try {
mw.notify( '¡Texto copiado al portapapeles!', { type: 'success' } );
            document.execCommand("copy");
} catch ( e ) {
            // Muestra una notificación de éxito
mw.notify( 'Error al copiar el texto.', { type: 'error' } );
            mw.notify('¡Texto copiado al portapapeles!', { type: 'success' });
}
        } catch (e) {
 
            mw.notify('Error al copiar el texto.', { type: 'error' });
$temp.remove();
        }
} );
       
} );
        $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();
	} );
} );