()
| 218 | } |
| 219 | |
| 220 | setOptInCheckbox () { |
| 221 | let optIn |
| 222 | |
| 223 | if (this.optInWidget === 'switch') { |
| 224 | optIn = this.theme.getOptInSwitch(this.formname) |
| 225 | } else { |
| 226 | optIn = this.theme.getOptInCheckbox(this.formname) |
| 227 | } |
| 228 | |
| 229 | this.optInCheckbox = optIn.checkbox |
| 230 | this.optInContainer = optIn.container |
| 231 | |
| 232 | this.optInCheckbox.addEventListener('click', () => { |
| 233 | if (this.isActive()) { |
| 234 | this.deactivate() |
| 235 | } else { |
| 236 | this.activate() |
| 237 | } |
| 238 | }) |
| 239 | |
| 240 | /* append active/deactive checkbox if show_opt_in is true */ |
| 241 | const globalOptIn = this.jsoneditor.options.show_opt_in |
| 242 | const parentOptInDefined = (typeof this.parent.options.show_opt_in !== 'undefined') |
| 243 | const parentOptInEnabled = (parentOptInDefined && this.parent.options.show_opt_in === true) |
| 244 | const parentOptInDisabled = (parentOptInDefined && this.parent.options.show_opt_in === false) |
| 245 | |
| 246 | if (parentOptInEnabled || (!parentOptInDisabled && globalOptIn) || (!parentOptInDefined && globalOptIn)) { |
| 247 | /* and control to type object editors if they are not required */ |
| 248 | if (this.parent && this.parent.schema.type === 'object' && !this.isRequired() && this.header) { |
| 249 | this.header.insertBefore(this.optInContainer, this.header.firstChild) |
| 250 | this.optInAppended = true |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | preBuild () { |
| 256 |
nothing calls this directly
no test coverage detected