From 76441a7f63977d5325b1a1cb6b225102d3b7b564 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 26 Apr 2011 02:33:11 +0000 Subject: [PATCH] Fixed bug where anchors in pages landed beneath the banner. --- xsl/webhelp/template/common/main.js | 36 ++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/xsl/webhelp/template/common/main.js b/xsl/webhelp/template/common/main.js index 449cda8b5..925d6565d 100755 --- a/xsl/webhelp/template/common/main.js +++ b/xsl/webhelp/template/common/main.js @@ -13,6 +13,28 @@ var treesettings = { }; $(document).ready(function() { + + + // When you click on a link to an anchor, scroll down + // 105 px to cope with the fact that the banner + // hides the top 95px or so of the page. + // This code deals with the problem when + // you click on a link within a page. + $('a[href*=#]').click(function() { + if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') + && location.hostname == this.hostname) { + var $target = $(this.hash); + $target = $target.length && $target + || $('[name=' + this.hash.slice(1) +']'); + if ($target.length) { + var targetOffset = $target.offset().top - 105; + $('html,body') + .animate({scrollTop: targetOffset}, 200); + return false; + } + } + }); + // $("#showHideHighlight").button(); //add jquery button styling to 'Go' button //Generate tabs in nav-pane with JQuery $(function() { @@ -53,6 +75,18 @@ $(document).ready(function() { syncToc(); //Synchronize the toc tree with the content pane, when loading the page. //$("#doSearch").button(); //add jquery button styling to 'Go' button + + // When you click on a link to an anchor, scroll down + // 105 px to cope with the fact that the banner + // hides the top 95px or so of the page. + // This code deals with the problem when + // you click on a link from another page. + var hash = window.location.hash; + if(hash){ + var targetOffset = $(hash).offset().top - 105; + $('html,body').animate({scrollTop: targetOffset}, 200); + return false; + } }); /** @@ -173,7 +207,7 @@ function showHideToc() { } /** - * Code for searh highlighting + * Code for search highlighting */ var highlightOn = true; function searchHighlight(searchText) { -- 2.40.0