Advertisement
kthomer

Moving ToC in DokuWiki

Dec 21st, 2012
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * JavaScript to move DokuWiki Table of Contents position from the default
  3.  * location to within the first element with class='wrap_movetoc' and
  4.  * recolors it to match the current ToC of Wikipedia.
  5.  *
  6.  * Creation of a div with class='wrap_movetoc' can be accomplished with the
  7.  * plugin "Wrap" and creating an empty <WRAP movetoc {size}px></WRAP>
  8.  * and placing that where you want the ToC to appear.
  9.  *
  10.  */
  11. addInitEvent(function moveTOC() {
  12.     'use strict';
  13.     var moveTOCHere, tocTable, container, tocHeader, tocInside, tocToggle;
  14.     moveTOCHere = document.getElementsByClassName('wrap_movetoc');
  15.     tocTable = document.getElementsByClassName('toc');
  16.     container = moveTOCHere[0];
  17.     tocHeader = document.getElementById('toc__header');
  18.     tocInside = document.getElementById('toc__inside');
  19.     tocToggle = document.getElementById('toc__toggle');
  20.         if(typeof(tocHeader) !== 'undefined' && tocHeader !== null) {
  21.                 if (moveTOCHere.length === 1) {
  22.                         container.appendChild(tocTable[0]);
  23.                         tocHeader.style.textAlign = "center";
  24.                         tocTable[0].style.cssFloat = "none";
  25.                         tocTable[0].style.margin = "0px";
  26.                         tocTable[0].style.fontSize = "100%";
  27.                         tocHeader.style.backgroundColor = "transparent";
  28.                         tocHeader.style.border = "none";
  29.                         tocHeader.style.margin = "0px";
  30.                         tocInside.style.backgroundColor = "transparent";
  31.                         tocInside.style.border = "none";
  32.                         moveTOCHere[0].style.backgroundColor = "#F9F9F9";
  33.                         moveTOCHere[0].style.border = "1px solid #AAAAAA";
  34.                 } else {
  35.                         return;
  36.                 }
  37.         } else {
  38.                 return;
  39.         }
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement