(anchor, isLink)
| 1199 | // fix scrolling to an anchor because of the header |
| 1200 | // isLink tells us if we are here because a link was cliked |
| 1201 | function scrollToAnchor(anchor, isLink) { |
| 1202 | var target = $("#" + escape_selector(anchor)); |
| 1203 | if (target.length) { |
| 1204 | //Smooth scrolling and let back go to the last location |
| 1205 | var contentTop = $("#content").offset().top; |
| 1206 | if (parseInt(anchor)) { |
| 1207 | // if the anchor is a line number, (or a function local) we want to give a bit more |
| 1208 | // context on top |
| 1209 | contentTop += target.height() * 7; // 7 lines |
| 1210 | } |
| 1211 | |
| 1212 | if (isLink) { |
| 1213 | // history.replaceState({contentTop: contentTop, bodyTop: $("body").scrollTop() }, undefined) |
| 1214 | history.pushState({bodyTop: target.offset().top - contentTop}, |
| 1215 | document.title + "**" + anchor, |
| 1216 | window.location.pathname + "#" + anchor); |
| 1217 | } |
| 1218 | // $("#content").animate({scrollTop:target.position().top + contentTop }, 300); |
| 1219 | $("html,body").animate({scrollTop:target.offset().top - contentTop }, isLink ? 300 : 1); |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | window.onpopstate = function (e) { |
| 1224 | if (!e.state) |
no test coverage detected