X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fmediawiki.toc.js;h=5e10a5be5a678a2b6f004ec6231acd564075188e;hb=dd54a41166d697185048e1beb9d407003c8e39a6;hp=0955c23f067b260cb2f06b2affb37c74bc694ca7;hpb=2c8f7978df47f338ee6e245e3efba6175ba425e9;p=lhc%2Fweb%2Fwiklou.git
diff --git a/resources/src/mediawiki/mediawiki.toc.js b/resources/src/mediawiki/mediawiki.toc.js
index 0955c23f06..5e10a5be5a 100644
--- a/resources/src/mediawiki/mediawiki.toc.js
+++ b/resources/src/mediawiki/mediawiki.toc.js
@@ -3,56 +3,58 @@
// Table of contents toggle
mw.hook( 'wikipage.content' ).add( function ( $content ) {
- var $toc, $tocTitle, $tocToggleLink, $tocList, hideToc;
- $toc = $content.find( '#toc' );
- $tocTitle = $content.find( '#toctitle' );
- $tocToggleLink = $content.find( '#togglelink' );
- $tocList = $toc.find( 'ul' ).eq( 0 );
+ $content.find( '.toc' ).addBack( '.toc' ).each( function () {
+ var hideToc,
+ $this = $( this ),
+ $tocTitle = $this.find( '.toctitle' ),
+ $tocToggleLink = $this.find( '.togglelink' ),
+ $tocList = $this.find( 'ul' ).eq( 0 );
- // Hide/show the table of contents element
- function toggleToc() {
- if ( $tocList.is( ':hidden' ) ) {
- $tocList.slideDown( 'fast' );
- $tocToggleLink.text( mw.msg( 'hidetoc' ) );
- $toc.removeClass( 'tochidden' );
- mw.cookie.set( 'hidetoc', null );
- } else {
- $tocList.slideUp( 'fast' );
- $tocToggleLink.text( mw.msg( 'showtoc' ) );
- $toc.addClass( 'tochidden' );
- mw.cookie.set( 'hidetoc', '1' );
+ // Hide/show the table of contents element
+ function toggleToc() {
+ if ( $tocList.is( ':hidden' ) ) {
+ $tocList.slideDown( 'fast' );
+ $tocToggleLink.text( mw.msg( 'hidetoc' ) );
+ $this.removeClass( 'tochidden' );
+ mw.cookie.set( 'hidetoc', null );
+ } else {
+ $tocList.slideUp( 'fast' );
+ $tocToggleLink.text( mw.msg( 'showtoc' ) );
+ $this.addClass( 'tochidden' );
+ mw.cookie.set( 'hidetoc', '1' );
+ }
}
- }
- // Only add it if there is a complete TOC and it doesn't
- // have a toggle added already
- if ( $toc.length && $tocTitle.length && $tocList.length && !$tocToggleLink.length ) {
- hideToc = mw.cookie.get( 'hidetoc' ) === '1';
+ // Only add it if there is a complete TOC and it doesn't
+ // have a toggle added already
+ if ( $tocTitle.length && $tocList.length && !$tocToggleLink.length ) {
+ hideToc = mw.cookie.get( 'hidetoc' ) === '1';
- $tocToggleLink = $( '' )
- .text( mw.msg( hideToc ? 'showtoc' : 'hidetoc' ) )
- .on( 'click keypress', function ( e ) {
- if (
- e.type === 'click' ||
- e.type === 'keypress' && e.which === 13
- ) {
- toggleToc();
- }
- } );
+ $tocToggleLink = $( '' )
+ .text( mw.msg( hideToc ? 'showtoc' : 'hidetoc' ) )
+ .on( 'click keypress', function ( e ) {
+ if (
+ e.type === 'click' ||
+ e.type === 'keypress' && e.which === 13
+ ) {
+ toggleToc();
+ }
+ } );
- $tocTitle.append(
- $tocToggleLink
- .wrap( '' )
- .parent()
+ $tocTitle.append(
+ $tocToggleLink
+ .wrap( '' )
+ .parent()
.prepend( ' [' )
.append( '] ' )
- );
+ );
- if ( hideToc ) {
- $tocList.hide();
- $toc.addClass( 'tochidden' );
+ if ( hideToc ) {
+ $tocList.hide();
+ $this.addClass( 'tochidden' );
+ }
}
- }
+ } );
} );
}( mediaWiki, jQuery ) );