diff --git a/isso/js/app/config.js b/isso/js/app/config.js index 35bf051..f38dcc7 100644 --- a/isso/js/app/config.js +++ b/isso/js/app/config.js @@ -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"); diff --git a/isso/js/app/isso.js b/isso/js/app/isso.js index 3e09003..e40c351 100644 --- a/isso/js/app/isso.js +++ b/isso/js/app/isso.js @@ -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 () { @@ -191,7 +208,7 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n", votes(rv.likes - rv.dislikes); }); }); - + votes(comment.likes - comment.dislikes); }