mediawiki-skins-MinervaNeue/resources/skins.minerva.toggling/init.js
Jan Drewniak 1589a15862 Remove references to "mobile.toggle" module.
mobile.toggle was folded into mobile.startup in
mobileFrontend, so moving references to that instead.
- Changing require statements
- moving skinStyles/mobile.toggle/minerva.less to
   skinStyles/mobile.startup/toggle.less
- Replacing references to mobile.toggle in skin.json

Depends-On: Iecc1870f08532e8c7893861afdd54f069da54be2
Bug: T210208
Change-Id: Ie67cd50a2d042fbbaaef348b9b62d64193900d78
2018-12-14 00:45:34 +01:00

51 lines
1.5 KiB
JavaScript

( function ( M ) {
var page = M.getCurrentPage(),
$contentContainer = $( '#mw-content-text > .mw-parser-output' ),
Toggler = M.require( 'mobile.startup' ).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 ) );