« MediaWiki:Common.js » : différence entre les versions

De Wiki Out Of Mana
Aller à la navigation Aller à la recherche
Contenu remplacé par « console.log("Common.js chargé 2 !"); document.addEventListener("DOMContentLoaded", function () { console.log("Script des menus déroulants chargé !"); document.querySelectorAll(".menu-deroulant-titre").forEach(button => { button.addEventListener("click", function () { let target = this.nextElementSibling; if (target && target.classList.contains("menu-deroulant-contenu")) { target.style.display = (tar... »
Balise : Contenu remplacé
Aucun résumé des modifications
 
(4 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
console.log("Common.js chargé 2 !");
mw.hook('wikipage.content').add(function ($content) {
 
document.addEventListener("DOMContentLoaded", function () {
     console.log("Script des menus déroulants chargé !");
     console.log("Script des menus déroulants chargé !");
      
      
     document.querySelectorAll(".menu-deroulant-titre").forEach(button => {
     $content.find(".menu-deroulant-titre").each(function () {
         button.addEventListener("click", function () {
         $(this).on("click", function () {
             let target = this.nextElementSibling;
             var $target = $(this).next(".menu-deroulant-contenu");
            if (target && target.classList.contains("menu-deroulant-contenu")) {
            if ($target.length) {
                 target.style.display = (target.style.display === "none" || target.style.display === "") ? "block" : "none";
                 $target.slideToggle(); // Animation fluide
                 this.classList.toggle("menu-ouvert");
                 $(this).toggleClass("menu-ouvert");
             }
             }
         });
         });
     });
     });
});
});

Dernière version du 14 mars 2025 à 01:02

mw.hook('wikipage.content').add(function ($content) {
    console.log("Script des menus déroulants chargé !");
    
    $content.find(".menu-deroulant-titre").each(function () {
        $(this).on("click", function () {
            var $target = $(this).next(".menu-deroulant-contenu");
            if ($target.length) {
                $target.slideToggle(); // Animation fluide
                $(this).toggleClass("menu-ouvert");
            }
        });
    });
});