discourse/plugins/poll/assets/javascripts/components/poll-results-standard.js.es6

23 lines
604 B
Text
Raw Normal View History

export default Em.Component.extend({
tagName: "table",
classNames: ["results"],
options: function() {
const voters = this.get("poll.voters");
this.get("poll.options").forEach(option => {
2015-05-15 05:51:10 -04:00
const percentage = voters === 0 ? 0 : Math.floor(100 * option.get("votes") / voters),
style = "width: " + percentage + "%".htmlSafe();
option.setProperties({
2015-05-06 11:49:55 -04:00
percentage,
2015-05-15 05:51:10 -04:00
style,
title: I18n.t("poll.option_title", { count: option.get("votes") })
});
});
return this.get("poll.options");
}.property("poll.voters", "poll.options.[]")
});