* feature added add-discussion-length-in-brackets #12324 * changed class name from comments-count to js-comments-count
This commit is contained in:
parent
d1a594e7a9
commit
30bf47a445
2 changed files with 10 additions and 2 deletions
|
|
@ -273,6 +273,7 @@ function handleCommentSubmit(event) {
|
|||
else {
|
||||
window.location.replace(newComment.url)
|
||||
}
|
||||
updateCommentsCount();
|
||||
initializeCommentsPage();
|
||||
initializeCommentDate();
|
||||
initializeCommentDropdown();
|
||||
|
|
@ -548,3 +549,10 @@ function listenForDetailsToggle() {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateCommentsCount() {
|
||||
var commentsCountDiv = document.getElementsByClassName("js-comments-count")[0];
|
||||
var commentsCountData = parseInt(commentsCountDiv.dataset.commentsCount) + 1;
|
||||
commentsCountDiv.dataset.commentsCount = commentsCountData;
|
||||
commentsCountDiv.innerHTML = `(${commentsCountData})`
|
||||
}
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
<section id="comments" data-updated-at="<%= Time.current %>" class="text-padding mb-4 border-t-1 border-0 border-solid border-base-10">
|
||||
<% if @article.show_comments %>
|
||||
<header class="relative flex justify-between items-center mb-6">
|
||||
<h2 class="crayons-subtitle-1">Discussion</h2>
|
||||
<h2 class="crayons-subtitle-1">Discussion <span class="js-comments-count" data-comments-count="<%= @article.comments_count %>">(<%= @article.comments_count %>)</span> </h2>
|
||||
<div id="comment-subscription">
|
||||
<div role="presentation" class="crayons-btn-group">
|
||||
<span class="crayons-btn crayons-btn--outlined">Subscribe</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue