feature added : add-discussion-length-in-brackets #12324 (#12518)

* feature added  add-discussion-length-in-brackets #12324

* changed class name from comments-count to js-comments-count
This commit is contained in:
Nandan Kumar 2021-02-02 20:44:01 +05:30 committed by GitHub
parent d1a594e7a9
commit 30bf47a445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -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})`
}

View file

@ -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>