diff options
Diffstat (limited to 'assets/js/components/comment-highlight.js')
-rw-r--r-- | assets/js/components/comment-highlight.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/assets/js/components/comment-highlight.js b/assets/js/components/comment-highlight.js new file mode 100644 index 00000000..cc0b9bc0 --- /dev/null +++ b/assets/js/components/comment-highlight.js @@ -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(); +}); |