feat(comments): AJAX fragment list/submit + load-more parity
Add REST comment/list + comment/submit HTML fragments, shared query renderer for order/author/hottest, fix load-more policy and DOM targets, and stop full-page scrapes for order/author/reload.
This commit is contained in:
@@ -29,8 +29,13 @@
|
||||
if (target && target.classList && target.classList.contains("content-stream__footer")) {
|
||||
target = target.previousElementSibling;
|
||||
}
|
||||
if (isComment) {
|
||||
var commentList = document.getElementById("comment-list") ||
|
||||
(container.parentElement && container.parentElement.querySelector("#comment-list, .commentlist, ol.commentlist"));
|
||||
if (commentList) target = commentList;
|
||||
}
|
||||
if (!target && container.parentElement) {
|
||||
target = container.parentElement.querySelector(".post-grid, .comment-list, .content-stream__list");
|
||||
target = container.parentElement.querySelector(".post-grid, .comment-list, .commentlist, .content-stream__list");
|
||||
}
|
||||
|
||||
function showSkeleton() {
|
||||
@@ -79,6 +84,8 @@
|
||||
if (isComment && postId) {
|
||||
body.set("post_id", postId);
|
||||
body.set("comment_order", commentOrder);
|
||||
var authorOnly = container.dataset.authorOnly || "0";
|
||||
if (authorOnly === "1") body.set("author_only", "1");
|
||||
}
|
||||
|
||||
fetch(aksrtData.ajaxUrl, {
|
||||
@@ -98,6 +105,9 @@
|
||||
while (newItems.length > 0) {
|
||||
target.appendChild(newItems[0]);
|
||||
}
|
||||
if (isComment && window.AksrtFrontend) {
|
||||
AksrtFrontend.rehydrate(target, "ajax");
|
||||
}
|
||||
nextPage++;
|
||||
container.dataset.nextPage = String(nextPage);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user