Ir al contenido

Diferencia entre revisiones de «MediaWiki:Common.js»

De WikiDerechos
Página creada con «Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página: document.addEventListener("DOMContentLoaded", function() { var items = document.querySelectorAll("#mw-panel .portal > ul > li"); items.forEach(function(item) { item.addEventListener("click", function(event) { var subMenu = this.querySelector("ul"); if (subMenu) { event.preventDefault(); s…»
 
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.addEventListener("DOMContentLoaded", function() {
$(document).ready(function() {
     var items = document.querySelectorAll("#mw-panel .portal > ul > li");
     // Manejo del botón de ocultar/mostrar
    $('.mw-portlet h3').click(function() {
        $(this).next('div').toggle();
    });


     items.forEach(function(item) {
     // Expansión de elementos con ":expand"
         item.addEventListener("click", function(event) {
    $('.mw-portlet li:contains(":expand")').each(function() {
             var subMenu = this.querySelector("ul");
         $(this).html('<span class="toggle">&#9660;</span> ' + $(this).html().replace(':expand ', ''));
            if (subMenu) {
        $(this).click(function() {
                event.preventDefault();
             $(this).children('ul').toggle();
                subMenu.style.display = subMenu.style.display === "block" ? "none" : "block";
            }
         });
         });
     });
     });
});
});

Revisión del 01:25 6 mar 2025

/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */
$(document).ready(function() {
    // Manejo del botón de ocultar/mostrar
    $('.mw-portlet h3').click(function() {
        $(this).next('div').toggle();
    });

    // Expansión de elementos con ":expand"
    $('.mw-portlet li:contains(":expand")').each(function() {
        $(this).html('<span class="toggle">&#9660;</span> ' + $(this).html().replace(':expand ', ''));
        $(this).click(function() {
            $(this).children('ul').toggle();
        });
    });
});