discourse/plugins/poll/assets/javascripts/components/poll-option.js.es6

26 lines
706 B
Plaintext
Raw Normal View History

2016-07-28 22:30:38 -04:00
import computed from 'ember-addons/ember-computed-decorators';
import { iconHTML } from 'discourse/helpers/fa-icon';
export default Em.Component.extend({
tagName: "li",
2016-07-28 22:30:38 -04:00
attributeBindings: ["data-poll-option-id"],
"data-poll-option-id": Em.computed.alias("option.id"),
2016-07-28 22:30:38 -04:00
@computed("option.selected", "isMultiple")
optionIcon(selected, isMultiple) {
if (isMultiple) {
return iconHTML(selected ? 'check-square-o' : 'square-o');
} else {
return iconHTML(selected ? 'dot-circle-o' : 'circle-o');
}
},
click(e) {
// ensure we're not clicking on a link
if ($(e.target).closest("a").length === 0) {
this.sendAction("toggle", this.get("option"));
}
}
});