summaryrefslogtreecommitdiffstats
path: root/src/navtree.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/navtree.js')
-rw-r--r--src/navtree.js205
1 files changed, 76 insertions, 129 deletions
diff --git a/src/navtree.js b/src/navtree.js
index f3c0380..b0c4936 100644
--- a/src/navtree.js
+++ b/src/navtree.js
@@ -26,80 +26,54 @@ function getScript(scriptName,func,show)
function createIndent(o,domNode,node,level)
{
- if (node.parentNode && node.parentNode.parentNode)
- {
+ if (node.parentNode && node.parentNode.parentNode) {
createIndent(o,domNode,node.parentNode,level+1);
}
var imgNode = document.createElement("img");
imgNode.width = 16;
imgNode.height = 22;
- if (level==0 && node.childrenData)
- {
+ if (level==0 && node.childrenData) {
node.plus_img = imgNode;
node.expandToggle = document.createElement("a");
node.expandToggle.href = "javascript:void(0)";
- node.expandToggle.onclick = function()
- {
- if (node.expanded)
- {
+ node.expandToggle.onclick = function() {
+ if (node.expanded) {
$(node.getChildrenUL()).slideUp("fast");
- if (node.isLast)
- {
+ if (node.isLast) {
node.plus_img.src = node.relpath+"ftv2plastnode.png";
- }
- else
- {
+ } else {
node.plus_img.src = node.relpath+"ftv2pnode.png";
}
node.expanded = false;
- }
- else
- {
+ } else {
expandNode(o, node, false, false);
}
}
node.expandToggle.appendChild(imgNode);
domNode.appendChild(node.expandToggle);
- }
- else
- {
+ } else {
domNode.appendChild(imgNode);
}
- if (level==0)
- {
- if (node.isLast)
- {
- if (node.childrenData)
- {
+ if (level==0) {
+ if (node.isLast) {
+ if (node.childrenData) {
imgNode.src = node.relpath+"ftv2plastnode.png";
- }
- else
- {
+ } else {
imgNode.src = node.relpath+"ftv2lastnode.png";
domNode.appendChild(imgNode);
}
- }
- else
- {
- if (node.childrenData)
- {
+ } else {
+ if (node.childrenData) {
imgNode.src = node.relpath+"ftv2pnode.png";
- }
- else
- {
+ } else {
imgNode.src = node.relpath+"ftv2node.png";
domNode.appendChild(imgNode);
}
}
- }
- else
- {
- if (node.isLast)
- {
+ } else {
+ if (node.isLast) {
imgNode.src = node.relpath+"ftv2blank.png";
- }
- else
- {
+ } else {
imgNode.src = node.relpath+"ftv2vertline.png";
}
}
@@ -134,37 +108,45 @@ function newNode(o, po, text, link, childrenData, lastNode)
node.label = document.createTextNode(text);
node.expanded = false;
a.appendChild(node.label);
- if (link)
- {
+ if (link) {
+ var url;
+ if (link.substring(0,1)=='^') {
+ url = link.substring(1);
+ link = url;
+ } else {
+ url = node.relpath+link;
+ }
a.className = stripPath(link.replace('#',':'));
- if (link.indexOf('#')!=-1)
- {
+ if (link.indexOf('#')!=-1) {
var aname = '#'+link.split('#')[1];
var srcPage = stripPath($(location).attr('pathname'));
var targetPage = stripPath(link.split('#')[0]);
- a.href = srcPage!=targetPage ? node.relpath+link : '#';
+ a.href = srcPage!=targetPage ? url : '#';
a.onclick = function(){
$('.item').removeClass('selected');
$('.item').removeAttr('id');
$(a).parent().parent().addClass('selected');
$(a).parent().parent().attr('id','selected');
- var anchor = $(aname);
- $("#doc-content").animate({
- scrollTop: anchor.position().top +
- $('#doc-content').scrollTop() -
- $('#doc-content').offset().top
- },500,function(){
+ var pos, anchor = $(aname), docContent = $('#doc-content');
+ if (anchor.parent().attr('class')=='memItemLeft') {
+ pos = anchor.parent().position().top;
+ } else {
+ pos = anchor.position().top;
+ }
+ var dist = Math.abs(Math.min(
+ pos-docContent.offset().top,
+ docContent[0].scrollHeight-
+ docContent.height()-docContent.scrollTop()));
+ docContent.animate({
+ scrollTop: pos + docContent.scrollTop() - docContent.offset().top
+ },Math.max(50,Math.min(500,dist)),function(){
window.location.replace(aname);
});
};
+ } else {
+ a.href = url;
}
- else
- {
- a.href = node.relpath+link;
- }
- }
- else
- {
+ } else {
if (childrenData != null)
{
a.className = "nolink";
@@ -174,10 +156,8 @@ function newNode(o, po, text, link, childrenData, lastNode)
}
node.childrenUL = null;
- node.getChildrenUL = function()
- {
- if (!node.childrenUL)
- {
+ node.getChildrenUL = function() {
+ if (!node.childrenUL) {
node.childrenUL = document.createElement("ul");
node.childrenUL.className = "children_ul";
node.childrenUL.style.display = "none";
@@ -205,36 +185,24 @@ function showRoot()
function expandNode(o, node, imm, showRoot)
{
- if (node.childrenData && !node.expanded)
- {
- if (typeof(node.childrenData)==='string')
- {
+ if (node.childrenData && !node.expanded) {
+ if (typeof(node.childrenData)==='string') {
var varName = node.childrenData;
getScript(node.relpath+varName,function(){
node.childrenData = getData(varName);
expandNode(o, node, imm, showRoot);
}, showRoot);
- }
- else
- {
- if (!node.childrenVisited)
- {
+ } else {
+ if (!node.childrenVisited) {
getNode(o, node);
- }
- if (imm)
- {
+ } if (imm) {
$(node.getChildrenUL()).show();
- }
- else
- {
+ } else {
$(node.getChildrenUL()).slideDown("fast");
}
- if (node.isLast)
- {
+ if (node.isLast) {
node.plus_img.src = node.relpath+"ftv2mlastnode.png";
- }
- else
- {
+ } else {
node.plus_img.src = node.relpath+"ftv2mnode.png";
}
node.expanded = true;
@@ -244,72 +212,53 @@ function expandNode(o, node, imm, showRoot)
function showNode(o, node, index)
{
- if (node.childrenData && !node.expanded)
- {
- if (typeof(node.childrenData)==='string')
- {
+ if (node.childrenData && !node.expanded) {
+ if (typeof(node.childrenData)==='string') {
var varName = node.childrenData;
getScript(node.relpath+varName,function(){
node.childrenData = getData(varName);
showNode(o,node,index);
},true);
- }
- else
- {
- if (!node.childrenVisited)
- {
+ } else {
+ if (!node.childrenVisited) {
getNode(o, node);
}
$(node.getChildrenUL()).show();
- if (node.isLast)
- {
+ if (node.isLast) {
node.plus_img.src = node.relpath+"ftv2mlastnode.png";
- }
- else
- {
+ } else {
node.plus_img.src = node.relpath+"ftv2mnode.png";
}
node.expanded = true;
var n = node.children[o.breadcrumbs[index]];
- if (index+1<o.breadcrumbs.length)
- {
+ if (index+1<o.breadcrumbs.length) {
showNode(o,n,index+1);
- }
- else
- {
- if (typeof(n.childrenData)==='string')
- {
+ } else {
+ if (typeof(n.childrenData)==='string') {
var varName = n.childrenData;
getScript(n.relpath+varName,function(){
n.childrenData = getData(varName);
node.expanded=false;
showNode(o,node,index); // retry with child node expanded
},true);
- }
- else
- {
- if (o.toroot=="index.html" || n.childrenData)
- {
+ } else {
+ if (o.toroot=="index.html" || n.childrenData) {
expandNode(o, n, true, true);
}
var a;
- if ($(location).attr('hash'))
- {
+ if ($(location).attr('hash')) {
var link=stripPath($(location).attr('pathname'))+':'+
$(location).attr('hash').substring(1);
a=$('.item a[class*=\""'+link+'"\"]');
}
- if (a && a.length)
- {
+ if (a && a.length) {
a.parent().parent().addClass('selected');
a.parent().parent().attr('id','selected');
var anchor = $($(location).attr('hash'));
var targetDiv = anchor.next();
$(targetDiv).children('.memproto,.memdoc').
effect("highlight", {}, 1500);
- }
- else
- {
+ } else {
$(n.itemDiv).addClass('selected');
$(n.itemDiv).attr('id','selected');
}
@@ -323,8 +272,7 @@ function getNode(o, po)
{
po.childrenVisited = true;
var l = po.childrenData.length-1;
- for (var i in po.childrenData)
- {
+ for (var i in po.childrenData) {
var nodeData = po.childrenData[i];
po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2],
i==l);
@@ -364,11 +312,13 @@ function initNavTree(toroot,relpath)
$(window).bind('hashchange', function(){
if (window.location.hash && window.location.hash.length>1){
var anchor = $(window.location.hash);
- var targetDiv = anchor.next();
- $(targetDiv).children('.memproto,.memdoc').effect("highlight",{},1500);
- var docContent = $('#doc-content');
- if (docContent && anchor && anchor[0] && anchor[0].ownerDocument){
- docContent.scrollTop(anchor.position().top+docContent.scrollTop()-docContent.offset().top);
+ if (anchor.parent().attr('class')=='memItemLeft'){
+ var rows = $('.memberdecls tr[class$=\""'+
+ window.location.hash.substring(1)+'"\"]').children();
+ rows.effect('highlight',{},1500);
+ } else {
+ var targetDiv = anchor.next();
+ $(targetDiv).children('.memproto,.memdoc').effect("highlight",{},1500);
}
var a;
if ($(location).attr('hash')){
@@ -385,9 +335,6 @@ function initNavTree(toroot,relpath)
var targetDiv = anchor.next();
showRoot();
}
- } else {
- var docContent = $('#doc-content');
- if (docContent){ docContent.scrollTop(0); }
}
})