Fix comments counter for zero comments

This commit is contained in:
Anton Ignatov 2019-06-21 10:43:41 +02:00
parent db7c6435b3
commit 57ef9573f2

View file

@ -2,8 +2,14 @@
/* eslint-disable no-restricted-globals, no-alert */
var Comments = (function() {
function changeCounter(comment, value) {
var currnetCount = $('#comment-counter-' + comment.closest('.comments-container').attr('data-object-id'));
currnetCount.html(parseInt(currnetCount.html(), 10) + value);
var currentCount = $('#comment-counter-' + comment.closest('.comments-container').attr('data-object-id'));
var newValue = parseInt(currentCount.html(), 10) + value;
currentCount.html(newValue);
if (newValue === 0) {
currentCount.addClass('hidden');
} else {
currentCount.removeClass('hidden');
}
}
function scrollBottom(container) {