MCPcopy Create free account
hub / github.com/cryptii/cryptii / renderField

Method renderField

src/View/Field/Boolean.js:41–68  ·  view source on GitHub ↗

* Renders field. * @protected * @return {?HTMLElement}

()

Source from the content-addressed store, hash-verified

39 * @return {?HTMLElement}
40 */
41 renderField () {
42 this._$input = View.createElement('input', {
43 className: 'field-boolean__input',
44 type: 'checkbox',
45 id: this.getId(),
46 onChange: this.inputValueDidChange.bind(this),
47 checked: this.getModel().getValue(),
48 onFocus: evt => this.focus(),
49 onBlur: evt => this.blur()
50 })
51
52 const $toggle = View.createElement('label', {
53 className: 'field-boolean__toggle',
54 htmlFor: this.getId()
55 }, [
56 View.createElement('span', {
57 className: 'field-boolean__choice'
58 }, this.getModel().getTrueLabel()),
59 View.createElement('span', {
60 className: 'field-boolean__choice'
61 }, this.getModel().getFalseLabel())
62 ])
63
64 const $field = super.renderField()
65 $field.appendChild(this._$input)
66 $field.appendChild($toggle)
67 return $field
68 }
69
70 /**
71 * Triggered when input value has been changed.

Callers

nothing calls this directly

Calls 8

createElementMethod · 0.80
focusMethod · 0.80
blurMethod · 0.80
getTrueLabelMethod · 0.80
getFalseLabelMethod · 0.80
getIdMethod · 0.45
getValueMethod · 0.45
getModelMethod · 0.45

Tested by

no test coverage detected