Skip to content

Commit

Permalink
Set highlight style to the active anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
tchandelle committed Jan 11, 2017
1 parent 0d8f0ac commit 5938db1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions config/jsdoc/api/template/static/scripts/main.js
Expand Up @@ -114,4 +114,22 @@ $(function () {
});
stabilityToggle.prop('checked', search === '?stableonly=true');
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();
});
3 changes: 3 additions & 0 deletions config/jsdoc/api/template/static/styles/jaguar.css
Expand Up @@ -51,6 +51,9 @@ body {
width: 0px;
height: 0px;
}
.nameContainer .anchor.highlighted + h4 {
background-color: #faebcc;
}
a {
position: relative;
z-index: 1;
Expand Down

0 comments on commit 5938db1

Please sign in to comment.