From: Fomafix Date: Mon, 14 Apr 2014 20:16:08 +0000 (+0000) Subject: Remove deprecated function mw.util.toggleToc X-Git-Tag: 1.31.0-rc.0~16175^2~1 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=a54ef1a203ddf9d54645ad0fb485beab4b3dc48d;p=lhc%2Fweb%2Fwiklou.git Remove deprecated function mw.util.toggleToc * 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 --- diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index 3d9efc3969..88f4974c86 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 == diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 2d9078d3be..3bf40c681b 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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 ) { diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 68e8703f6d..31fcc61aeb 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -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; } diff --git a/resources/Resources.php b/resources/Resources.php index cea012aa98..3adbe1299f 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -898,7 +898,6 @@ return array( 'jquery.client', 'jquery.mwExtension', 'mediawiki.notify', - 'mediawiki.toc', ), 'position' => 'top', // For $wgPreloadJavaScriptMwUtil 'targets' => array( 'desktop', 'mobile' ), diff --git a/resources/src/mediawiki/mediawiki.util.js b/resources/src/mediawiki/mediawiki.util.js index 22342384fd..a5bc7d9b24 100644 --- a/resources/src/mediawiki/mediawiki.util.js +++ b/resources/src/mediawiki/mediawiki.util.js @@ -147,30 +147,6 @@ 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. diff --git a/tests/qunit/QUnitTestResources.php b/tests/qunit/QUnitTestResources.php index a0fb9180ab..cb9fa07402 100644 --- a/tests/qunit/QUnitTestResources.php +++ b/tests/qunit/QUnitTestResources.php @@ -98,6 +98,7 @@ return array( 'mediawiki.api.watch', 'mediawiki.jqueryMsg', 'mediawiki.Title', + 'mediawiki.toc', 'mediawiki.Uri', 'mediawiki.user', 'mediawiki.util', diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js index 5d1d27933c..9707ab9eb1 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js @@ -71,38 +71,6 @@ $( 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 = '
' + - '
' + - '

Contents

' + - '
' + - '' + - '
'; - $( 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;