navtree.js 16 KB

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