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

@@ -1,3 +1,11 @@
Version 1.0.39 (unreleased)
---------------------------
Improvements:
* Comments are highlighted if hash (#comment-123) is present in URL
* Documentation translated in Turkish
Version 1.0.38 (Jan 28, 2017)
-----------------------------

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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();
});

View File

@@ -3,4 +3,5 @@ document.addEventListener('DOMContentLoaded', function () {
KB.render();
KB.listen();
KB.keyboardShortcuts();
KB.trigger('dom.ready');
});

View File

@@ -15,6 +15,14 @@
&:hover
background: #fafafa
.comment-highlighted
background-color: #FFF8DC
border: 2px solid #FFF8DC
border-left: 2px solid #ffeb8e
&:hover
background-color: #FFF8DC
border: 2px solid #ffeb8e
.comment-title
border-bottom: 1px dotted #eee
margin-left: 55px