mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-03 18:26:16 +00:00
a9d73060fa
When moving to packageFiles, the modules errorLogging and toc were not imported by init.js meaning they were not run. ResourceLoader should probably error in this situation, but until then we should fix this problem. This is a follow up to I44790dd3fc6fe42bb502d79c39c4081c223bf2b1 Bug: T212944 Change-Id: I86efb7be1c39b03f63c8f1e0b107216cd30ff6de
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
( function ( M ) {
|
|
var mobile = M.require( 'mobile.startup' ),
|
|
Toggler = mobile.Toggler,
|
|
TableOfContents = mobile.toc.TableOfContents,
|
|
eventBus = mobile.eventBusSingleton;
|
|
|
|
/**
|
|
* Create TableOfContents if the given Page has sections and is not the main page
|
|
* and wgMFTocEnabled config variable is set to true.
|
|
* @method
|
|
* @param {Page} page for which a TOC is generated
|
|
* @param {jQuery.Object} $toc container to replace
|
|
* @ignore
|
|
*/
|
|
function init( page, $toc ) {
|
|
var sections = page.getSections(),
|
|
toc = new TableOfContents( {
|
|
sections: sections
|
|
} );
|
|
|
|
// eslint-disable-next-line no-new
|
|
new Toggler( {
|
|
$container: toc.$el,
|
|
prefix: 'toc-',
|
|
page: page,
|
|
isClosed: true,
|
|
eventBus: eventBus
|
|
} );
|
|
// if there is a toc already, replace it
|
|
if ( $toc.length > 0 ) {
|
|
// don't show toc at end of page, when no sections there
|
|
$toc.replaceWith( toc.$el );
|
|
} else {
|
|
// otherwise append it to the lead section
|
|
toc.appendTo( page.getLeadSectionElement() );
|
|
}
|
|
}
|
|
|
|
module.exports = init;
|
|
|
|
}( mw.mobileFrontend ) );
|