source: flair-dev/trunk/doc/Flair/navtree.js@ 14

Last change on this file since 14 was 14, checked in by Sanahuja Guillaume, 8 years ago

doc

File size: 15.8 KB
Line 
1var NAVTREE =
2[
3 [ "Flair", "index.html", [
4 [ "Namespaces", null, [
5 [ "Namespace List", "namespaces.html", "namespaces" ],
6 [ "Namespace Members", "namespacemembers.html", [
7 [ "All", "namespacemembers.html", null ],
8 [ "Functions", "namespacemembers_func.html", null ],
9 [ "Typedefs", "namespacemembers_type.html", null ]
10 ] ]
11 ] ],
12 [ "Classes", null, [
13 [ "Class List", "annotated.html", "annotated" ],
14 [ "Class Index", "classes.html", null ],
15 [ "Class Hierarchy", "hierarchy.html", "hierarchy" ],
16 [ "Class Members", "functions.html", [
17 [ "All", "functions.html", "functions_dup" ],
18 [ "Functions", "functions_func.html", "functions_func" ],
19 [ "Variables", "functions_vars.html", null ],
20 [ "Enumerations", "functions_enum.html", null ],
21 [ "Enumerator", "functions_eval.html", null ]
22 ] ]
23 ] ],
24 [ "Files", null, [
25 [ "File List", "files.html", "files" ]
26 ] ]
27 ] ]
28];
29
30var NAVTREEINDEX =
31[
32"_afro_bldc_8h.html",
33"_widget_8h.html",
34"classflair_1_1core_1_1_object.html#a3ca9694d29ec2b0491739879685df5ca",
35"classflair_1_1core_1_1cvmatrix__descriptor.html#a6bb368cea0ea8e947446d4d468f0a7bc",
36"classflair_1_1gui_1_1_picture.html",
37"classflair_1_1sensor_1_1_gps.html#ae48a8af3f5274bebb2f70524c0a42211",
38"classflair_1_1simulator_1_1_gui.html"
39];
40
41var SYNCONMSG = 'click to disable panel synchronisation';
42var SYNCOFFMSG = 'click to enable panel synchronisation';
43var navTreeSubIndices = new Array();
44
45function getData(varName)
46{
47 var i = varName.lastIndexOf('/');
48 var n = i>=0 ? varName.substring(i+1) : varName;
49 return eval(n.replace(/\-/g,'_'));
50}
51
52function stripPath(uri)
53{
54 return uri.substring(uri.lastIndexOf('/')+1);
55}
56
57function stripPath2(uri)
58{
59 var i = uri.lastIndexOf('/');
60 var s = uri.substring(i+1);
61 var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/);
62 return m ? uri.substring(i-6) : s;
63}
64
65function hashValue()
66{
67 return $(location).attr('hash').substring(1).replace(/[^\w\-]/g,'');
68}
69
70function hashUrl()
71{
72 return '#'+hashValue();
73}
74
75function pathName()
76{
77 return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g, '');
78}
79
80function localStorageSupported()
81{
82 try {
83 return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem;
84 }
85 catch(e) {
86 return false;
87 }
88}
89
90
91function storeLink(link)
92{
93 if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) {
94 window.localStorage.setItem('navpath',link);
95 }
96}
97
98function deleteLink()
99{
100 if (localStorageSupported()) {
101 window.localStorage.setItem('navpath','');
102 }
103}
104
105function cachedLink()
106{
107 if (localStorageSupported()) {
108 return window.localStorage.getItem('navpath');
109 } else {
110 return '';
111 }
112}
113
114function getScript(scriptName,func,show)
115{
116 var head = document.getElementsByTagName("head")[0];
117 var script = document.createElement('script');
118 script.id = scriptName;
119 script.type = 'text/javascript';
120 script.onload = func;
121 script.src = scriptName+'.js';
122 if ($.browser.msie && $.browser.version<=8) {
123 // script.onload does not work with older versions of IE
124 script.onreadystatechange = function() {
125 if (script.readyState=='complete' || script.readyState=='loaded') {
126 func(); if (show) showRoot();
127 }
128 }
129 }
130 head.appendChild(script);
131}
132
133function createIndent(o,domNode,node,level)
134{
135 var level=-1;
136 var n = node;
137 while (n.parentNode) { level++; n=n.parentNode; }
138 if (node.childrenData) {
139 var imgNode = document.createElement("img");
140 imgNode.style.paddingLeft=(16*level).toString()+'px';
141 imgNode.width = 16;
142 imgNode.height = 22;
143 imgNode.border = 0;
144 node.plus_img = imgNode;
145 node.expandToggle = document.createElement("a");
146 node.expandToggle.href = "javascript:void(0)";
147 node.expandToggle.onclick = function() {
148 if (node.expanded) {
149 $(node.getChildrenUL()).slideUp("fast");
150 node.plus_img.src = node.relpath+"ftv2pnode.png";
151 node.expanded = false;
152 } else {
153 expandNode(o, node, false, false);
154 }
155 }
156 node.expandToggle.appendChild(imgNode);
157 domNode.appendChild(node.expandToggle);
158 imgNode.src = node.relpath+"ftv2pnode.png";
159 } else {
160 var span = document.createElement("span");
161 span.style.display = 'inline-block';
162 span.style.width = 16*(level+1)+'px';
163 span.style.height = '22px';
164 span.innerHTML = '&#160;';
165 domNode.appendChild(span);
166 }
167}
168
169var animationInProgress = false;
170
171function gotoAnchor(anchor,aname,updateLocation)
172{
173 var pos, docContent = $('#doc-content');
174 var ancParent = $(anchor.parent());
175 if (ancParent.hasClass('memItemLeft') ||
176 ancParent.hasClass('fieldname') ||
177 ancParent.hasClass('fieldtype') ||
178 ancParent.is(':header'))
179 {
180 pos = ancParent.position().top;
181 } else if (anchor.position()) {
182 pos = anchor.position().top;
183 }
184 if (pos) {
185 var dist = Math.abs(Math.min(
186 pos-docContent.offset().top,
187 docContent[0].scrollHeight-
188 docContent.height()-docContent.scrollTop()));
189 animationInProgress=true;
190 docContent.animate({
191 scrollTop: pos + docContent.scrollTop() - docContent.offset().top
192 },Math.max(50,Math.min(500,dist)),function(){
193 if (updateLocation) window.location.href=aname;
194 animationInProgress=false;
195 });
196 }
197}
198
199function newNode(o, po, text, link, childrenData, lastNode)
200{
201 var node = new Object();
202 node.children = Array();
203 node.childrenData = childrenData;
204 node.depth = po.depth + 1;
205 node.relpath = po.relpath;
206 node.isLast = lastNode;
207
208 node.li = document.createElement("li");
209 po.getChildrenUL().appendChild(node.li);
210 node.parentNode = po;
211
212 node.itemDiv = document.createElement("div");
213 node.itemDiv.className = "item";
214
215 node.labelSpan = document.createElement("span");
216 node.labelSpan.className = "label";
217
218 createIndent(o,node.itemDiv,node,0);
219 node.itemDiv.appendChild(node.labelSpan);
220 node.li.appendChild(node.itemDiv);
221
222 var a = document.createElement("a");
223 node.labelSpan.appendChild(a);
224 node.label = document.createTextNode(text);
225 node.expanded = false;
226 a.appendChild(node.label);
227 if (link) {
228 var url;
229 if (link.substring(0,1)=='^') {
230 url = link.substring(1);
231 link = url;
232 } else {
233 url = node.relpath+link;
234 }
235 a.className = stripPath(link.replace('#',':'));
236 if (link.indexOf('#')!=-1) {
237 var aname = '#'+link.split('#')[1];
238 var srcPage = stripPath(pathName());
239 var targetPage = stripPath(link.split('#')[0]);
240 a.href = srcPage!=targetPage ? url : "javascript:void(0)";
241 a.onclick = function(){
242 storeLink(link);
243 if (!$(a).parent().parent().hasClass('selected'))
244 {
245 $('.item').removeClass('selected');
246 $('.item').removeAttr('id');
247 $(a).parent().parent().addClass('selected');
248 $(a).parent().parent().attr('id','selected');
249 }
250 var anchor = $(aname);
251 gotoAnchor(anchor,aname,true);
252 };
253 } else {
254 a.href = url;
255 a.onclick = function() { storeLink(link); }
256 }
257 } else {
258 if (childrenData != null)
259 {
260 a.className = "nolink";
261 a.href = "javascript:void(0)";
262 a.onclick = node.expandToggle.onclick;
263 }
264 }
265
266 node.childrenUL = null;
267 node.getChildrenUL = function() {
268 if (!node.childrenUL) {
269 node.childrenUL = document.createElement("ul");
270 node.childrenUL.className = "children_ul";
271 node.childrenUL.style.display = "none";
272 node.li.appendChild(node.childrenUL);
273 }
274 return node.childrenUL;
275 };
276
277 return node;
278}
279
280function showRoot()
281{
282 var headerHeight = $("#top").height();
283 var footerHeight = $("#nav-path").height();
284 var windowHeight = $(window).height() - headerHeight - footerHeight;
285 (function (){ // retry until we can scroll to the selected item
286 try {
287 var navtree=$('#nav-tree');
288 navtree.scrollTo('#selected',0,{offset:-windowHeight/2});
289 } catch (err) {
290 setTimeout(arguments.callee, 0);
291 }
292 })();
293}
294
295function expandNode(o, node, imm, showRoot)
296{
297 if (node.childrenData && !node.expanded) {
298 if (typeof(node.childrenData)==='string') {
299 var varName = node.childrenData;
300 getScript(node.relpath+varName,function(){
301 node.childrenData = getData(varName);
302 expandNode(o, node, imm, showRoot);
303 }, showRoot);
304 } else {
305 if (!node.childrenVisited) {
306 getNode(o, node);
307 } if (imm || ($.browser.msie && $.browser.version>8)) {
308 // somehow slideDown jumps to the start of tree for IE9 :-(
309 $(node.getChildrenUL()).show();
310 } else {
311 $(node.getChildrenUL()).slideDown("fast");
312 }
313 if (node.isLast) {
314 node.plus_img.src = node.relpath+"ftv2mlastnode.png";
315 } else {
316 node.plus_img.src = node.relpath+"ftv2mnode.png";
317 }
318 node.expanded = true;
319 }
320 }
321}
322
323function glowEffect(n,duration)
324{
325 n.addClass('glow').delay(duration).queue(function(next){
326 $(this).removeClass('glow');next();
327 });
328}
329
330function highlightAnchor()
331{
332 var aname = hashUrl();
333 var anchor = $(aname);
334 if (anchor.parent().attr('class')=='memItemLeft'){
335 var rows = $('.memberdecls tr[class$="'+hashValue()+'"]');
336 glowEffect(rows.children(),300); // member without details
337 } else if (anchor.parent().attr('class')=='fieldname'){
338 glowEffect(anchor.parent().parent(),1000); // enum value
339 } else if (anchor.parent().attr('class')=='fieldtype'){
340 glowEffect(anchor.parent().parent(),1000); // struct field
341 } else if (anchor.parent().is(":header")) {
342 glowEffect(anchor.parent(),1000); // section header
343 } else {
344 glowEffect(anchor.next(),1000); // normal member
345 }
346 gotoAnchor(anchor,aname,false);
347}
348
349function selectAndHighlight(hash,n)
350{
351 var a;
352 if (hash) {
353 var link=stripPath(pathName())+':'+hash.substring(1);
354 a=$('.item a[class$="'+link+'"]');
355 }
356 if (a && a.length) {
357 a.parent().parent().addClass('selected');
358 a.parent().parent().attr('id','selected');
359 highlightAnchor();
360 } else if (n) {
361 $(n.itemDiv).addClass('selected');
362 $(n.itemDiv).attr('id','selected');
363 }
364 if ($('#nav-tree-contents .item:first').hasClass('selected')) {
365 $('#nav-sync').css('top','30px');
366 } else {
367 $('#nav-sync').css('top','5px');
368 }
369 showRoot();
370}
371
372function showNode(o, node, index, hash)
373{
374 if (node && node.childrenData) {
375 if (typeof(node.childrenData)==='string') {
376 var varName = node.childrenData;
377 getScript(node.relpath+varName,function(){
378 node.childrenData = getData(varName);
379 showNode(o,node,index,hash);
380 },true);
381 } else {
382 if (!node.childrenVisited) {
383 getNode(o, node);
384 }
385 $(node.getChildrenUL()).css({'display':'block'});
386 if (node.isLast) {
387 node.plus_img.src = node.relpath+"ftv2mlastnode.png";
388 } else {
389 node.plus_img.src = node.relpath+"ftv2mnode.png";
390 }
391 node.expanded = true;
392 var n = node.children[o.breadcrumbs[index]];
393 if (index+1<o.breadcrumbs.length) {
394 showNode(o,n,index+1,hash);
395 } else {
396 if (typeof(n.childrenData)==='string') {
397 var varName = n.childrenData;
398 getScript(n.relpath+varName,function(){
399 n.childrenData = getData(varName);
400 node.expanded=false;
401 showNode(o,node,index,hash); // retry with child node expanded
402 },true);
403 } else {
404 var rootBase = stripPath(o.toroot.replace(/\..+$/, ''));
405 if (rootBase=="index" || rootBase=="pages" || rootBase=="search") {
406 expandNode(o, n, true, true);
407 }
408 selectAndHighlight(hash,n);
409 }
410 }
411 }
412 } else {
413 selectAndHighlight(hash);
414 }
415}
416
417function removeToInsertLater(element) {
418 var parentNode = element.parentNode;
419 var nextSibling = element.nextSibling;
420 parentNode.removeChild(element);
421 return function() {
422 if (nextSibling) {
423 parentNode.insertBefore(element, nextSibling);
424 } else {
425 parentNode.appendChild(element);
426 }
427 };
428}
429
430function getNode(o, po)
431{
432 var insertFunction = removeToInsertLater(po.li);
433 po.childrenVisited = true;
434 var l = po.childrenData.length-1;
435 for (var i in po.childrenData) {
436 var nodeData = po.childrenData[i];
437 po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2],
438 i==l);
439 }
440 insertFunction();
441}
442
443function gotoNode(o,subIndex,root,hash,relpath)
444{
445 var nti = navTreeSubIndices[subIndex][root+hash];
446 o.breadcrumbs = $.extend(true, [], nti ? nti : navTreeSubIndices[subIndex][root]);
447 if (!o.breadcrumbs && root!=NAVTREE[0][1]) { // fallback: show index
448 navTo(o,NAVTREE[0][1],"",relpath);
449 $('.item').removeClass('selected');
450 $('.item').removeAttr('id');
451 }
452 if (o.breadcrumbs) {
453 o.breadcrumbs.unshift(0); // add 0 for root node
454 showNode(o, o.node, 0, hash);
455 }
456}
457
458function navTo(o,root,hash,relpath)
459{
460 var link = cachedLink();
461 if (link) {
462 var parts = link.split('#');
463 root = parts[0];
464 if (parts.length>1) hash = '#'+parts[1].replace(/[^\w\-]/g,'');
465 else hash='';
466 }
467 if (hash.match(/^#l\d+$/)) {
468 var anchor=$('a[name='+hash.substring(1)+']');
469 glowEffect(anchor.parent(),1000); // line number
470 hash=''; // strip line number anchors
471 }
472 var url=root+hash;
473 var i=-1;
474 while (NAVTREEINDEX[i+1]<=url) i++;
475 if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index
476 if (navTreeSubIndices[i]) {
477 gotoNode(o,i,root,hash,relpath)
478 } else {
479 getScript(relpath+'navtreeindex'+i,function(){
480 navTreeSubIndices[i] = eval('NAVTREEINDEX'+i);
481 if (navTreeSubIndices[i]) {
482 gotoNode(o,i,root,hash,relpath);
483 }
484 },true);
485 }
486}
487
488function showSyncOff(n,relpath)
489{
490 n.html('<img src="'+relpath+'sync_off.png" title="'+SYNCOFFMSG+'"/>');
491}
492
493function showSyncOn(n,relpath)
494{
495 n.html('<img src="'+relpath+'sync_on.png" title="'+SYNCONMSG+'"/>');
496}
497
498function toggleSyncButton(relpath)
499{
500 var navSync = $('#nav-sync');
501 if (navSync.hasClass('sync')) {
502 navSync.removeClass('sync');
503 showSyncOff(navSync,relpath);
504 storeLink(stripPath2(pathName())+hashUrl());
505 } else {
506 navSync.addClass('sync');
507 showSyncOn(navSync,relpath);
508 deleteLink();
509 }
510}
511
512function initNavTree(toroot,relpath)
513{
514 var o = new Object();
515 o.toroot = toroot;
516 o.node = new Object();
517 o.node.li = document.getElementById("nav-tree-contents");
518 o.node.childrenData = NAVTREE;
519 o.node.children = new Array();
520 o.node.childrenUL = document.createElement("ul");
521 o.node.getChildrenUL = function() { return o.node.childrenUL; };
522 o.node.li.appendChild(o.node.childrenUL);
523 o.node.depth = 0;
524 o.node.relpath = relpath;
525 o.node.expanded = false;
526 o.node.isLast = true;
527 o.node.plus_img = document.createElement("img");
528 o.node.plus_img.src = relpath+"ftv2pnode.png";
529 o.node.plus_img.width = 16;
530 o.node.plus_img.height = 22;
531
532 if (localStorageSupported()) {
533 var navSync = $('#nav-sync');
534 if (cachedLink()) {
535 showSyncOff(navSync,relpath);
536 navSync.removeClass('sync');
537 } else {
538 showSyncOn(navSync,relpath);
539 }
540 navSync.click(function(){ toggleSyncButton(relpath); });
541 }
542
543 $(window).load(function(){
544 navTo(o,toroot,hashUrl(),relpath);
545 showRoot();
546 });
547
548 $(window).bind('hashchange', function(){
549 if (window.location.hash && window.location.hash.length>1){
550 var a;
551 if ($(location).attr('hash')){
552 var clslink=stripPath(pathName())+':'+hashValue();
553 a=$('.item a[class$="'+clslink.replace(/</g,'\\3c ')+'"]');
554 }
555 if (a==null || !$(a).parent().parent().hasClass('selected')){
556 $('.item').removeClass('selected');
557 $('.item').removeAttr('id');
558 }
559 var link=stripPath2(pathName());
560 navTo(o,link,hashUrl(),relpath);
561 } else if (!animationInProgress) {
562 $('#doc-content').scrollTop(0);
563 $('.item').removeClass('selected');
564 $('.item').removeAttr('id');
565 navTo(o,toroot,hashUrl(),relpath);
566 }
567 })
568}
569
Note: See TracBrowser for help on using the repository browser.