Merge "(Bug 60030) Use $content of the hook for toc hiding"
[lhc/web/wiklou.git] / resources / mediawiki / mediawiki.util.js
index 86f06b8..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' ) )
                                                .click( function ( e ) {
                                                        e.preventDefault();
-                                                       util.toggleToc( $(this) );
+                                                       util.toggleToc( $( this ) );
                                                } );
                                        $tocTitle.append(
                                                $tocToggleLink
                 * This function returns the styleSheet object for convience (due to cross-browsers
                 * difference as to where it is located).
                 *
-                *     var sheet = mw.util.addCSS('.foobar { display: none; }');
-                *     $(foo).click(function () {
+                *     var sheet = mw.util.addCSS( '.foobar { display: none; }' );
+                *     $( foo ).click( function () {
                 *         // Toggle the sheet on and off
                 *         sheet.disabled = !sheet.disabled;
-                *     });
+                *     } );
                 *
                 * @param {string} text CSS to be appended
                 * @return {CSSStyleSheet} Use .ownerNode to get to the `<style>` element.
                        // the ABNF:
                        //      1 * ( atext / "." ) "@" ldh-str 1*( "." ldh-str )
                        // With:
-                       // - atext      : defined in RFC 5322 section 3.2.3
+                       // - atext   : defined in RFC 5322 section 3.2.3
                        // - ldh-str : defined in RFC 1034 section 3.5
                        //
                        // (see STD 68 / RFC 5234 http://tools.ietf.org/html/std68)
                                // RegExp is case insensitive
                                'i'
                        );
-                       return (null !== mailtxt.match( html5EmailRegexp ) );
+                       return ( null !== mailtxt.match( html5EmailRegexp ) );
                },
 
                /**