summaryrefslogtreecommitdiff
path: root/assets/js/components
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-01-29 18:58:00 -0500
committerFrederic Guillot <fred@kanboard.net>2017-01-29 18:58:00 -0500
commit66ced63fe263b158707b65b4bd691fa46658828c (patch)
treec8ca5bdda479d78159d407972b14bd47c4f36cdd /assets/js/components
parent0371acff89b14b9bdcb03e72fd9637e26e6b517c (diff)
Highlight comments if hash is present in URL
Diffstat (limited to 'assets/js/components')
-rw-r--r--assets/js/components/comment-highlight.js21
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();
+});