From 1c207c0aa5dc5490ce2c93186d112a622a1b6e2a Mon Sep 17 00:00:00 2001 From: 8chan Date: Sun, 14 Dec 2014 03:29:00 -0800 Subject: [PATCH] Bug fix: fix highlightReply() with the new floating boardlist --- templates/main.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/templates/main.js b/templates/main.js index 44b3dd96..23af9447 100644 --- a/templates/main.js +++ b/templates/main.js @@ -255,9 +255,10 @@ function get_cookie(cookie_name) { } function highlightReply(id) { - if (typeof window.event != "undefined" && event.which == 2) { + if (typeof window.event != "undefined") { // don't highlight on middle click - return true; + if (event.which == 2) return true; + window.event.preventDefault(); } var divs = document.getElementsByTagName('div'); @@ -268,9 +269,18 @@ function highlightReply(id) { } if (id) { var post = document.getElementById('reply_'+id); - if (post) + if (post) { post.className += ' highlighted'; window.location.hash = id; + + // Better offset to keep in mind new hovering boardlist + var post_top = post.getBoundingClientRect().top; + var body_top = document.body.getBoundingClientRect().top; + var boardlist_height = document.getElementsByClassName('boardlist')[0].getBoundingClientRect().height; + var offset = (post_top - body_top) - boardlist_height; + + window.scrollTo(0, offset); + } } return true; }