2015-04-23 13:33:29 -04:00
|
|
|
export default Em.Component.extend({
|
|
|
|
tagName: "table",
|
|
|
|
classNames: ["results"],
|
|
|
|
|
|
|
|
options: function() {
|
2015-05-15 05:08:51 -04:00
|
|
|
const voters = this.get("poll.voters");
|
2015-04-23 13:33:29 -04:00
|
|
|
|
|
|
|
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();
|
2015-04-23 13:33:29 -04:00
|
|
|
|
|
|
|
option.setProperties({
|
2015-05-06 11:49:55 -04:00
|
|
|
percentage,
|
2015-05-15 05:51:10 -04:00
|
|
|
style,
|
2015-05-15 05:08:51 -04:00
|
|
|
title: I18n.t("poll.option_title", { count: option.get("votes") })
|
2015-04-23 13:33:29 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return this.get("poll.options");
|
2015-05-04 10:01:57 -04:00
|
|
|
}.property("poll.voters", "poll.options.[]")
|
2015-04-23 13:33:29 -04:00
|
|
|
|
|
|
|
});
|