update unread anchor

This commit is contained in:
Barış Soner Uşaklı
2024-02-05 17:01:08 -05:00
parent 38197163b9
commit 1b4a24b997
2 changed files with 14 additions and 3 deletions

View File

@@ -238,5 +238,6 @@
"navigator.unread": "%1 unread",
"upvote-post": "Upvote post",
"downvote-post": "Downvote post",
"post-tools": "Post tools"
"post-tools": "Post tools",
"unread-posts-link": "Unread posts link"
}

View File

@@ -372,13 +372,23 @@ define('navigator', [
const anchorEl = unreadEl.querySelector('.meta a');
remaining = Math.min(remaining, ajaxify.data.postcount - index);
function toggleAnchor(text) {
anchorEl.innerText = text;
anchorEl.setAttribute('aria-disabled', text ? 'false' : 'true');
if (text) {
anchorEl.removeAttribute('tabindex');
} else {
anchorEl.setAttribute('tabindex', -1);
}
}
if (remaining > 0 && (trackHeight - thumbBottom) >= thumbHeight) {
const text = await translator.translate(`[[topic:navigator.unread, ${remaining}]]`);
anchorEl.href = `${config.relative_path}/topic/${ajaxify.data.slug}/${Math.min(index + 1, ajaxify.data.postcount)}`;
anchorEl.innerText = text;
toggleAnchor(text);
} else {
anchorEl.href = ajaxify.data.url;
anchorEl.innerText = '';
toggleAnchor('');
}
}