From 0cca3603de2ff2f23ba27bf18737abfe0b8f3658 Mon Sep 17 00:00:00 2001 From: fatchan Date: Wed, 4 Sep 2019 17:41:15 +0000 Subject: [PATCH] script for hoveing qutoes highlighting posts --- gulp/res/css/style.css | 2 +- gulp/res/js/hover.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gulp/res/js/hover.js diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index 58a1e824..740174eb 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -498,7 +498,7 @@ textarea { max-width: 100%; } -.anchor:target + .post-container { +.anchor:target + .post-container, .post-container.highlighted { background-color: var(--highlighted-post-color) !important; border-color: var(--highlighted-post-outline-color) !important; } diff --git a/gulp/res/js/hover.js b/gulp/res/js/hover.js new file mode 100644 index 00000000..9b645bb0 --- /dev/null +++ b/gulp/res/js/hover.js @@ -0,0 +1,17 @@ +window.addEventListener('DOMContentLoaded', (event) => { + + var quotes = document.getElementsByClassName('quote'); + + var toggleHighlightPost = function(e) { + var hash = this.hash.substring(1); + var anchor = document.getElementById(hash); + var post = anchor.nextSibling; + post.classList.toggle('highlighted'); + }; + + for (var i = 0; i < quotes.length; i++) { + quotes[i].addEventListener('mouseover', toggleHighlightPost, false); + quotes[i].addEventListener('mouseout', toggleHighlightPost, false); + } + +});