Add reply highlighting

If a user hovers over a reply link, that reply is highlighted.
Obviously, this is only useful if the reply is on-screen.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-07-29 21:09:19 -07:00
parent b84ca6d84f
commit ede216789b
3 changed files with 22 additions and 7 deletions

View File

@@ -346,6 +346,16 @@ $(window).on("load", () => {
} }
}); });
$(".post_link").on("mouseover", (e) => {
let postId = $(e.target).attr("data-post-id");
$("#p" + postId + ".post").addClass("post_highlight");
});
$(".post_link").on("mouseout", (e) => {
let postId = $(e.target).attr("data-post-id");
$("#p" + postId + ".post").removeClass("post_highlight");
});
$(".youtube_embed_link").on("click", (e) => { $(".youtube_embed_link").on("click", (e) => {
e.preventDefault(); e.preventDefault();
let fullEnt = $(e.target).parents(".youtube_embed"); let fullEnt = $(e.target).parents(".youtube_embed");

View File

@@ -1,6 +1,7 @@
:root { :root {
--body: #ededed; --body: #ededed;
--highlight: #555; --highlight: #aaa;
--link: #555;
--border-color: #555; --border-color: #555;
--name: #060; --name: #060;
--quote: #595; --quote: #595;
@@ -121,6 +122,10 @@ th {
float: right; float: right;
} }
.post_highlight {
background-color: var(--highlight);
}
.thread { .thread {
background-color: var(--post-background); background-color: var(--post-background);
padding: 10px; padding: 10px;
@@ -169,9 +174,6 @@ th {
right: 0px; right: 0px;
} }
/* Youtube embeds */
/* Spoilers */ /* Spoilers */
.spoiler { .spoiler {
@@ -200,11 +202,11 @@ nav {
/* Misc */ /* Misc */
a:link { a:link {
color: var(--highlight); color: var(--link);
} }
a:visited { a:visited {
color: var(--highlight); color: var(--link);
} }
a:hover { a:hover {

View File

@@ -105,7 +105,10 @@ class ReplyBuilder:
self.adv() self.adv()
post = Post.objects.filter(id=int(post_id)).first() post = Post.objects.filter(id=int(post_id)).first()
if post: if post:
self.final += f'<a class="post_link" href="{post.get_absolute_url()}">&gt;&gt;{post_id}</a>' self.final += (
f'<a class="post_link" href="{post.get_absolute_url()}" '
f'data-post-id="{post_id}">&gt;&gt;{post_id}</a>'
)
else: else:
self.final += f'<span class="post_link_broken">&gt;&gt;{post_id}</span>' self.final += f'<span class="post_link_broken">&gt;&gt;{post_id}</span>'