(i, holder)
| 534 | } |
| 535 | |
| 536 | _createDeleteButton (i, holder) { |
| 537 | const button = this.getButton(this.getItemTitle(), 'delete', 'button_delete_row_title', [this.getItemTitle()]) |
| 538 | button.classList.add('delete', 'json-editor-btntype-delete') |
| 539 | button.setAttribute('data-i', i) |
| 540 | button.addEventListener('click', e => { |
| 541 | e.preventDefault() |
| 542 | e.stopPropagation() |
| 543 | |
| 544 | if (!this.askConfirmation()) { |
| 545 | return false |
| 546 | } |
| 547 | |
| 548 | const i = e.currentTarget.getAttribute('data-i') * 1 |
| 549 | const newval = this.getValue().filter((row, j) => j !== i) |
| 550 | let newActiveTab = null |
| 551 | |
| 552 | const editor = this.rows[i] |
| 553 | const editorValue = editor.getValue() |
| 554 | |
| 555 | this.setValue(newval) |
| 556 | |
| 557 | if (this.rows[i]) { |
| 558 | newActiveTab = this.rows[i].tab |
| 559 | } else if (this.rows[i - 1]) { |
| 560 | newActiveTab = this.rows[i - 1].tab |
| 561 | } |
| 562 | |
| 563 | if (newActiveTab) { |
| 564 | this.active_tab = newActiveTab |
| 565 | this.refreshTabs() |
| 566 | } |
| 567 | |
| 568 | this.onChange(true) |
| 569 | this.jsoneditor.trigger('deleteRow', editorValue) |
| 570 | }) |
| 571 | |
| 572 | if (holder) { |
| 573 | holder.appendChild(button) |
| 574 | } |
| 575 | return button |
| 576 | } |
| 577 | |
| 578 | _createCopyButton (i, holder) { |
| 579 | const button = this.getButton(this.getItemTitle(), 'copy', 'button_copy_row_title', [this.getItemTitle()]) |
no test coverage detected