2018-11-16 15:16:25 +00:00
|
|
|
( function ( M ) {
|
2019-02-07 16:34:18 +00:00
|
|
|
var
|
2019-04-03 23:32:18 +00:00
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
2017-07-12 15:12:40 +00:00
|
|
|
$contentContainer = $( '#mw-content-text > .mw-parser-output' ),
|
2019-02-07 16:34:18 +00:00
|
|
|
mobile = M.require( 'mobile.startup' ),
|
2019-07-11 00:56:04 +00:00
|
|
|
currentPage = mobile.currentPage(),
|
|
|
|
currentPageHTMLParser = mobile.currentPageHTMLParser(),
|
2019-02-07 16:34:18 +00:00
|
|
|
Toggler = mobile.Toggler,
|
|
|
|
eventBus = mobile.eventBusSingleton;
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2019-07-11 00:56:04 +00:00
|
|
|
if ( !currentPageHTMLParser.getLeadSectionElement() ) {
|
2017-08-25 15:26:47 +00:00
|
|
|
// Operating in desktop Minerva mode. Stop execution. (T172948)
|
|
|
|
return;
|
|
|
|
}
|
2017-07-12 15:12:40 +00:00
|
|
|
// If there was no mw-parser-output wrapper, just use the parent
|
|
|
|
if ( $contentContainer.length === 0 ) {
|
2019-04-03 23:32:18 +00:00
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
2017-07-12 15:12:40 +00:00
|
|
|
$contentContainer = $( '#mw-content-text' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialises toggling code.
|
|
|
|
*
|
|
|
|
* @method
|
2018-07-03 14:50:09 +00:00
|
|
|
* @param {JQuery.Object} $container to enable toggling on
|
2017-07-12 15:12:40 +00:00
|
|
|
* @param {string} prefix a prefix to use for the id.
|
|
|
|
* @param {Page} page The current page
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
function init( $container, prefix, page ) {
|
|
|
|
// distinguish headings in content from other headings
|
|
|
|
$container.find( '> h1,> h2,> h3,> h4,> h5,> h6' ).addClass( 'section-heading' )
|
|
|
|
.removeAttr( 'onclick' );
|
|
|
|
// cleanup global as it is no longer needed. We check if it's undefined because
|
|
|
|
// there is no guarantee this won't be run on other skins e.g. Vector or cached HTML
|
|
|
|
if ( window.mfTempOpenSection !== undefined ) {
|
|
|
|
delete window.mfTempOpenSection;
|
|
|
|
}
|
|
|
|
// eslint-disable-next-line no-new
|
2018-12-04 22:13:38 +00:00
|
|
|
new Toggler( {
|
|
|
|
$container: $container,
|
|
|
|
prefix: prefix,
|
|
|
|
page: page,
|
|
|
|
eventBus: eventBus
|
|
|
|
} );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// avoid this running on Watchlist
|
|
|
|
if (
|
2019-07-11 00:56:04 +00:00
|
|
|
!currentPage.inNamespace( 'special' ) &&
|
2017-07-12 15:12:40 +00:00
|
|
|
mw.config.get( 'wgAction' ) === 'view'
|
|
|
|
) {
|
2019-07-11 00:56:04 +00:00
|
|
|
init( $contentContainer, 'content-', currentPage );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
2018-11-16 15:16:25 +00:00
|
|
|
}( mw.mobileFrontend ) );
|