Jump to content
Gov  ·  Market  ·  Community  ·  Policies  ·  Funding  ·  Open Calls  ·  Get started

MediaWiki:Mobile.js: Difference between revisions

From WikiDeal
Expand all mobile sections on load (no tap-to-open), defeats Minerva content-visibility collapse
 
Always move ApprovedRevs banner to end of article (Vector-mf case: subtitle already inside bodyContent)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* WikiDeal Mobile.js — loaded by MobileFrontend (Minerva skin)
/* Not loaded by this wiki (site JS disabled). Mobile section/TOC expansion lives in MediaWiki:Common.css. */
*
* 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' ) {
/* ApprovedRevs banner: move to the BOTTOM of the article on mobile (Theo, 2026-08-19).
expandAllSections();
  In Minerva the subtitle is nested inside .pre-content, so CSS reordering cannot
} else {
  move it below the article. We relocate the DOM node after page load instead. */
document.addEventListener( 'DOMContentLoaded', expandAllSections );
mw.hook('wikipage.content').add(function () {
}
    var s = document.getElementById('mw-content-subtitle');
 
    var b = document.getElementById('bodyContent');
// MobileFrontend may (re)collapse after its own JS runs; re-apply shortly after.
    if (s && b && s.textContent.trim() !== '' && b.lastElementChild !== s) {
if ( window.mw && mw.hook ) {
        b.appendChild(s);
mw.hook( 'wikipage.content' ).add( expandAllSections );
    }
}
});
setTimeout( expandAllSections, 300 );
setTimeout( expandAllSections, 1200 );
}() );

Latest revision as of 08:13, 19 August 2026

/* Not loaded by this wiki (site JS disabled). Mobile section/TOC expansion lives in MediaWiki:Common.css. */

/* ApprovedRevs banner: move to the BOTTOM of the article on mobile (Theo, 2026-08-19).
   In Minerva the subtitle is nested inside .pre-content, so CSS reordering cannot
   move it below the article. We relocate the DOM node after page load instead. */
mw.hook('wikipage.content').add(function () {
    var s = document.getElementById('mw-content-subtitle');
    var b = document.getElementById('bodyContent');
    if (s && b && s.textContent.trim() !== '' && b.lastElementChild !== s) {
        b.appendChild(s);
    }
});