feat(frontend): wire comment sort/author filter like Zibll

Apply comments_template_query_args for newest/hottest/author-only,
keep filter bar visible under empty author filters, and restyle order
tabs/buttons with Zibll-compatible classes.
This commit is contained in:
kate522 committed 2026-07-11 21:07:22 +08:00
1 parent b155936868
commit b01a89bee2
3 files changed
+165 -8

No files matched your search

+35 -1
View File
@@ -596,14 +596,48 @@
var newFilter = newComments.querySelector(".comment-filter");
if (currentFilter && newFilter) {
currentFilter.replaceWith(newFilter.cloneNode(true));
} else if (!currentFilter && newFilter) {
var listAnchor = commentsArea.querySelector("#postcomments, #comment-list");
if (listAnchor && listAnchor.parentNode) {
listAnchor.parentNode.insertBefore(newFilter.cloneNode(true), listAnchor);
}
}
var currentListWrap = commentsArea.querySelector("#postcomments");
var newListWrap = newComments.querySelector("#postcomments");
var currentList = commentsArea.querySelector("#comment-list");
var newList = newComments.querySelector("#comment-list");
if (currentList && newList) {
if (currentListWrap && newListWrap) {
currentListWrap.replaceWith(newListWrap.cloneNode(true));
} else if (currentList && newList) {
currentList.replaceWith(newList.cloneNode(true));
}
var currentEmpty = commentsArea.querySelector(".comments-empty");
var newEmpty = newComments.querySelector(".comments-empty");
if (currentEmpty && newEmpty) {
currentEmpty.replaceWith(newEmpty.cloneNode(true));
} else if (currentEmpty && !newEmpty) {
currentEmpty.remove();
} else if (!currentEmpty && newEmpty) {
var insertAt = commentsArea.querySelector("#postcomments") || commentsArea;
insertAt.appendChild(newEmpty.cloneNode(true));
}
var currentPagination = getPaginationEl(commentsArea);
var newPagination = getPaginationEl(newComments);
if (currentPagination && newPagination) {
currentPagination.replaceWith(newPagination.cloneNode(true));
} else if (currentPagination && !newPagination) {
currentPagination.remove();
}
var currentCount = commentsArea.querySelector(".comments-count");
var newCount = newComments.querySelector(".comments-count");
if (currentCount && newCount) {
currentCount.textContent = newCount.textContent;
}
if (window.history && typeof window.history.replaceState === "function") {
window.history.replaceState(null, "", url.toString());
}