* 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
=== Other changes in 1.24 ===
* The deprecated jquery.delayedBind ResourceLoader module was removed.
+* The deprecated function mw.util.toggleToc was removed.
== Compatibility ==
$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 ) {
$out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
} elseif ( $this->toc !== false ) {
$out->prependHTML( $this->toc );
+ $out->addModules( 'mediawiki.toc' );
}
break;
}
'jquery.client',
'jquery.mwExtension',
'mediawiki.notify',
- 'mediawiki.toc',
),
'position' => 'top', // For $wgPreloadJavaScriptMwUtil
'targets' => array( 'desktop', 'mobile' ),
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.
'mediawiki.api.watch',
'mediawiki.jqueryMsg',
'mediawiki.Title',
+ 'mediawiki.toc',
'mediawiki.Uri',
'mediawiki.user',
'mediawiki.util',
$( 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;