Ir al contenido

MediaWiki:Common.js

De WikiDerechos

Nota: Después de publicar, quizás necesite actualizar la caché de su navegador para ver los cambios.

  • Firefox/Safari: Mantenga presionada la tecla Shift mientras pulsa el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
  • Google Chrome: presione Ctrl+Shift+R (⌘+Shift+R en Mac)
  • Edge: mantenga presionada Ctrl mientras pulsa Actualizar, o presione Ctrl+F5
$(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();
});