div.float_toc {
margin: 0px;
float:right;
width: 200px;
font-size: 80%;
clear:both;
z-index: 1;
position: absolute;
}
==== conf/dokuwiki.php or better conf/local.php - added an option to /* Display Options */ section ====
$conf['float_toc'] = 1; //produce toc that is visibile at all times and can be moved around in doc? 0|1
==== inc/html.php ====
* new js include
//after this
//added this
* function toc_html($toc) modfications
function html_toc($toc){
global $lang;
global $conf; // added this
$ret = '';
// replaced this: $ret .= ''; with following if block
if ( $conf['float_toc'] == 1 ){
$ret .= '';
}else{
$ret .= '';
}
$ret .= '';
$ret .= $lang['toc'];
$ret .= ' ';
$ret .= '';
$ret .= '';
$ret .= html_buildlist($toc,'toc','html_list_toc');
$ret .= '';
$ret .= '';
return $ret;
}
==== new js file: toc.js ====
/**
* Floating/movable TOC
*
* @author Oliver S6ro
* @copyright Copyright (C) 2005, Oliver S6ro
* @license GPL v2 http://www.gnu.org/copyleft/gpl.html
*/
// GLOBALS
// Id of first div element of TOC.
var TOC_ID = "tocbox";
// State flag for mouse cursor. True if in TOC area otherwise false.
var inToc = false;
// State flag for Ctrl. True if inToc == true && Ctrl is held down, otherwise false.
var tocCtrlDown = false;
// Initial TOC x (style.left), y (style.top) coordinates
var tocXOffset = 1;
var tocYOffset = 100;
// Store difference between mouse X,Y and TOC x,y if Ctrl is first pressed in TOC area.
var tocXDiff = 0;
var tocYDiff = 0;
// Quick browser check
var isIE = document.all ? true : false;
/**
* Called if mouse cursor is over TOC area.
*/
function tocOver()
{
inToc = true;
tocCtrlDown = false;
}
/*
* Called if mouse cursor moved out of TOC area.
*/
function tocOut()
{
inToc = false;
tocCtrlDown = false;
}
/**
* Move TOC - duh ;)
*/
function moveToc( pEvent )
{
var TOC = document.getElementById( TOC_ID );
if ( TOC && inToc )
{
// TOC found in page and mouse cursor in TOC area
if ( tocCtrlDown )
{
// Ctrl is held down - move sucker ;)
if ( !isIE )
{
var tocX = pEvent.pageX - tocXDiff;
var tocY = pEvent.pageY - tocYDiff;
tocCtrlDown = pEvent.ctrlKey;
}
else
{
var tocX = window.event.clientX - tocXDiff;
var tocY = window.event.clientY - tocYDiff;
tocCtrlDown = window.event.ctrlKey;
}
tocXOffset = tocX;
tocYOffset = tocY;
TOC.style.left = new String( tocX + "px" );
TOC.style.top = new String( tocY + "px" );
}
else
{
// check if Ctrl is pressed down, is so get x,y diffs
if ( !isIE )
{
tocCtrlDown = pEvent.ctrlKey;
if ( tocCtrlDown )
{
tocXDiff = pEvent.pageX - parseInt( TOC.style.left );
tocYDiff = pEvent.pageY - parseInt( TOC.style.top );
}
}
else
{
tocCtrlDown = window.event.ctrlKey;
if ( tocCtrlDown )
{
tocXDiff = window.event.clientX - parseInt( TOC.style.left );
tocYDiff = window.event.clientY - parseInt( TOC.style.top );
}
}
}
}
return true;
}
/**
* Firefox/Mozilla have limited support of onscroll so instead this function
* is used and called every X ms specified in initTocScroll.
*/
function tocScroll()
{
var TOC = document.getElementById( TOC_ID );
if ( TOC )
{
if ( !inToc )
{
if ( !isIE )
{
var tocX = tocXOffset + window.pageXOffset;
var tocY = tocYOffset + window.pageYOffset;
}
else
{
var tocX = tocXOffset + document.documentElement.scrollLeft;
var tocY = tocYOffset + document.documentElement.scrollTop;
}
TOC.style.top = new String( tocY + "px" );
TOC.style.left = new String( tocX + "px" );
}
}
}
/**
* Scrolling setup
*/
function initTocScroll()
{
var TOC = document.getElementById( TOC_ID );
if ( TOC )
{
TOC.style.left = new String( tocXOffset + "px" );
TOC.style.top = new String( tocYOffset + "px" );
TOC.onmouseover = tocOver;
TOC.onmouseout = tocOut;
var tid = setInterval( "tocScroll()", 1 );
}
return true;
}
/**
* Capture document events and set handlers
*/
if ( !isIE ) document.captureEvents( Event.MOUSEMOVE );
document.onmousemove = moveToc;
window.onload = initTocScroll;