diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2011-09-25 13:05:36 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2011-09-25 13:05:36 (GMT) |
commit | 214233ffd78420a2b80f5b477ba59a5b65c41c87 (patch) | |
tree | 5f64338de08ce72826ca0878c754638fed1587d4 /src/navtree_js.h | |
parent | 5c424c553763d3f56f56e3fa3336b0f1f4a3c44a (diff) | |
download | Doxygen-214233ffd78420a2b80f5b477ba59a5b65c41c87.zip Doxygen-214233ffd78420a2b80f5b477ba59a5b65c41c87.tar.gz Doxygen-214233ffd78420a2b80f5b477ba59a5b65c41c87.tar.bz2 |
Release-1.7.5.1-20110925
Diffstat (limited to 'src/navtree_js.h')
-rw-r--r-- | src/navtree_js.h | 243 |
1 files changed, 183 insertions, 60 deletions
diff --git a/src/navtree_js.h b/src/navtree_js.h index 8e81d55..6456eb6 100644 --- a/src/navtree_js.h +++ b/src/navtree_js.h @@ -1,3 +1,29 @@ +"function getData(varName)\n" +"{\n" +" var i = varName.lastIndexOf('/');\n" +" var n = i>=0 ? varName.substring(i+1) : varName;\n" +" return eval(n);\n" +"}\n" +"\n" +"function stripPath(uri)\n" +"{\n" +" return uri.substring(uri.lastIndexOf('/')+1);\n" +"}\n" +"\n" +"function getScript(scriptName,func,show)\n" +"{\n" +" var head = document.getElementsByTagName(\"head\")[0]; \n" +" var script = document.createElement('script');\n" +" script.id = scriptName;\n" +" script.type = 'text/javascript';\n" +" script.onload = func; \n" +" script.src = scriptName+'.js'; \n" +" script.onreadystatechange = function() {\n" +" if (script.readyState == 'complete') { func(); if (show) showRoot(); }\n" +" };\n" +" head.appendChild(script); \n" +"}\n" +"\n" "function createIndent(o,domNode,node,level)\n" "{\n" " if (node.parentNode && node.parentNode.parentNode)\n" @@ -5,6 +31,8 @@ " createIndent(o,domNode,node.parentNode,level+1);\n" " }\n" " var imgNode = document.createElement(\"img\");\n" +" imgNode.width = 16;\n" +" imgNode.height = 22;\n" " if (level==0 && node.childrenData)\n" " {\n" " node.plus_img = imgNode;\n" @@ -27,7 +55,7 @@ " } \n" " else \n" " {\n" -" expandNode(o, node, false);\n" +" expandNode(o, node, false, false);\n" " }\n" " }\n" " node.expandToggle.appendChild(imgNode);\n" @@ -104,10 +132,38 @@ " var a = document.createElement(\"a\");\n" " node.labelSpan.appendChild(a);\n" " node.label = document.createTextNode(text);\n" +" node.expanded = false;\n" " a.appendChild(node.label);\n" " if (link) \n" " {\n" -" a.href = node.relpath+link;\n" +" a.className = stripPath(link.replace('#',':'));\n" +" if (link.indexOf('#')!=-1)\n" +" {\n" +" var aname = '#'+link.split('#')[1];\n" +" var srcPage = stripPath($(location).attr('pathname'));\n" +" var targetPage = stripPath(link.split('#')[0]);\n" +" a.href = srcPage!=targetPage ? node.relpath+link : '#';\n" +" a.onclick = function(){\n" +" $('.item').removeClass('selected');\n" +" $('.item').removeAttr('id');\n" +" $(a).parent().parent().addClass('selected');\n" +" $(a).parent().parent().attr('id','selected');\n" +" var anchor = $(aname);\n" +" var targetDiv = anchor.next();\n" +" $(targetDiv).children('.memproto,.memdoc').effect(\"highlight\",{},3000);\n" +" $(\"#doc-content\").animate({\n" +" scrollTop: anchor.position().top +\n" +" $('#doc-content').scrollTop() -\n" +" $('#doc-content').offset().top\n" +" },500,function(){\n" +" $(location).attr('href',aname);\n" +" });\n" +" };\n" +" }\n" +" else\n" +" {\n" +" a.href = node.relpath+link;\n" +" }\n" " } \n" " else \n" " {\n" @@ -116,7 +172,6 @@ " a.className = \"nolink\";\n" " a.href = \"javascript:void(0)\";\n" " a.onclick = node.expandToggle.onclick;\n" -" node.expanded = false;\n" " }\n" " }\n" "\n" @@ -141,34 +196,128 @@ " var headerHeight = $(\"#top\").height();\n" " var footerHeight = $(\"#nav-path\").height();\n" " var windowHeight = $(window).height() - headerHeight - footerHeight;\n" -" navtree.scrollTo('#selected',0,{offset:-windowHeight/2});\n" +" (function (){ // retry until we can scroll to the selected item\n" +" try {\n" +" navtree.scrollTo('#selected',0,{offset:-windowHeight/2});\n" +" } catch (err) {\n" +" setTimeout(arguments.callee, 0);\n" +" }\n" +" })();\n" "}\n" "\n" -"function expandNode(o, node, imm)\n" +"function expandNode(o, node, imm, showRoot)\n" "{\n" " if (node.childrenData && !node.expanded) \n" " {\n" -" if (!node.childrenVisited) \n" +" if (typeof(node.childrenData)==='string')\n" " {\n" -" getNode(o, node);\n" +" var varName = node.childrenData;\n" +" getScript(node.relpath+varName,function(){\n" +" node.childrenData = getData(varName);\n" +" expandNode(o, node, imm, showRoot);\n" +" }, showRoot);\n" " }\n" -" if (imm)\n" -" {\n" -" $(node.getChildrenUL()).show();\n" -" } \n" -" else \n" +" else\n" " {\n" -" $(node.getChildrenUL()).slideDown(\"fast\",showRoot);\n" +" if (!node.childrenVisited) \n" +" {\n" +" getNode(o, node);\n" +" }\n" +" if (imm)\n" +" {\n" +" $(node.getChildrenUL()).show();\n" +" } \n" +" else \n" +" {\n" +" $(node.getChildrenUL()).slideDown(\"fast\");\n" +" }\n" +" if (node.isLast)\n" +" {\n" +" node.plus_img.src = node.relpath+\"ftv2mlastnode.png\";\n" +" }\n" +" else\n" +" {\n" +" node.plus_img.src = node.relpath+\"ftv2mnode.png\";\n" +" }\n" +" node.expanded = true;\n" " }\n" -" if (node.isLast)\n" +" }\n" +"}\n" +"\n" +"function showNode(o, node, index)\n" +"{\n" +" if (node.childrenData && !node.expanded) \n" +" {\n" +" if (typeof(node.childrenData)==='string')\n" " {\n" -" node.plus_img.src = node.relpath+\"ftv2mlastnode.png\";\n" +" var varName = node.childrenData;\n" +" getScript(node.relpath+varName,function(){\n" +" node.childrenData = getData(varName);\n" +" showNode(o,node,index);\n" +" },true);\n" " }\n" " else\n" " {\n" -" node.plus_img.src = node.relpath+\"ftv2mnode.png\";\n" +" if (!node.childrenVisited) \n" +" {\n" +" getNode(o, node);\n" +" }\n" +" $(node.getChildrenUL()).show();\n" +" if (node.isLast)\n" +" {\n" +" node.plus_img.src = node.relpath+\"ftv2mlastnode.png\";\n" +" }\n" +" else\n" +" {\n" +" node.plus_img.src = node.relpath+\"ftv2mnode.png\";\n" +" }\n" +" node.expanded = true;\n" +" var n = node.children[o.breadcrumbs[index]];\n" +" if (index+1<o.breadcrumbs.length)\n" +" {\n" +" showNode(o,n,index+1);\n" +" }\n" +" else\n" +" {\n" +" if (typeof(n.childrenData)==='string')\n" +" {\n" +" var varName = n.childrenData;\n" +" getScript(n.relpath+varName,function(){\n" +" n.childrenData = getData(varName);\n" +" node.expanded=false;\n" +" showNode(o,node,index); // retry with child node expanded\n" +" },true);\n" +" }\n" +" else\n" +" {\n" +" if (o.toroot==\"index.html\" || n.childrenData)\n" +" {\n" +" expandNode(o, n, true, true);\n" +" }\n" +" var a;\n" +" if ($(location).attr('hash'))\n" +" {\n" +" var link=stripPath($(location).attr('pathname'))+':'+\n" +" $(location).attr('hash').substring(1);\n" +" a=$('.item a[class*=\\\"\"'+link+'\"\\\"]');\n" +" }\n" +" if (a && a.length)\n" +" {\n" +" a.parent().parent().addClass('selected');\n" +" a.parent().parent().attr('id','selected');\n" +" var anchor = $($(location).attr('hash'));\n" +" var targetDiv = anchor.next();\n" +" $(targetDiv).children('.memproto,.memdoc').\n" +" effect(\"highlight\", {}, 3000);\n" +" }\n" +" else\n" +" {\n" +" $(n.itemDiv).addClass('selected');\n" +" $(n.itemDiv).attr('id','selected');\n" +" }\n" +" }\n" +" }\n" " }\n" -" node.expanded = true;\n" " }\n" "}\n" "\n" @@ -180,33 +329,10 @@ " {\n" " var nodeData = po.childrenData[i];\n" " po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2],\n" -" i==l);\n" +" i==l);\n" " }\n" "}\n" "\n" -"function findNavTreePage(url, data)\n" -"{\n" -" var nodes = data;\n" -" var result = null;\n" -" for (var i in nodes) \n" -" {\n" -" var d = nodes[i];\n" -" if (d[1] == url) \n" -" {\n" -" return new Array(i);\n" -" }\n" -" else if (d[2] != null) // array of children\n" -" {\n" -" result = findNavTreePage(url, d[2]);\n" -" if (result != null) \n" -" {\n" -" return (new Array(i).concat(result));\n" -" }\n" -" }\n" -" }\n" -" return null;\n" -"}\n" -"\n" "function initNavTree(toroot,relpath)\n" "{\n" " var o = new Object();\n" @@ -220,26 +346,23 @@ " o.node.li.appendChild(o.node.childrenUL);\n" " o.node.depth = 0;\n" " o.node.relpath = relpath;\n" +" o.node.expanded = false;\n" +" o.node.isLast = true;\n" +" o.node.plus_img = document.createElement(\"img\");\n" +" o.node.plus_img.src = relpath+\"ftv2pnode.png\";\n" +" o.node.plus_img.width = 16;\n" +" o.node.plus_img.height = 22;\n" "\n" -" getNode(o, o.node);\n" -"\n" -" o.breadcrumbs = findNavTreePage(toroot, NAVTREE);\n" -" if (o.breadcrumbs == null)\n" -" {\n" -" o.breadcrumbs = findNavTreePage(\"index.html\",NAVTREE);\n" -" }\n" -" if (o.breadcrumbs != null && o.breadcrumbs.length>0)\n" -" {\n" -" var p = o.node;\n" -" for (var i in o.breadcrumbs) \n" -" {\n" -" var j = o.breadcrumbs[i];\n" -" p = p.children[j];\n" -" expandNode(o,p,true);\n" +" getScript(relpath+\"navtreeindex\",function(){\n" +" var navTreeIndex = eval('NAVTREEINDEX');\n" +" if (navTreeIndex) {\n" +" o.breadcrumbs = navTreeIndex[toroot];\n" +" if (o.breadcrumbs==null) o.breadcrumbs = navTreeIndex[\"index.html\"];\n" +" o.breadcrumbs.unshift(0);\n" +" showNode(o, o.node, 0);\n" " }\n" -" p.itemDiv.className = p.itemDiv.className + \" selected\";\n" -" p.itemDiv.id = \"selected\";\n" -" $(window).load(showRoot);\n" -" }\n" +" },true);\n" +"\n" +" $(window).load(showRoot);\n" "}\n" "\n" |