annotate code-docs/navtree.js @ 3:5c2683745b33 vamp-plugin-sdk-v2.4

Update for 2.4
author Chris Cannam
date Fri, 13 Jul 2012 13:30:27 +0100
parents 3c430ef1ed66
children 27319718b1f8
rev   line source
Chris@1 1 var NAVTREE =
Chris@1 2 [
Chris@1 3 [ "VampPluginSDK", "index.html", [
Chris@1 4 [ "Vamp Plugin SDK", "index.html", null ],
Chris@3 5 [ "Namespaces", null, [
Chris@3 6 [ "Namespace List", "namespaces.html", "namespaces" ],
Chris@3 7 [ "Namespace Members", "namespacemembers.html", [
Chris@3 8 [ "All", "namespacemembers.html", null ],
Chris@3 9 [ "Functions", "namespacemembers_func.html", null ]
Chris@3 10 ] ]
Chris@1 11 ] ],
Chris@3 12 [ "Classes", null, [
Chris@3 13 [ "Class List", "annotated.html", "annotated" ],
Chris@3 14 [ "Class Hierarchy", "hierarchy.html", "hierarchy" ],
Chris@3 15 [ "Class Members", "functions.html", [
Chris@3 16 [ "All", "functions.html", "functions_dup" ],
Chris@3 17 [ "Functions", "functions_func.html", "functions_func" ],
Chris@3 18 [ "Variables", "functions_vars.html", null ],
Chris@3 19 [ "Typedefs", "functions_type.html", null ],
Chris@3 20 [ "Enumerations", "functions_enum.html", null ],
Chris@3 21 [ "Enumerator", "functions_eval.html", null ]
Chris@3 22 ] ]
Chris@1 23 ] ],
Chris@3 24 [ "Files", null, [
Chris@3 25 [ "File List", "files.html", "files" ],
Chris@3 26 [ "File Members", "globals.html", [
Chris@3 27 [ "All", "globals.html", null ],
Chris@3 28 [ "Functions", "globals_func.html", null ],
Chris@3 29 [ "Variables", "globals_vars.html", null ],
Chris@3 30 [ "Typedefs", "globals_type.html", null ],
Chris@3 31 [ "Enumerations", "globals_enum.html", null ],
Chris@3 32 [ "Enumerator", "globals_eval.html", null ],
Chris@3 33 [ "Defines", "globals_defs.html", null ]
Chris@3 34 ] ]
Chris@1 35 ] ],
Chris@3 36 [ "Directories", "dirs.html", "dirs" ]
Chris@1 37 ] ]
Chris@1 38 ];
Chris@1 39
Chris@3 40 function getData(varName)
Chris@3 41 {
Chris@3 42 var i = varName.lastIndexOf('/');
Chris@3 43 var n = i>=0 ? varName.substring(i+1) : varName;
Chris@3 44 return eval(n);
Chris@3 45 }
Chris@3 46
Chris@3 47 function stripPath(uri)
Chris@3 48 {
Chris@3 49 return uri.substring(uri.lastIndexOf('/')+1);
Chris@3 50 }
Chris@3 51
Chris@3 52 function getScript(scriptName,func,show)
Chris@3 53 {
Chris@3 54 var head = document.getElementsByTagName("head")[0];
Chris@3 55 var script = document.createElement('script');
Chris@3 56 script.id = scriptName;
Chris@3 57 script.type = 'text/javascript';
Chris@3 58 script.onload = func;
Chris@3 59 script.src = scriptName+'.js';
Chris@3 60 script.onreadystatechange = function() {
Chris@3 61 if (script.readyState=='complete' || script.readyState=='loaded') {
Chris@3 62 func(); if (show) showRoot();
Chris@3 63 }
Chris@3 64 };
Chris@3 65 head.appendChild(script);
Chris@3 66 }
Chris@3 67
Chris@1 68 function createIndent(o,domNode,node,level)
Chris@1 69 {
Chris@3 70 if (node.parentNode && node.parentNode.parentNode) {
Chris@1 71 createIndent(o,domNode,node.parentNode,level+1);
Chris@1 72 }
Chris@1 73 var imgNode = document.createElement("img");
Chris@3 74 imgNode.width = 16;
Chris@3 75 imgNode.height = 22;
Chris@3 76 if (level==0 && node.childrenData) {
Chris@1 77 node.plus_img = imgNode;
Chris@1 78 node.expandToggle = document.createElement("a");
Chris@1 79 node.expandToggle.href = "javascript:void(0)";
Chris@3 80 node.expandToggle.onclick = function() {
Chris@3 81 if (node.expanded) {
Chris@1 82 $(node.getChildrenUL()).slideUp("fast");
Chris@3 83 if (node.isLast) {
Chris@1 84 node.plus_img.src = node.relpath+"ftv2plastnode.png";
Chris@3 85 } else {
Chris@1 86 node.plus_img.src = node.relpath+"ftv2pnode.png";
Chris@1 87 }
Chris@1 88 node.expanded = false;
Chris@3 89 } else {
Chris@3 90 expandNode(o, node, false, false);
Chris@1 91 }
Chris@1 92 }
Chris@1 93 node.expandToggle.appendChild(imgNode);
Chris@1 94 domNode.appendChild(node.expandToggle);
Chris@3 95 } else {
Chris@1 96 domNode.appendChild(imgNode);
Chris@1 97 }
Chris@3 98 if (level==0) {
Chris@3 99 if (node.isLast) {
Chris@3 100 if (node.childrenData) {
Chris@1 101 imgNode.src = node.relpath+"ftv2plastnode.png";
Chris@3 102 } else {
Chris@1 103 imgNode.src = node.relpath+"ftv2lastnode.png";
Chris@1 104 domNode.appendChild(imgNode);
Chris@1 105 }
Chris@3 106 } else {
Chris@3 107 if (node.childrenData) {
Chris@1 108 imgNode.src = node.relpath+"ftv2pnode.png";
Chris@3 109 } else {
Chris@1 110 imgNode.src = node.relpath+"ftv2node.png";
Chris@1 111 domNode.appendChild(imgNode);
Chris@1 112 }
Chris@1 113 }
Chris@3 114 } else {
Chris@3 115 if (node.isLast) {
Chris@1 116 imgNode.src = node.relpath+"ftv2blank.png";
Chris@3 117 } else {
Chris@1 118 imgNode.src = node.relpath+"ftv2vertline.png";
Chris@1 119 }
Chris@1 120 }
Chris@1 121 imgNode.border = "0";
Chris@1 122 }
Chris@1 123
Chris@1 124 function newNode(o, po, text, link, childrenData, lastNode)
Chris@1 125 {
Chris@1 126 var node = new Object();
Chris@1 127 node.children = Array();
Chris@1 128 node.childrenData = childrenData;
Chris@1 129 node.depth = po.depth + 1;
Chris@1 130 node.relpath = po.relpath;
Chris@1 131 node.isLast = lastNode;
Chris@1 132
Chris@1 133 node.li = document.createElement("li");
Chris@1 134 po.getChildrenUL().appendChild(node.li);
Chris@1 135 node.parentNode = po;
Chris@1 136
Chris@1 137 node.itemDiv = document.createElement("div");
Chris@1 138 node.itemDiv.className = "item";
Chris@1 139
Chris@1 140 node.labelSpan = document.createElement("span");
Chris@1 141 node.labelSpan.className = "label";
Chris@1 142
Chris@1 143 createIndent(o,node.itemDiv,node,0);
Chris@1 144 node.itemDiv.appendChild(node.labelSpan);
Chris@1 145 node.li.appendChild(node.itemDiv);
Chris@1 146
Chris@1 147 var a = document.createElement("a");
Chris@1 148 node.labelSpan.appendChild(a);
Chris@1 149 node.label = document.createTextNode(text);
Chris@3 150 node.expanded = false;
Chris@1 151 a.appendChild(node.label);
Chris@3 152 if (link) {
Chris@3 153 var url;
Chris@3 154 if (link.substring(0,1)=='^') {
Chris@3 155 url = link.substring(1);
Chris@3 156 link = url;
Chris@3 157 } else {
Chris@3 158 url = node.relpath+link;
Chris@3 159 }
Chris@3 160 a.className = stripPath(link.replace('#',':'));
Chris@3 161 if (link.indexOf('#')!=-1) {
Chris@3 162 var aname = '#'+link.split('#')[1];
Chris@3 163 var srcPage = stripPath($(location).attr('pathname'));
Chris@3 164 var targetPage = stripPath(link.split('#')[0]);
Chris@3 165 a.href = srcPage!=targetPage ? url : '#';
Chris@3 166 a.onclick = function(){
Chris@3 167 if (!$(a).parent().parent().hasClass('selected'))
Chris@3 168 {
Chris@3 169 $('.item').removeClass('selected');
Chris@3 170 $('.item').removeAttr('id');
Chris@3 171 $(a).parent().parent().addClass('selected');
Chris@3 172 $(a).parent().parent().attr('id','selected');
Chris@3 173 }
Chris@3 174 var pos, anchor = $(aname), docContent = $('#doc-content');
Chris@3 175 if (anchor.parent().attr('class')=='memItemLeft') {
Chris@3 176 pos = anchor.parent().position().top;
Chris@3 177 } else {
Chris@3 178 pos = anchor.position().top;
Chris@3 179 }
Chris@3 180 var dist = Math.abs(Math.min(
Chris@3 181 pos-docContent.offset().top,
Chris@3 182 docContent[0].scrollHeight-
Chris@3 183 docContent.height()-docContent.scrollTop()));
Chris@3 184 docContent.animate({
Chris@3 185 scrollTop: pos + docContent.scrollTop() - docContent.offset().top
Chris@3 186 },Math.max(50,Math.min(500,dist)),function(){
Chris@3 187 window.location.replace(aname);
Chris@3 188 });
Chris@3 189 };
Chris@3 190 } else {
Chris@3 191 a.href = url;
Chris@3 192 }
Chris@3 193 } else {
Chris@1 194 if (childrenData != null)
Chris@1 195 {
Chris@1 196 a.className = "nolink";
Chris@1 197 a.href = "javascript:void(0)";
Chris@1 198 a.onclick = node.expandToggle.onclick;
Chris@1 199 }
Chris@1 200 }
Chris@1 201
Chris@1 202 node.childrenUL = null;
Chris@3 203 node.getChildrenUL = function() {
Chris@3 204 if (!node.childrenUL) {
Chris@1 205 node.childrenUL = document.createElement("ul");
Chris@1 206 node.childrenUL.className = "children_ul";
Chris@1 207 node.childrenUL.style.display = "none";
Chris@1 208 node.li.appendChild(node.childrenUL);
Chris@1 209 }
Chris@1 210 return node.childrenUL;
Chris@1 211 };
Chris@1 212
Chris@1 213 return node;
Chris@1 214 }
Chris@1 215
Chris@1 216 function showRoot()
Chris@1 217 {
Chris@1 218 var headerHeight = $("#top").height();
Chris@1 219 var footerHeight = $("#nav-path").height();
Chris@1 220 var windowHeight = $(window).height() - headerHeight - footerHeight;
Chris@3 221 (function (){ // retry until we can scroll to the selected item
Chris@3 222 try {
Chris@3 223 navtree.scrollTo('#selected',0,{offset:-windowHeight/2});
Chris@3 224 } catch (err) {
Chris@3 225 setTimeout(arguments.callee, 0);
Chris@3 226 }
Chris@3 227 })();
Chris@1 228 }
Chris@1 229
Chris@3 230 function expandNode(o, node, imm, showRoot)
Chris@1 231 {
Chris@3 232 if (node.childrenData && !node.expanded) {
Chris@3 233 if (typeof(node.childrenData)==='string') {
Chris@3 234 var varName = node.childrenData;
Chris@3 235 getScript(node.relpath+varName,function(){
Chris@3 236 node.childrenData = getData(varName);
Chris@3 237 expandNode(o, node, imm, showRoot);
Chris@3 238 }, showRoot);
Chris@3 239 } else {
Chris@3 240 if (!node.childrenVisited) {
Chris@3 241 getNode(o, node);
Chris@3 242 } if (imm) {
Chris@3 243 $(node.getChildrenUL()).show();
Chris@3 244 } else {
Chris@3 245 $(node.getChildrenUL()).slideDown("fast");
Chris@3 246 }
Chris@3 247 if (node.isLast) {
Chris@3 248 node.plus_img.src = node.relpath+"ftv2mlastnode.png";
Chris@3 249 } else {
Chris@3 250 node.plus_img.src = node.relpath+"ftv2mnode.png";
Chris@3 251 }
Chris@3 252 node.expanded = true;
Chris@1 253 }
Chris@3 254 }
Chris@3 255 }
Chris@3 256
Chris@3 257 function highlightAnchor()
Chris@3 258 {
Chris@3 259 var anchor = $($(location).attr('hash'));
Chris@3 260 if (anchor.parent().attr('class')=='memItemLeft'){
Chris@3 261 var rows = $('.memberdecls tr[class$=\""'+
Chris@3 262 window.location.hash.substring(1)+'"\"]').children();
Chris@3 263 rows.effect('highlight',{},1500);
Chris@3 264 } else if (anchor.parent().is(":header")) {
Chris@3 265 anchor.parent().effect('highlight',{},1500);
Chris@3 266 } else {
Chris@3 267 var targetDiv = anchor.next();
Chris@3 268 $(targetDiv).children('.memproto,.memdoc').effect("highlight",{},1500);
Chris@3 269 }
Chris@3 270 }
Chris@3 271
Chris@3 272 function showNode(o, node, index)
Chris@3 273 {
Chris@3 274 if (node.childrenData /*&& !node.expanded*/) {
Chris@3 275 if (typeof(node.childrenData)==='string') {
Chris@3 276 var varName = node.childrenData;
Chris@3 277 getScript(node.relpath+varName,function(){
Chris@3 278 node.childrenData = getData(varName);
Chris@3 279 showNode(o,node,index);
Chris@3 280 },true);
Chris@3 281 } else {
Chris@3 282 if (!node.childrenVisited) {
Chris@3 283 getNode(o, node);
Chris@3 284 }
Chris@1 285 $(node.getChildrenUL()).show();
Chris@3 286 if (node.isLast) {
Chris@3 287 node.plus_img.src = node.relpath+"ftv2mlastnode.png";
Chris@3 288 } else {
Chris@3 289 node.plus_img.src = node.relpath+"ftv2mnode.png";
Chris@3 290 }
Chris@3 291 node.expanded = true;
Chris@3 292 var n = node.children[o.breadcrumbs[index]];
Chris@3 293 if (index+1<o.breadcrumbs.length) {
Chris@3 294 showNode(o,n,index+1);
Chris@3 295 } else {
Chris@3 296 if (typeof(n.childrenData)==='string') {
Chris@3 297 var varName = n.childrenData;
Chris@3 298 getScript(n.relpath+varName,function(){
Chris@3 299 n.childrenData = getData(varName);
Chris@3 300 node.expanded=false;
Chris@3 301 showNode(o,node,index); // retry with child node expanded
Chris@3 302 },true);
Chris@3 303 } else {
Chris@3 304 if (o.toroot=="index.html" || n.childrenData) {
Chris@3 305 expandNode(o, n, true, true);
Chris@3 306 }
Chris@3 307 var a;
Chris@3 308 if ($(location).attr('hash')) {
Chris@3 309 var link=stripPath($(location).attr('pathname'))+':'+
Chris@3 310 $(location).attr('hash').substring(1);
Chris@3 311 a=$('.item a[class$=\""'+link+'"\"]');
Chris@3 312 }
Chris@3 313 if (a && a.length) {
Chris@3 314 a.parent().parent().addClass('selected');
Chris@3 315 a.parent().parent().attr('id','selected');
Chris@3 316 highlightAnchor();
Chris@3 317 } else {
Chris@3 318 $(n.itemDiv).addClass('selected');
Chris@3 319 $(n.itemDiv).attr('id','selected');
Chris@3 320 }
Chris@3 321 showRoot();
Chris@3 322 }
Chris@3 323 }
Chris@1 324 }
Chris@1 325 }
Chris@1 326 }
Chris@1 327
Chris@1 328 function getNode(o, po)
Chris@1 329 {
Chris@1 330 po.childrenVisited = true;
Chris@1 331 var l = po.childrenData.length-1;
Chris@3 332 for (var i in po.childrenData) {
Chris@1 333 var nodeData = po.childrenData[i];
Chris@1 334 po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2],
Chris@3 335 i==l);
Chris@1 336 }
Chris@1 337 }
Chris@1 338
Chris@3 339 function navTo(o,root,hash,relpath)
Chris@1 340 {
Chris@3 341 getScript(relpath+"navtreeindex",function(){
Chris@3 342 var navTreeIndex = eval('NAVTREEINDEX');
Chris@3 343 if (navTreeIndex) {
Chris@3 344 var nti = navTreeIndex[root+hash];
Chris@3 345 o.breadcrumbs = nti ? nti : navTreeIndex[root];
Chris@3 346 if (o.breadcrumbs==null) o.breadcrumbs = navTreeIndex["index.html"];
Chris@3 347 o.breadcrumbs.unshift(0);
Chris@3 348 showNode(o, o.node, 0);
Chris@1 349 }
Chris@3 350 },true);
Chris@1 351 }
Chris@1 352
Chris@1 353 function initNavTree(toroot,relpath)
Chris@1 354 {
Chris@1 355 var o = new Object();
Chris@1 356 o.toroot = toroot;
Chris@1 357 o.node = new Object();
Chris@1 358 o.node.li = document.getElementById("nav-tree-contents");
Chris@1 359 o.node.childrenData = NAVTREE;
Chris@1 360 o.node.children = new Array();
Chris@1 361 o.node.childrenUL = document.createElement("ul");
Chris@1 362 o.node.getChildrenUL = function() { return o.node.childrenUL; };
Chris@1 363 o.node.li.appendChild(o.node.childrenUL);
Chris@1 364 o.node.depth = 0;
Chris@1 365 o.node.relpath = relpath;
Chris@3 366 o.node.expanded = false;
Chris@3 367 o.node.isLast = true;
Chris@3 368 o.node.plus_img = document.createElement("img");
Chris@3 369 o.node.plus_img.src = relpath+"ftv2pnode.png";
Chris@3 370 o.node.plus_img.width = 16;
Chris@3 371 o.node.plus_img.height = 22;
Chris@1 372
Chris@3 373 navTo(o,toroot,window.location.hash,relpath);
Chris@1 374
Chris@3 375 $(window).bind('hashchange', function(){
Chris@3 376 if (window.location.hash && window.location.hash.length>1){
Chris@3 377 var a;
Chris@3 378 if ($(location).attr('hash')){
Chris@3 379 var clslink=stripPath($(location).attr('pathname'))+':'+
Chris@3 380 $(location).attr('hash').substring(1);
Chris@3 381 a=$('.item a[class$=\""'+clslink+'"\"]');
Chris@3 382 }
Chris@3 383 if (a==null || !$(a).parent().parent().hasClass('selected')){
Chris@3 384 $('.item').removeClass('selected');
Chris@3 385 $('.item').removeAttr('id');
Chris@3 386 }
Chris@3 387 var link=stripPath($(location).attr('pathname'));
Chris@3 388 navTo(o,link,$(location).attr('hash'),relpath);
Chris@3 389 }
Chris@3 390 })
Chris@3 391
Chris@3 392 $(window).load(showRoot);
Chris@1 393 }
Chris@1 394