Ir al contenido

Diferencia entre revisiones de «MediaWiki:Common.js»

De WikiDerechos
Sin resumen de edición
Sin resumen de edición
Línea 1: Línea 1:
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */
$(document).ready(function() {
$(document).ready(function() {
     // Manejo del botón de ocultar/mostrar
     // Ocultar/Mostrar sidebar
     $('.mw-portlet h3').click(function() {
     $('.mw-portlet h3').append(' <span class="toggle-sidebar">(ocultar)</span>');
         $(this).next('div').toggle();
    $('.toggle-sidebar').click(function() {
         $(this).parent().next('div').toggle();
        $(this).text($(this).text() === '(ocultar)' ? '(mostrar)' : '(ocultar)');
     });
     });


     // Expansión de elementos con ":expand"
     // Agregar funcionalidad de expandir/colapsar
     $('.mw-portlet li:contains(":expand")').each(function() {
     $('.mw-portlet li:contains(":expand")').each(function() {
         $(this).html('<span class="toggle">&#9660;</span> ' + $(this).html().replace(':expand ', ''));
         var $this = $(this);
         $(this).click(function() {
        $this.html('<span class="toggle">&#9660;</span> ' + $this.html().replace(':expand ', ''));
             $(this).children('ul').toggle();
         $this.children('.toggle').click(function() {
             $(this).parent().nextAll().toggle();
            $(this).text($(this).text() === '▼' ? '▶' : '▼');
         });
         });
     });
     });
    // Ocultar subniveles al inicio
    $('.mw-portlet li:contains(":expand")').nextAll().hide();
});
});

Revisión del 01:28 6 mar 2025

/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */
$(document).ready(function() {
    // Ocultar/Mostrar sidebar
    $('.mw-portlet h3').append(' <span class="toggle-sidebar">(ocultar)</span>');
    $('.toggle-sidebar').click(function() {
        $(this).parent().next('div').toggle();
        $(this).text($(this).text() === '(ocultar)' ? '(mostrar)' : '(ocultar)');
    });

    // Agregar funcionalidad de expandir/colapsar
    $('.mw-portlet li:contains(":expand")').each(function() {
        var $this = $(this);
        $this.html('<span class="toggle">&#9660;</span> ' + $this.html().replace(':expand ', ''));
        $this.children('.toggle').click(function() {
            $(this).parent().nextAll().toggle();
            $(this).text($(this).text() === '▼' ? '▶' : '▼');
        });
    });

    // Ocultar subniveles al inicio
    $('.mw-portlet li:contains(":expand")').nextAll().hide();
});