MediaWiki:Gadget-MakeMobileCollapsible.js

Versione del 25 ago 2024 alle 11:57 di Johnrdorazio (discussione | contributi) (Creata pagina con "// MakeMobileCollapsible, enables collapsible templates/infoboxes on the mobile site. // See https://en.wikipedia.org/wiki/Wikipedia:MakeMobileCollapsible for more information. // 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: //<nowiki> let MMCollap = {}; MMCollap.do...")
(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.

  • Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
  • Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
  • Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
  • Opera: premi Ctrl-F5.
// MakeMobileCollapsible, enables collapsible templates/infoboxes on the mobile site.
// See https://en.wikipedia.org/wiki/Wikipedia:MakeMobileCollapsible for more information.
// 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*/
//<nowiki>
let MMCollap = {};
MMCollap.do = function() {
	MMCollap.els = $('.mw-collapsible');
	if ( MMCollap.els[0] ) {
		if ( MMCollap.els.length > 1  && ( ['enwiki'].indexOf(mw.config.get('wgDBname')) != -1) ) {
			$('.autocollapse').addClass('mw-collapsed'); //the "autocollapse" class is handled by code in Common.js on enwiki, but Common.js isn't loaded on mobile.
		}
		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
		});
	}
};
mw.hook( 'wikipage.content' ).add( MMCollap.do ); //make collapsible content collapsible whenever the page is rendered, on load but also e.g. after saving an edit
//</nowiki>