Highlight comments if hash is present in URL

This commit is contained in:
Frederic Guillot
2017-01-29 18:58:00 -05:00
parent 0371acff89
commit 66ced63fe2
6 changed files with 42 additions and 4 deletions

View File

@@ -0,0 +1,21 @@
KB.on('dom.ready', function () {
function highlightComment() {
if (window.location.hash.indexOf('#comment-') === 0) {
var commentElement = KB.find(window.location.hash);
if (commentElement) {
var commentsElement = document.querySelectorAll('.comment');
commentsElement.forEach(function (element) {
KB.dom(element).removeClass('comment-highlighted');
});
commentElement.addClass('comment-highlighted');
}
}
}
window.addEventListener('hashchange', highlightComment);
highlightComment();
});