finished quote behavior for mobile

This commit is contained in:
plebbitor
2023-04-18 15:23:39 +02:00
parent b6c041ea9e
commit 1dc5a577ae
3 changed files with 44 additions and 41 deletions
+8 -4
View File
@@ -1,5 +1,6 @@
function handleQuoteClick(reply, parentCid, threadCid) {
const cid = parentCid ? parentCid : reply.shortCid;
const isMobile = window.innerWidth <= 480;
if (threadCid && cid === threadCid) {
const highlightedElements = document.querySelectorAll('.highlighted');
@@ -7,19 +8,22 @@ function handleQuoteClick(reply, parentCid, threadCid) {
highlightedElements.forEach(el => {
el.classList.remove('highlighted');
});
return;
}
const targetElement = [...document.querySelectorAll('.post-reply')]
const targetElementSelector = isMobile ? '.post-reply-mobile' : '.post-reply-desktop';
const postNumberSelector = isMobile ? '.post-number-mobile' : '.post-number-desktop';
const targetElement = [...document.querySelectorAll(targetElementSelector)]
.find(el => {
const postNumberElement = el.querySelector('.post-number');
const postNumberElement = el.querySelector(postNumberSelector);
return postNumberElement && postNumberElement.innerHTML.includes(cid);
});
if (targetElement) {
const highlightedElements = document.querySelectorAll('.highlighted');
highlightedElements.forEach(el => {
el.classList.remove('highlighted');
});