This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/radio-button.js.es6
2019-10-23 12:30:52 -04:00

28 lines
569 B
JavaScript

import Component from "@ember/component";
import computed from "ember-addons/ember-computed-decorators";
export default Component.extend({
tagName: "input",
type: "radio",
attributeBindings: [
"name",
"type",
"value",
"checked:checked",
"disabled:disabled"
],
click() {
const value = $(this.element).val();
if (this.selection === value) {
this.set("selection", undefined);
}
this.set("selection", value);
},
@computed("value", "selection")
checked(value, selection) {
return value === selection;
}
});