Set highlight style to the active anchor

This commit is contained in:
Thomas Chandelle
2017-01-11 11:54:06 +01:00
parent 0d8f0ac5fa
commit 5938db1459
2 changed files with 21 additions and 0 deletions

View File

@@ -114,4 +114,22 @@ $(function () {
}); });
stabilityToggle.prop('checked', search === '?stableonly=true'); stabilityToggle.prop('checked', search === '?stableonly=true');
unstable.toggleClass('hidden', stabilityToggle[0].checked); unstable.toggleClass('hidden', stabilityToggle[0].checked);
// Highlighting current anchor
var anchors = $('.anchor');
var _onHashChange = function () {
var activeHash = window.document.location.hash
.replace(/\./g, '\\.'); // Escape dot in element id
anchors.removeClass('highlighted');
if (activeHash.length > 0) {
anchors.filter(activeHash).addClass('highlighted');
}
};
$(window).on('hashchange', _onHashChange);
_onHashChange();
}); });

View File

@@ -51,6 +51,9 @@ body {
width: 0px; width: 0px;
height: 0px; height: 0px;
} }
.nameContainer .anchor.highlighted + h4 {
background-color: #faebcc;
}
a { a {
position: relative; position: relative;
z-index: 1; z-index: 1;