/* global ns */ /** * Creates a boolean field for the editor. * * @param {mixed} parent * @param {object} field * @param {mixed} params * @param {function} setValue * @returns {ns.Boolean} */ ns.Boolean = function (parent, field, params, setValue) { if (params === undefined) { this.value = false; setValue(field, this.value); } else { this.value = params; } this.field = field; this.setValue = setValue; // Setup event dispatching on change this.changes = []; this.triggerListeners = function (value) { // Run callbacks for (var i = 0; i < this.changes.length; i++) { this.changes[i](value); } }; }; /** * Create HTML for the boolean field. */ ns.Boolean.prototype.createHtml = function () { const id = ns.getNextFieldId(this.field); const checked = (this.value !== undefined && this.value) ? ' checked' : ''; let content = '