Merge pull request #6353 from tchandelle/doc-anchor

API doc : add highlight style to the active anchor
This commit is contained in:
Andreas Hocevar
2017-01-11 20:38:01 +01:00
committed by GitHub
2 changed files with 21 additions and 0 deletions
@@ -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();
}); });
@@ -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;