gd-sprest-js
Version:
SharePoint 2013/Online js components.
48 lines (47 loc) • 1.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var _1 = require(".");
/**
* CheckBox Group
*/
exports.CheckBoxGroup = function (props) {
var _cbs = [];
// Method to get the checkbox elements
var get = function () { return _cbs; };
// Method to get the value
var getValues = function () {
var values = [];
// Parse the checkboxes
for (var i = 0; i < _cbs.length; i++) {
// Add the value
values.push(_cbs[i].getValue());
}
// Get the checkbox values
return values;
};
// Parse the checkbox properties
for (var i = 0; i < props.props.length; i++) {
var cbProps = props.props[i];
// Create an element
var el = document.createElement("div");
// Create the checkbox
var cb = _1.CheckBox({
className: cbProps.className,
disable: cbProps.disable,
el: el,
label: cbProps.label,
onChange: cbProps.onChange || props.onChange,
required: cbProps.required,
value: cbProps.value
}).get();
// Append the checkbox
props.el.appendChild(cb._container);
// Save the checkbox
_cbs.push(cb);
}
// Return the checkbox group
return {
get: get,
getValues: getValues
};
};