Merge "(Bug 60030) Use $content of the hook for toc hiding"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 23 Jan 2014 17:55:34 +0000 (17:55 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 23 Jan 2014 17:55:34 +0000 (17:55 +0000)
resources/mediawiki/mediawiki.util.js

index a178e2b..820cd0a 100644 (file)
                        } )();
 
                        // Table of contents toggle
-                       mw.hook( 'wikipage.content' ).add( function () {
+                       mw.hook( 'wikipage.content' ).add( function ( $content ) {
                                var $tocTitle, $tocToggleLink, hideTocCookie;
-                               $tocTitle = $( '#toctitle' );
-                               $tocToggleLink = $( '#togglelink' );
+                               $tocTitle = $content.find( '#toctitle' );
+                               $tocToggleLink = $content.find( '#togglelink' );
                                // Only add it if there is a TOC and there is no toggle added already
-                               if ( $( '#toc' ).length && $tocTitle.length && !$tocToggleLink.length ) {
+                               if ( $content.find( '#toc' ).length && $tocTitle.length && !$tocToggleLink.length ) {
                                        hideTocCookie = $.cookie( 'mw_hidetoc' );
                                        $tocToggleLink = $( '<a href="#" class="internal" id="togglelink"></a>' )
                                                .text( mw.msg( 'hidetoc' ) )