UNPKG

gd-sprest-js

Version:

SharePoint 2013/Online js components.

40 lines (39 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _1 = require("."); /** * CheckBox */ exports.CheckBox = function (props) { var _cb = null; // Method to get the checkbox element var get = function () { return _cb; }; // Method to get the value var getValue = function () { // Get the checkbox value return _cb ? _cb.getValue() : false; }; // Add the checkbox html props.el.innerHTML = _1.Templates.CheckBox(props); // Get the checkbox var cb = props.el.querySelector(".ms-CheckBox"); // Create the checkbox _cb = new _1.fabric.CheckBox(cb); // See if a change event exists if (props.onChange) { // Set the checkbox change event cb.addEventListener("change", function () { // Execute the change event props.onChange(getValue()); }); } // Update the value props.value ? _cb.check() : _cb.unCheck(); // Return the checkbox return { check: function () { _cb ? _cb.check() : null; }, get: get, getValue: getValue, unCheck: function () { _cb ? _cb.unCheck() : null; } }; };