MCPcopy Index your code
hub / github.com/json-editor/json-editor / _createToggleButton

Method _createToggleButton

src/editors/array.js:720–745  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

718 }
719
720 _createToggleButton () {
721 const button = this.getButton('', 'collapse', 'button_collapse')
722 button.classList.add('json-editor-btntype-toggle')
723 this.title.insertBefore(button, this.title.childNodes[0])
724
725 const rowHolderDisplay = this.row_holder.style.display
726 const controlsDisplay = this.controls.style.display
727 button.addEventListener('click', e => {
728 e.preventDefault()
729 e.stopPropagation()
730 if (this.panel) this.setButtonState(this.panel, this.collapsed)
731 if (this.tabs_holder) this.setButtonState(this.tabs_holder, this.collapsed)
732 if (this.collapsed) {
733 this.collapsed = false
734 this.row_holder.style.display = rowHolderDisplay
735 this.controls.style.display = controlsDisplay
736 this.setButtonText(e.currentTarget, '', 'collapse', 'button_collapse')
737 } else {
738 this.collapsed = true
739 this.row_holder.style.display = 'none'
740 this.controls.style.display = 'none'
741 this.setButtonText(e.currentTarget, '', 'expand', 'button_expand')
742 }
743 })
744 return button
745 }
746
747 _createAddRowButton () {
748 const button = this.getButton(this.getItemTitle(), 'add', 'button_add_row_title', [this.getItemTitle()])

Callers 1

addControlsMethod · 0.95

Calls 4

setButtonStateMethod · 0.95
addMethod · 0.80
getButtonMethod · 0.45
setButtonTextMethod · 0.45

Tested by

no test coverage detected