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