(Bug 60030) Use $content of the hook for toc hiding
authorFomafix <fomafix@googlemail.com>
Tue, 14 Jan 2014 07:50:28 +0000 (07:50 +0000)
committer[[mw:User:Fomafix]] <gerritpatchuploader@gmail.com>
Tue, 14 Jan 2014 07:50:28 +0000 (07:50 +0000)
Change-Id: Ia1d0a5c4b23459a7da58803fbf886b562eea7f37

resources/mediawiki/mediawiki.util.js

index 86f06b8..1feb36b 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' ) )