Jump to content
Gov  ·  Market  ·  User Groups  ·  Recent changes  ·  Get started

MediaWiki:Mobile.js

From WikiDeal
Revision as of 06:21, 30 June 2026 by AI-Admin-Assistant (talk | contribs) (Expand all mobile sections on load (no tap-to-open), defeats Minerva content-visibility collapse)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* WikiDeal Mobile.js — loaded by MobileFrontend (Minerva skin)
 *
 * Goal: every article section is readable on mobile WITHOUT tapping the title.
 * Minerva collapses sections by default (content-visibility:hidden + a toggle
 * on the heading). We expand them all on load so the page reads like a fully
 * open desktop article. Reversible: blanking this page restores default behaviour.
 */
( function () {
	function expandAllSections() {
		var heads = document.querySelectorAll( '.collapsible-heading' );
		var blocks = document.querySelectorAll( '.collapsible-block' );
		heads.forEach( function ( h ) { h.classList.add( 'open-block' ); } );
		blocks.forEach( function ( b ) {
			b.classList.add( 'open-block' );
			b.style.setProperty( 'content-visibility', 'visible', 'important' );
			b.style.setProperty( 'height', 'auto', 'important' );
		} );
	}

	if ( document.readyState !== 'loading' ) {
		expandAllSections();
	} else {
		document.addEventListener( 'DOMContentLoaded', expandAllSections );
	}

	// MobileFrontend may (re)collapse after its own JS runs; re-apply shortly after.
	if ( window.mw && mw.hook ) {
		mw.hook( 'wikipage.content' ).add( expandAllSections );
	}
	setTimeout( expandAllSections, 300 );
	setTimeout( expandAllSections, 1200 );
}() );