lib/jazzy/assets/js/jazzy.js in jazzy-0.4.0 vs lib/jazzy/assets/js/jazzy.js in jazzy-0.4.1
- old
+ new
@@ -15,17 +15,26 @@
linkToHash.trigger("click");
}
});
// On token click, toggle its discussion and animate token.marginLeft
-$(".token").click(function() {
+$(".token").click(function(event) {
if (window.jazzy.docset) {
return;
}
var link = $(this);
var animationDuration = 300;
var tokenOffset = "15px";
var original = link.css('marginLeft') == tokenOffset;
link.animate({'margin-left':original ? "0px" : tokenOffset}, animationDuration);
$content = link.parent().parent().next();
$content.slideToggle(animationDuration);
+
+ // Keeps the document from jumping to the hash.
+ var href = $(this).attr('href');
+ if (history.pushState) {
+ history.pushState({}, '', href);
+ } else {
+ location.hash = href;
+ }
+ event.preventDefault();
});