MediaWiki:CollapsibleSections.js
Aller à la navigation
Aller à la recherche
Note : après avoir publié vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
- Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
- Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
- Internet Explorer / Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
- Opera : appuyez sur Ctrl + F5.
/*<nowiki>*/ /************* Class CollapsibleTables.js (c) Till034 <wiki@till034.net> *************/ function CollapsibleSections(){ $("h2:has(span.mw-headline)").each( function(id){ var elem; //if there's no more h2, select everything till printfooter if($(this).nextUntil(".printfooter").find(".mw-headline").length==0){ elem = $(this).nextUntil(".printfooter"); } //else, select everything till next h2 else{ elem = $(this).nextUntil("h2:has(span.mw-headline)"); } //create a section div elem.wrapAll("<div class='mw-section'></div>"); //add toggling link $(this).children().first() .after("<span class='editsection'>[<a href=\"javascript:void(0);\">masquer</a>]</span>"); //listen to click event $("h2:has(span.mw-headline)").eq(id).find("a").eq(1).bind("click", {id: id}, function(event){ $(".mw-section").eq(event.data.id).toggle(); //toggle text if($(this).text()=="masquer"){ $(this).text("afficher"); } else{ $(this).text("masquer"); } }); } ) } /*</nowiki>*/