2015-04-24 01:33:29 +08:00
|
|
|
export default Em.Component.extend({
|
|
|
|
tagName: "li",
|
|
|
|
attributeBindings: ["data-poll-option-id", "data-poll-selected", "style"],
|
|
|
|
|
|
|
|
"data-poll-option-id": Em.computed.alias("option.id"),
|
|
|
|
|
|
|
|
"data-poll-selected": function() {
|
|
|
|
return this.get("option.selected") ? "selected" : false;
|
|
|
|
}.property("option.selected"),
|
|
|
|
|
|
|
|
style: function() {
|
|
|
|
var styles = [];
|
|
|
|
if (this.get("color")) { styles.push("color:" + this.get("color")); }
|
|
|
|
if (this.get("background")) { styles.push("background:" + this.get("background")); }
|
2015-05-06 23:49:55 +08:00
|
|
|
|
|
|
|
return (styles.length > 0 ? styles.join(";") : '').htmlSafe();
|
2015-04-24 01:33:29 +08:00
|
|
|
}.property("color", "background"),
|
|
|
|
|
|
|
|
render(buffer) {
|
|
|
|
buffer.push(this.get("option.html"));
|
|
|
|
},
|
|
|
|
|
|
|
|
click(e) {
|
|
|
|
// ensure we're not clicking on a link
|
|
|
|
if ($(e.target).closest("a").length === 0) {
|
|
|
|
this.sendAction("toggle", this.get("option"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|