Zum Inhalt springen

MediaWiki:Mobile.js: Unterschied zwischen den Versionen

Aus ADOS Wiki
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
Zeile 1: Zeile 1:
// Alle Abschnitte in Minerva automatisch ausklappen
/* Minerva: Alle Abschnitte automatisch ausklappen */
(function () {
(function () {
   if (!window.mw) return;
   if (!window.mw) return;
  // Nur im Minerva-Skin (MobileFrontend)
   if (mw.config.get('skin') !== 'minerva') return;
   if (mw.config.get('skin') !== 'minerva') return;


   function expandAll() {
   function expandAll() {
     // Minerva nutzt Buttons mit .section-toggle zum Auf/Zu-klappen
     // 1) Alle Toggle-Buttons, die noch "zu" sind, anklicken
     document.querySelectorAll('button.section-toggle[aria-expanded="false"]').forEach(function (btn) {
     document.querySelectorAll('button.section-toggle[aria-expanded="false"], [data-event-name="section-toggle"][aria-expanded="false"]').forEach(function (btn) {
       btn.click();
       try { btn.click(); } catch(e) {}
     });
     });
    // 2) Sicherheitsgurt: typische Inhalts-Container sichtbar erzwingen
    document.querySelectorAll('.collapsible-block, .mf-section-contents, .section-content').forEach(function (el) {
      el.style.display = 'block';
      el.hidden = false;
      el.classList.add('open-block');
      el.classList.remove('collapsed');
    });
  }
  // Beim Rendern und bei dynamischen Änderungen erneut ausführen
  function init() {
    expandAll();
    // Nochmal kurz nach Seitenaufbau und nach spätem JS
    setTimeout(expandAll, 50);
    setTimeout(expandAll, 400);
   }
   }


  // Beim Rendern der Seite
   if (mw.loader && mw.loader.using) {
   if (mw.hook) {
     mw.loader.using(['mobile.init']).always(function () {
     mw.hook('wikipage.content').add(function () {
      if (mw.hook) mw.hook('wikipage.content').add(init);
       expandAll();
       init();
     });
     });
   } else {
   } else {
     document.addEventListener('DOMContentLoaded', expandAll);
     document.addEventListener('DOMContentLoaded', init);
  }
 
  // Falls Inhalte nachträglich geladen/umgebaut werden (Vorschau, Spoiler etc.)
  if (window.MutationObserver) {
    var obs = new MutationObserver(function () { expandAll(); });
    obs.observe(document.body, { childList: true, subtree: true });
   }
   }
})();
})();

Aktuelle Version vom 25. Oktober 2025, 19:58 Uhr

/* Minerva: Alle Abschnitte automatisch ausklappen */
(function () {
  if (!window.mw) return;
  if (mw.config.get('skin') !== 'minerva') return;

  function expandAll() {
    // 1) Alle Toggle-Buttons, die noch "zu" sind, anklicken
    document.querySelectorAll('button.section-toggle[aria-expanded="false"], [data-event-name="section-toggle"][aria-expanded="false"]').forEach(function (btn) {
      try { btn.click(); } catch(e) {}
    });

    // 2) Sicherheitsgurt: typische Inhalts-Container sichtbar erzwingen
    document.querySelectorAll('.collapsible-block, .mf-section-contents, .section-content').forEach(function (el) {
      el.style.display = 'block';
      el.hidden = false;
      el.classList.add('open-block');
      el.classList.remove('collapsed');
    });
  }

  // Beim Rendern und bei dynamischen Änderungen erneut ausführen
  function init() {
    expandAll();
    // Nochmal kurz nach Seitenaufbau und nach spätem JS
    setTimeout(expandAll, 50);
    setTimeout(expandAll, 400);
  }

  if (mw.loader && mw.loader.using) {
    mw.loader.using(['mobile.init']).always(function () {
      if (mw.hook) mw.hook('wikipage.content').add(init);
      init();
    });
  } else {
    document.addEventListener('DOMContentLoaded', init);
  }
})();