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

Method _createMoveUpButton

src/editors/array.js:616–644  ·  view source on GitHub ↗
(i, holder)

Source from the content-addressed store, hash-verified

614 }
615
616 _createMoveUpButton (i, holder) {
617 const button = this.getButton('', (this.schema.format === 'tabs-top' ? 'moveleft' : 'moveup'), 'button_move_up_title')
618 button.classList.add('moveup', 'json-editor-btntype-move')
619 button.setAttribute('data-i', i)
620 button.addEventListener('click', e => {
621 e.preventDefault()
622 e.stopPropagation()
623 const i = e.currentTarget.getAttribute('data-i') * 1
624
625 if (i <= 0) return
626 const rows = this.getValue()
627 const tmp = rows[i - 1]
628 rows[i - 1] = rows[i]
629 rows[i] = tmp
630
631 this.setValue(rows)
632 this.active_tab = this.rows[i - 1].tab
633 this.refreshTabs()
634
635 this.onChange(true)
636
637 this.jsoneditor.trigger('moveRow', this.rows[i - 1])
638 })
639
640 if (holder) {
641 holder.appendChild(button)
642 }
643 return button
644 }
645
646 _createMoveDownButton (i, holder) {
647 const button = this.getButton('', (this.schema.format === 'tabs-top' ? 'moveright' : 'movedown'), 'button_move_down_title')

Callers 1

addRowMethod · 0.95

Calls 7

setValueMethod · 0.95
refreshTabsMethod · 0.95
addMethod · 0.80
triggerMethod · 0.80
getButtonMethod · 0.45
getValueMethod · 0.45
onChangeMethod · 0.45

Tested by

no test coverage detected