mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-17 19:21:39 +00:00
5bfd949f9a
This patch removes the remaining usages of M.on/M.off/M.emit (functionality derived from moduleLoader.js in MobileFrontend) in Minerva and continues the work of Id990b0e1a53221d5c1cb3e3012aed0e27d801fc2 (patch for MobileFrontend). This patch and the patch for MobileFrontend should be merged together as they both depend on eachother. Depends-On: Id990b0e1a53221d5c1cb3e3012aed0e27d801fc2 Bug: T156186 Change-Id: I005d2fcdbf91c2f1ac98178dfa388aa8174e7530
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
( function ( M ) {
|
|
var page = M.getCurrentPage(),
|
|
$contentContainer = $( '#mw-content-text > .mw-parser-output' ),
|
|
Toggler = M.require( 'mobile.toggle/Toggler' ),
|
|
eventBus = M.require( 'mobile.startup/eventBusSingleton' );
|
|
|
|
if ( !page.getLeadSectionElement() ) {
|
|
// Operating in desktop Minerva mode. Stop execution. (T172948)
|
|
return;
|
|
}
|
|
// If there was no mw-parser-output wrapper, just use the parent
|
|
if ( $contentContainer.length === 0 ) {
|
|
$contentContainer = $( '#mw-content-text' );
|
|
}
|
|
|
|
/**
|
|
* Initialises toggling code.
|
|
*
|
|
* @method
|
|
* @param {JQuery.Object} $container to enable toggling on
|
|
* @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
|
|
new Toggler( {
|
|
$container: $container,
|
|
prefix: prefix,
|
|
page: page,
|
|
eventBus: eventBus
|
|
} );
|
|
}
|
|
|
|
// avoid this running on Watchlist
|
|
if (
|
|
!page.inNamespace( 'special' ) &&
|
|
mw.config.get( 'wgAction' ) === 'view'
|
|
) {
|
|
init( $contentContainer, 'content-', page );
|
|
}
|
|
}( mw.mobileFrontend ) );
|