Skillnad mellan versioner av "MediaWiki:Common.js"

Från Mittköping
Hoppa till:navigering, sök
Rad 1: Rad 1:
 
/* JavaScript som skrivs här körs varje gång en användare laddar en sida. */
 
/* JavaScript som skrivs här körs varje gång en användare laddar en sida. */
function hideToc() {  
+
// The enclosed code runs only after the page has been loaded and parsed.
   var toc = document.getElementById('toc').getElementsByTagName('ul')[0];
+
window.addEventListener('DOMContentLoaded', function() {
  var toggleLink = document.getElementById('togglelink');
+
   try {
  toc.style.display = 'none';  
+
    // Detect whether the page's TOC is being displayed.
}  
+
    if (document.getElementById('toc').getElementsByTagName('ul')[0].style.display != 'none') {
hideToc();
+
      // Use MW's toggleToc() to hide TOC, change "hide/show" link text, and set cookie.
 +
      toggleToc();
 +
    }
 +
  } catch (exception) {
 +
    // Probably this page doesn't have a TOC, ignore the exception to prevent console clutter.
 +
  }
 +
}, false);

Versionen från 16 oktober 2017 kl. 16.12

/* JavaScript som skrivs här körs varje gång en användare laddar en sida. */
// The enclosed code runs only after the page has been loaded and parsed.
window.addEventListener('DOMContentLoaded', function() {
  try {
    // Detect whether the page's TOC is being displayed.
    if (document.getElementById('toc').getElementsByTagName('ul')[0].style.display != 'none') {
      // Use MW's toggleToc() to hide TOC, change "hide/show" link text, and set cookie.
      toggleToc();
    }
  } catch (exception) {
    // Probably this page doesn't have a TOC, ignore the exception to prevent console clutter.
  }
}, false);