Remove deprecated function mw.util.toggleToc
authorFomafix <fomafix@googlemail.com>
Mon, 14 Apr 2014 20:16:08 +0000 (20:16 +0000)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 17 Apr 2014 15:23:43 +0000 (17:23 +0200)
* Remove dependency from mediawiki.util to mediawiki.toc.
* Load module mediawiki.toc only when toc is existent.

Gadgets that use the messages "showtoc" or "hidetoc" should explicitly
load the module mediawiki.toc or use their own messages.

Follows-up I3ca2acb70db98d00e3f1b (implements mediawiki.toc).

Change-Id: If0438b7b6f4649434e2b83133d6f583f2f8eff16

RELEASE-NOTES-1.24
includes/parser/Parser.php
includes/specials/SpecialEditWatchlist.php
resources/Resources.php
resources/src/mediawiki/mediawiki.util.js
tests/qunit/QUnitTestResources.php
tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js

index 3d9efc3..88f4974 100644 (file)
@@ -24,6 +24,7 @@ changes to languages because of Bugzilla reports.
 
 === Other changes in 1.24 ===
 * The deprecated jquery.delayedBind ResourceLoader module was removed.
+* The deprecated function mw.util.toggleToc was removed.
 
 == Compatibility ==
 
index 2d9078d..3bf40c6 100644 (file)
@@ -4524,6 +4524,7 @@ class Parser {
                        $toc = Linker::tocList( $toc, $this->mOptions->getUserLangObj() );
                        $this->mOutput->setTOCHTML( $toc );
                        $toc = self::TOC_START . $toc . self::TOC_END;
+                       $this->mOutput->addModules( 'mediawiki.toc' );
                }
 
                if ( $isMain ) {
index 68e8703..31fcc61 100644 (file)
@@ -103,6 +103,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                                        $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
                                } elseif ( $this->toc !== false ) {
                                        $out->prependHTML( $this->toc );
+                                       $out->addModules( 'mediawiki.toc' );
                                }
                                break;
                }
index cea012a..3adbe12 100644 (file)
@@ -898,7 +898,6 @@ return array(
                        'jquery.client',
                        'jquery.mwExtension',
                        'mediawiki.notify',
-                       'mediawiki.toc',
                ),
                'position' => 'top', // For $wgPreloadJavaScriptMwUtil
                'targets' => array( 'desktop', 'mobile' ),
index 2234238..a5bc7d9 100644 (file)
                        return s.sheet || s.styleSheet || s;
                },
 
-               /**
-                * Hide/show the table of contents element
-                *
-                * @param {jQuery} $toggleLink A jQuery object of the toggle link.
-                * @param {Function} [callback] Function to be called after the toggle is
-                *  completed (including the animation).
-                * @return {Mixed} Boolean visibility of the toc (true if it's visible)
-                * or Null if there was no table of contents.
-                * @deprecated since 1.23 Use jQuery
-                */
-               toggleToc: function ( $toggleLink, callback ) {
-                       var ret, $tocList = $( '#toc ul:first' );
-
-                       // This function shouldn't be called if there's no TOC,
-                       // but just in case...
-                       if ( !$tocList.length ) {
-                               return null;
-                       }
-                       ret = $tocList.is( ':hidden' );
-                       $toggleLink.click();
-                       $tocList.promise().done( callback );
-                       return ret;
-               },
-
                /**
                 * Grab the URL parameter value for the given parameter.
                 * Returns null if not found.
index a0fb918..cb9fa07 100644 (file)
@@ -98,6 +98,7 @@ return array(
                        'mediawiki.api.watch',
                        'mediawiki.jqueryMsg',
                        'mediawiki.Title',
+                       'mediawiki.toc',
                        'mediawiki.Uri',
                        'mediawiki.user',
                        'mediawiki.util',
index 5d1d279..9707ab9 100644 (file)
                $( style.ownerNode ).remove();
        } );
 
-       QUnit.asyncTest( 'toggleToc', 4, function ( assert ) {
-               var tocHtml, $toggleLink;
-
-               function actionC() {
-                       QUnit.start();
-               }
-
-               function actionB() {
-                       assert.strictEqual( mw.util.toggleToc( $toggleLink, actionC ), true, 'Return boolean true if the TOC is now visible.' );
-               }
-
-               function actionA() {
-                       assert.strictEqual( mw.util.toggleToc( $toggleLink, actionB ), false, 'Return boolean false if the TOC is now hidden.' );
-               }
-
-               assert.strictEqual( mw.util.toggleToc(), null, 'Return null if there is no table of contents on the page.' );
-
-               tocHtml = '<div id="toc" class="toc">' +
-                       '<div id="toctitle">' +
-                       '<h2>Contents</h2>' +
-                       '</div>' +
-                       '<ul><li></li></ul>' +
-                       '</div>';
-               $( tocHtml ).appendTo( '#qunit-fixture' );
-               mw.hook( 'wikipage.content' ).fire( $( '#qunit-fixture' ) );
-               $toggleLink = $( '#togglelink' );
-
-               assert.strictEqual( $toggleLink.length, 1, 'Toggle link is appended to the page.' );
-
-               actionA();
-       } );
-
        QUnit.test( 'getParamValue', 5, function ( assert ) {
                var url;