Highlight comments if hash is present in URL
This commit is contained in:
2
assets/css/app.min.css
vendored
2
assets/css/app.min.css
vendored
File diff suppressed because one or more lines are too long
6
assets/js/app.min.js
vendored
6
assets/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
21
assets/js/components/comment-highlight.js
Normal file
21
assets/js/components/comment-highlight.js
Normal 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();
|
||||
});
|
||||
1
assets/js/core/bootstrap.js
vendored
1
assets/js/core/bootstrap.js
vendored
@@ -3,4 +3,5 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
KB.render();
|
||||
KB.listen();
|
||||
KB.keyboardShortcuts();
|
||||
KB.trigger('dom.ready');
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user