diff --git a/docs/docs/configuration/client.rst b/docs/docs/configuration/client.rst index b67622f..9f465db 100644 --- a/docs/docs/configuration/client.rst +++ b/docs/docs/configuration/client.rst @@ -16,6 +16,7 @@ preferably in the script tag which embeds the JS: data-isso-avatar="true" data-isso-avatar-bg="#f0f0f0" data-isso-avatar-fg="#9abf88 #5698c4 #e279a3 #9163b6 ..." + data-isso-vote="true" src="/prefix/js/embed.js"> Furthermore you can override the automatic title detection inside @@ -88,6 +89,11 @@ scheme is based in `this color palette `_. Multiple colors must be separated by space. If you use less than eight colors and not a multiple of 2, the color distribution is not even. +data-isso-vote +-------------- + +Enable or disable voting feature on the client side. + data-isso-id ------------ diff --git a/isso/css/isso.css b/isso/css/isso.css index eef6b81..b0ed6d1 100644 --- a/isso/css/isso.css +++ b/isso/css/isso.css @@ -127,10 +127,11 @@ color: #111111 !important; text-shadow: #aaaaaa 0 0 1px !important; } -.isso-comment > div.text-wrapper > .isso-comment-footer a.reply, -.isso-comment > div.text-wrapper > .isso-comment-footer a.edit, -.isso-comment > div.text-wrapper > .isso-comment-footer a.cancel, -.isso-comment > div.text-wrapper > .isso-comment-footer a.delete { +.isso-comment > div.text-wrapper > .isso-comment-footer > a { + position: relative; + top: .2em; +} +.isso-comment > div.text-wrapper > .isso-comment-footer > a + a { padding-left: 1em; } .isso-comment > div.text-wrapper > .isso-comment-footer .votes { diff --git a/isso/js/app/config.js b/isso/js/app/config.js index 043cdb4..bae5b77 100644 --- a/isso/js/app/config.js +++ b/isso/js/app/config.js @@ -11,7 +11,8 @@ define(function() { "avatar": true, "avatar-bg": "#f0f0f0", "avatar-fg": ["#9abf88", "#5698c4", "#e279a3", "#9163b6", - "#be5168", "#f19670", "#e4bf80", "#447c69"].join(" ") + "#be5168", "#f19670", "#e4bf80", "#447c69"].join(" "), + "vote": true }; var js = document.getElementsByTagName("script"); diff --git a/isso/js/app/isso.js b/isso/js/app/isso.js index 603f27e..ec97d63 100644 --- a/isso/js/app/isso.js +++ b/isso/js/app/isso.js @@ -151,31 +151,33 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n", } ); - // update vote counter, but hide if votes sum to 0 - var votes = function(value) { - var span = $("span.votes", footer); - if (span === null && value !== 0) { - footer.prepend($.new("span.votes", value)); - } else { - if (value === 0) { - span.remove(); + if (config.vote) { + // update vote counter, but hide if votes sum to 0 + var votes = function (value) { + var span = $("span.votes", footer); + if (span === null && value !== 0) { + footer.prepend($.new("span.votes", value)); } else { - span.textContent = value; + if (value === 0) { + span.remove(); + } else { + span.textContent = value; + } } - } - }; + }; - $("a.upvote", footer).on("click", function() { - api.like(comment.id).then(function(rv) { - votes(rv.likes - rv.dislikes); + $("a.upvote", footer).on("click", function () { + api.like(comment.id).then(function (rv) { + votes(rv.likes - rv.dislikes); + }); }); - }); - $("a.downvote", footer).on("click", function() { - api.dislike(comment.id).then(function(rv) { - votes(rv.likes - rv.dislikes); + $("a.downvote", footer).on("click", function () { + api.dislike(comment.id).then(function (rv) { + votes(rv.likes - rv.dislikes); + }); }); - }); + } $("a.edit", footer).toggle("click", function(toggler) { diff --git a/isso/js/app/text/comment.jade b/isso/js/app/text/comment.jade index cbbb245..faa6618 100644 --- a/isso/js/app/text/comment.jade +++ b/isso/js/app/text/comment.jade @@ -23,13 +23,14 @@ div(class='isso-comment' id='isso-#{comment.id}') != comment.text div(class='isso-comment-footer') - if comment.likes - comment.dislikes != 0 - span(class='votes') #{comment.likes - comment.dislikes} - a(class='upvote' href='#') - i!= svg['arrow-up'] - span(class='spacer') | - a(class='downvote' href='#') - i!= svg['arrow-down'] + if conf.vote + if comment.likes - comment.dislikes != 0 + span(class='votes') #{comment.likes - comment.dislikes} + a(class='upvote' href='#') + != svg['arrow-up'] + span(class='spacer') | + a(class='downvote' href='#') + != svg['arrow-down'] a(class='reply' href='#') #{i18n('comment-reply')} a(class='edit' href='#') #{i18n('comment-edit')} a(class='delete' href='#') #{i18n('comment-delete')}