mediawiki-skins-MinervaNeue/resources/skins.minerva.toggling/init.js
jdlrobson 2cc9516cde Minerva is its own skin
This is programmatic output from python3 scripts/migrate.py

This will result in a Minerva skin dependent on MobileFrontend.

Post merge we will rename message keys to have minerva- prefix

Bug: T166748
Change-Id: Iff1f7e63e796cc5d4a6d2ab0370e0c33248d2fce
2017-07-12 08:12:40 -07:00

42 lines
1.3 KiB
JavaScript

( function ( M, $ ) {
var page = M.getCurrentPage(),
$contentContainer = $( '#mw-content-text > .mw-parser-output' ),
Toggler = M.require( 'mobile.toggle/Toggler' );
// 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, prefix, page );
}
// avoid this running on Watchlist
if (
!page.inNamespace( 'special' ) &&
!mw.config.get( 'wgIsMainPage' ) &&
mw.config.get( 'wgAction' ) === 'view'
) {
init( $contentContainer, 'content-', page );
}
}( mw.mobileFrontend, jQuery ) );