forked from ibm-js/deliteful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Checkbox.js
40 lines (35 loc) · 1.06 KB
/
Checkbox.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/** @module deliteful/Checkbox */
define([
"dcl/dcl",
"delite/register",
"delite/FormWidget",
"./Toggle",
"delite/handlebars!./Checkbox/Checkbox.html",
"delite/theme!./Checkbox/themes/{{theme}}/Checkbox.css"
], function (dcl, register, FormWidget, Toggle, template) {
/**
* A 2-state checkbox widget similar to an HTML5 input type="checkbox" element.
* @example
* <d-checkbox checked="true"></d-checkbox>
* @class module:deliteful/Checkbox
* @augments module:delite/FormWidget
* @augments module:deliteful/Toggle
*/
return register("d-checkbox", [HTMLElement, FormWidget, Toggle], /** @lends module:deliteful/Checkbox# */ {
/**
* The component css base class.
* @member {string}
* @default "d-checkbox"
*/
baseClass: "d-checkbox",
template: template,
postRender: function () {
this._lbl4 = null;
this.on("click", this._inputClickHandler.bind(this), this.focusNode);
this.on("change", this._inputClickHandler.bind(this), this.focusNode);
},
_inputClickHandler: function () {
this.checked = this.focusNode.checked;
}
});
});