Hiding zero votes is now done through CSS instead of javascript.

This commit is contained in:
Ivan Pantic 2016-07-16 03:54:02 +02:00
parent b620f2c0b0
commit b0f8606b0f
3 changed files with 13 additions and 11 deletions

View File

@ -145,6 +145,9 @@
.isso-comment .isso-postbox { .isso-comment .isso-postbox {
margin-top: 0.8em; margin-top: 0.8em;
} }
.isso-comment.isso-no-votes span.votes {
display: none;
}
.isso-postbox { .isso-postbox {
max-width: 68em; max-width: 68em;

View File

@ -165,19 +165,18 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
); );
if (config.vote) { if (config.vote) {
// update vote counter, but hide if votes sum to 0 // update vote counter
var votes = function (value) { var votes = function (value) {
var span = $("span.votes", footer); var span = $("span.votes", footer);
if (span === null) { if (span === null) {
if (value !== 0) {
footer.prepend($.new("span.votes", value)); footer.prepend($.new("span.votes", value));
}
} else {
if (value === 0) {
span.remove();
} else { } else {
span.textContent = value; span.textContent = value;
} }
if (value) {
el.classList.remove('isso-no-votes');
} else {
el.classList.add('isso-no-votes');
} }
}; };
@ -192,6 +191,8 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
votes(rv.likes - rv.dislikes); votes(rv.likes - rv.dislikes);
}); });
}); });
votes(comment.likes - comment.dislikes);
} }
$("a.edit", footer).toggle("click", $("a.edit", footer).toggle("click",

View File

@ -24,8 +24,6 @@ div(class='isso-comment' id='isso-#{comment.id}')
div(class='isso-comment-footer') div(class='isso-comment-footer')
if conf.vote if conf.vote
if comment.likes - comment.dislikes != 0
span(class='votes') #{comment.likes - comment.dislikes}
a(class='upvote' href='#') a(class='upvote' href='#')
!= svg['arrow-up'] != svg['arrow-up']
span(class='spacer') | span(class='spacer') |