// original: $Id: toc.js,v 1.1 2006/04/03 21:53:15 nedjo Exp $ // Comments TOC version by Ignas, 2006/05/12 // // At the end of your tempate node.tpl.php place the line //
// // At the begining of comment.tpl.php place // // if (isJsEnabled()) { addLoadEvent(function() { var nodeDiv; var create; // Select all DIV elements divs = document.getElementsByTagName('div'); for (var i = 0; div = divs[i]; ++i) { if (hasClass(div, 'pagetoc')) nodeDiv = div; // finds special div included in template node.tpl.php if (hasClass(div, 'comment')) { create = true; break; } } if (create && nodeDiv) { var h3; var toc = document.createElement('fieldset'); legend = document.createElement('legend'); var a = document.createElement('a'); a.href = '#'; a.onclick = function() { toggleClass(this.parentNode.parentNode, 'collapsed'); if (!hasClass(this.parentNode.parentNode, 'collapsed')) { collapseScrollIntoView(this.parentNode.parentNode); } this.blur(); return false; }; a.appendChild(document.createTextNode('contents')); legend.appendChild(a); toc.appendChild(legend); addClass(toc, 'collapsible'); var ul = document.createElement('ul'); for (var i = 0; div = divs[i]; ++i) { if (hasClass(div, 'comment')) { if (divs[i-2].style.marginLeft) marginLeft=parseInt(parseInt(divs[i-2].style.marginLeft)/2); else marginLeft=0; //left margin values - stiling for nested comments var li = document.createElement('li'); var ddiv = document.createElement('div'); ddiv.style.marginLeft = marginLeft+'px'; var children = divs[i-1].childNodes; //take all information from special DIV while (children.length) li.appendChild(children[0]); ddiv.appendChild(li); ul.appendChild(ddiv); } } toc.appendChild(ul); nodeDiv.insertBefore(toc, nodeDiv.firstChild); collapseEnsureErrorsVisible(toc); } }); }