diff options
Diffstat (limited to 'src/navtree.js')
-rw-r--r-- | src/navtree.js | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/navtree.js b/src/navtree.js index 1a46df4..ed2565a 100644 --- a/src/navtree.js +++ b/src/navtree.js @@ -1,3 +1,5 @@ +var SYNCONMSG = 'click to disable panel synchronisation'; +var SYNCOFFMSG = 'click to enable panel synchronisation'; var navTreeSubIndices = new Array(); function getData(varName) @@ -78,12 +80,12 @@ function createIndent(o,domNode,node,level) var level=-1; var n = node; while (n.parentNode) { level++; n=n.parentNode; } - var imgNode = document.createElement("img"); - imgNode.style.paddingLeft=(16*level).toString()+'px'; - imgNode.width = 16; - imgNode.height = 22; - imgNode.border = 0; if (node.childrenData) { + var imgNode = document.createElement("img"); + imgNode.style.paddingLeft=(16*level).toString()+'px'; + imgNode.width = 16; + imgNode.height = 22; + imgNode.border = 0; node.plus_img = imgNode; node.expandToggle = document.createElement("a"); node.expandToggle.href = "javascript:void(0)"; @@ -100,8 +102,12 @@ function createIndent(o,domNode,node,level) domNode.appendChild(node.expandToggle); imgNode.src = node.relpath+"ftv2pnode.png"; } else { - imgNode.src = node.relpath+"ftv2node.png"; - domNode.appendChild(imgNode); + var span = document.createElement("span"); + span.style.display = 'inline-block'; + span.style.width = 16*(level+1)+'px'; + span.style.height = '22px'; + span.innerHTML = ' '; + domNode.appendChild(span); } } @@ -320,7 +326,7 @@ function showNode(o, node, index, hash) if (!node.childrenVisited) { getNode(o, node); } - $(node.getChildrenUL()).show(); + $(node.getChildrenUL()).css({'display':'block'}); if (node.isLast) { node.plus_img.src = node.relpath+"ftv2mlastnode.png"; } else { @@ -352,8 +358,22 @@ function showNode(o, node, index, hash) } } +function removeToInsertLater(element) { + var parentNode = element.parentNode; + var nextSibling = element.nextSibling; + parentNode.removeChild(element); + return function() { + if (nextSibling) { + parentNode.insertBefore(element, nextSibling); + } else { + parentNode.appendChild(element); + } + }; +} + function getNode(o, po) { + var insertFunction = removeToInsertLater(po.li); po.childrenVisited = true; var l = po.childrenData.length-1; for (var i in po.childrenData) { @@ -361,6 +381,7 @@ function getNode(o, po) po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2], i==l); } + insertFunction(); } function gotoNode(o,subIndex,root,hash,relpath) @@ -466,6 +487,7 @@ function initNavTree(toroot,relpath) $(window).load(function(){ navTo(o,toroot,window.location.hash,relpath); + showRoot(); }); $(window).bind('hashchange', function(){ @@ -489,7 +511,5 @@ function initNavTree(toroot,relpath) navTo(o,toroot,window.location.hash,relpath); } }) - - $(window).load(showRoot); } |