Vote levels features (custom classes based on the comment votes)
This commit is contained in:
parent
b0f8606b0f
commit
4972433406
@ -13,7 +13,8 @@ define(function() {
|
||||
"avatar-bg": "#f0f0f0",
|
||||
"avatar-fg": ["#9abf88", "#5698c4", "#e279a3", "#9163b6",
|
||||
"#be5168", "#f19670", "#e4bf80", "#447c69"].join(" "),
|
||||
"vote": true
|
||||
"vote": true,
|
||||
"vote-levels": null
|
||||
};
|
||||
|
||||
var js = document.getElementsByTagName("script");
|
||||
|
@ -165,6 +165,12 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
|
||||
);
|
||||
|
||||
if (config.vote) {
|
||||
var voteLevels = config['vote-levels'];
|
||||
if (typeof voteLevels === 'string') {
|
||||
// Eg. -5,5,15
|
||||
voteLevels = voteLevels.split(',');
|
||||
}
|
||||
|
||||
// update vote counter
|
||||
var votes = function (value) {
|
||||
var span = $("span.votes", footer);
|
||||
@ -178,6 +184,17 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
|
||||
} else {
|
||||
el.classList.add('isso-no-votes');
|
||||
}
|
||||
if (voteLevels) {
|
||||
var before = true;
|
||||
for (var index = 0; index <= voteLevels.length; index++) {
|
||||
if (before && (index >= voteLevels.length || value < voteLevels[index])) {
|
||||
el.classList.add('isso-vote-level-' + index);
|
||||
before = false;
|
||||
} else {
|
||||
el.classList.remove('isso-vote-level-' + index);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$("a.upvote", footer).on("click", function () {
|
||||
|
Loading…
Reference in New Issue
Block a user