summaryrefslogtreecommitdiffstats
path: root/src/navtree.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/navtree.js')
-rw-r--r--src/navtree.js72
1 files changed, 46 insertions, 26 deletions
diff --git a/src/navtree.js b/src/navtree.js
index 5549d7f..d4b241a 100644
--- a/src/navtree.js
+++ b/src/navtree.js
@@ -63,7 +63,7 @@ function getScript(scriptName,func,show)
script.onload = func;
script.src = scriptName+'.js';
if ($.browser.msie && $.browser.version<=8) {
- // script.onload does work with older versions of IE
+ // script.onload does not work with older versions of IE
script.onreadystatechange = function() {
if (script.readyState=='complete' || script.readyState=='loaded') {
func(); if (show) showRoot();
@@ -129,6 +129,34 @@ function createIndent(o,domNode,node,level)
imgNode.border = "0";
}
+var animationInProgress = false;
+
+function gotoAnchor(anchor,aname,updateLocation)
+{
+ var pos, docContent = $('#doc-content');
+ if (anchor.parent().attr('class')=='memItemLeft' ||
+ anchor.parent().attr('class')=='fieldtype' ||
+ anchor.parent().is(':header'))
+ {
+ pos = anchor.parent().position().top;
+ } else if (anchor.position()) {
+ pos = anchor.position().top;
+ }
+ if (pos) {
+ var dist = Math.abs(Math.min(
+ pos-docContent.offset().top,
+ docContent[0].scrollHeight-
+ docContent.height()-docContent.scrollTop()));
+ animationInProgress=true;
+ docContent.animate({
+ scrollTop: pos + docContent.scrollTop() - docContent.offset().top
+ },Math.max(50,Math.min(500,dist)),function(){
+ if (updateLocation) window.location.href=aname;
+ animationInProgress=false;
+ });
+ }
+}
+
function newNode(o, po, text, link, childrenData, lastNode)
{
var node = new Object();
@@ -170,7 +198,7 @@ function newNode(o, po, text, link, childrenData, lastNode)
var aname = '#'+link.split('#')[1];
var srcPage = stripPath($(location).attr('pathname'));
var targetPage = stripPath(link.split('#')[0]);
- a.href = srcPage!=targetPage ? url : '#';
+ a.href = srcPage!=targetPage ? url : "javascript:void(0)";
a.onclick = function(){
storeLink(link);
if (!$(a).parent().parent().hasClass('selected'))
@@ -180,23 +208,8 @@ function newNode(o, po, text, link, childrenData, lastNode)
$(a).parent().parent().addClass('selected');
$(a).parent().parent().attr('id','selected');
}
- var pos, anchor = $(aname), docContent = $('#doc-content');
- if (anchor.parent().attr('class')=='memItemLeft') {
- pos = anchor.parent().position().top;
- } else if (anchor.position()) {
- pos = anchor.position().top;
- }
- if (pos) {
- 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);
- });
- }
+ var anchor = $(aname);
+ gotoAnchor(anchor,aname,true);
};
} else {
a.href = url;
@@ -277,7 +290,8 @@ function glowEffect(n,duration)
function highlightAnchor()
{
- var anchor = $($(location).attr('hash'));
+ var aname = $(location).attr('hash');
+ var anchor = $(aname);
if (anchor.parent().attr('class')=='memItemLeft'){
var rows = $('.memberdecls tr[class$="'+
window.location.hash.substring(1)+'"]');
@@ -291,6 +305,7 @@ function highlightAnchor()
} else {
glowEffect(anchor.next(),1000); // normal member
}
+ gotoAnchor(anchor,aname,false);
}
function selectAndHighlight(hash,n)
@@ -308,6 +323,11 @@ function selectAndHighlight(hash,n)
$(n.itemDiv).addClass('selected');
$(n.itemDiv).attr('id','selected');
}
+ if ($('#nav-tree-contents .item:first').hasClass('selected')) {
+ $('#nav-sync').css('top','30px');
+ } else {
+ $('#nav-sync').css('top','5px');
+ }
showRoot();
}
@@ -391,11 +411,6 @@ function navTo(o,root,hash,relpath)
if (parts.length>1) hash = '#'+parts[1];
else hash='';
}
- if (root==NAVTREE[0][1]) {
- $('#nav-sync').css('top','30px');
- } else {
- $('#nav-sync').css('top','5px');
- }
if (hash.match(/^#l\d+$/)) {
var anchor=$('a[name='+hash.substring(1)+']');
glowEffect(anchor.parent(),1000); // line number
@@ -424,7 +439,7 @@ function showSyncOff(n,relpath)
function showSyncOn(n,relpath)
{
- n.html('<img src="'+relpath+'sync_on.png"/ title="'+SYNCONMSG+'">');
+ n.html('<img src="'+relpath+'sync_on.png" title="'+SYNCONMSG+'"/>');
}
function toggleSyncButton(relpath)
@@ -488,6 +503,11 @@ function initNavTree(toroot,relpath)
}
var link=stripPath2($(location).attr('pathname'));
navTo(o,link,$(location).attr('hash'),relpath);
+ } else if (!animationInProgress) {
+ $('#doc-content').scrollTop(0);
+ $('.item').removeClass('selected');
+ $('.item').removeAttr('id');
+ navTo(o,toroot,window.location.hash,relpath);
}
})