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 */
$(document).ready(function() {
$(document).ready(function() {
     // Ocultar/Mostrar sidebar
     // Manejo del botón "ocultar"
     $('.mw-portlet h3').append(' <span class="toggle-sidebar">(ocultar)</span>');
     $('.mw-portlet h3').append(' <span class="toggle-sidebar">(ocultar)</span>');
     $('.toggle-sidebar').click(function() {
     $('.toggle-sidebar').click(function() {
Línea 8: Línea 7:
     });
     });


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


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

Revisión del 01:30 6 mar 2025

$(document).ready(function() {
    // Manejo del botón "ocultar"
    $('.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)');
    });

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

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