add option to hide voting feature, closes #115
This commit is contained in:
parent
e2911da560
commit
c712d196d7
@ -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"></script>
|
||||
|
||||
Furthermore you can override the automatic title detection inside
|
||||
@ -88,6 +89,11 @@ scheme is based in `this color palette <http://colrd.com/palette/19308/>`_.
|
||||
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
|
||||
------------
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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");
|
||||
|
@ -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) {
|
||||
|
@ -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')}
|
||||
|
Loading…
Reference in New Issue
Block a user