Created page with "// MakeMobileCollapsible, enables collapsible templates/infoboxes on the mobile site. // This is a spinoff from Factotum. (https://en.wikipedia.org/wiki/User:Alexis_Jazz/Factotum) // MakeMobileCollapsible is public domain, irrevocably released as WTFPL Version 2[www.wtfpl.net/about/] by its author, Alexis Jazz. →globals $:false,mw:false: var MMCollap = {}; MMCollap.do = function(classes,int) { MMCollap.els = $('.mw-collapsible'); if ( MMCollap.els[0] ) { if ( MMCo..."
 
No edit summary
 
Line 1: Line 1:
// MakeMobileCollapsible, enables collapsible templates/infoboxes on the mobile site.
// MakeMobileCollapsible, enables collapsible templates/infoboxes on the mobile site.
// This is a spinoff from Factotum. (https://en.wikipedia.org/wiki/User:Alexis_Jazz/Factotum)
// MakeMobileCollapsible is public domain, irrevocably released as WTFPL Version 2[www.wtfpl.net/about/] by its author, Alexis Jazz.
// MakeMobileCollapsible is public domain, irrevocably released as WTFPL Version 2[www.wtfpl.net/about/] by its author, Alexis Jazz.


Line 9: Line 8:
if ( MMCollap.els[0] ) {
if ( MMCollap.els[0] ) {
if ( MMCollap.els.length > 1 ) {
if ( MMCollap.els.length > 1 ) {
// the "autocollapse" class is handled by code in Common.js on enwiki, but Common.js isn't loaded on mobile.
// the "autocollapse" class is handled by Common.js on desktop, but Common.js isn't loaded on mobile.
$('.autocollapse').addClass('mw-collapsed');
$('.autocollapse').addClass('mw-collapsed');
}
}

Latest revision as of 21:35, 7 November 2026

// MakeMobileCollapsible, enables collapsible templates/infoboxes on the mobile site.
// MakeMobileCollapsible is public domain, irrevocably released as WTFPL Version 2[www.wtfpl.net/about/] by its author, Alexis Jazz.

/*globals $:false,mw:false*/
var MMCollap = {};
MMCollap.do = function(classes,int) {
	MMCollap.els = $('.mw-collapsible');
	if ( MMCollap.els[0] ) {
		if ( MMCollap.els.length > 1 ) {
			// the "autocollapse" class is handled by Common.js on desktop, but Common.js isn't loaded on mobile.
			$('.autocollapse').addClass('mw-collapsed');
		}
		mw.loader.using(['jquery.makeCollapsible']).then( function () {
			mw.loader.addStyleTag('.mw-parser-output .mw-collapsible-toggle{font-weight:normal;min-width:6em}');
			$(MMCollap.els).makeCollapsible(); //T111565 FTFY
		});
	}
};
//make collapsible content collapsible whenever the page is rendered, on load but also e.g. after saving an edit
mw.hook( 'wikipage.content' ).add( MMCollap.do );