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
This commit is contained in:
Fomafix 2014-04-14 20:16:08 +00:00 committed by Bartosz Dziewoński
parent 543723c792
commit a54ef1a203
7 changed files with 4 additions and 57 deletions

View 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 ==

View 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 ) {

View 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;
}

View file

@ -898,7 +898,6 @@ return array(
'jquery.client',
'jquery.mwExtension',
'mediawiki.notify',
'mediawiki.toc',
),
'position' => 'top', // For $wgPreloadJavaScriptMwUtil
'targets' => array( 'desktop', 'mobile' ),

View file

@ -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.

View file

@ -98,6 +98,7 @@ return array(
'mediawiki.api.watch',
'mediawiki.jqueryMsg',
'mediawiki.Title',
'mediawiki.toc',
'mediawiki.Uri',
'mediawiki.user',
'mediawiki.util',

View file

@ -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 = '<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;