@@ -626,52 +626,39 @@ $(function () {
626626 }
627627 } ) ;
628628
629- // Add chapter before
630- $ ( "#chapter-tbody" ) . on ( "click" , ".btn-add-before" , function ( ) {
631- var $row = $ ( this ) . closest ( "tr" ) ;
632- var newRow =
629+ function buildNewChapterRowHtml ( ) {
630+ return (
633631 "<tr>" +
634632 "<td class='chapter-number'></td>" +
635- "<td><div class='editable-cell' contenteditable='true' data-field='title'>New Chapter</div></td>" +
636- "<td><div class='editable-cell' contenteditable='true' data-field='summary'>Enter chapter summary...</div></td>" +
633+ "<td><div class='editable-cell' contenteditable='true' data-field='title' role='textbox' aria-label='Chapter title' >New Chapter</div></td>" +
634+ "<td><div class='editable-cell' contenteditable='true' data-field='summary' role='textbox' aria-label='Chapter summary' >Enter chapter summary...</div></td>" +
637635 "<td class='text-center'>" +
638- "<div class='btn-group btn-group-sm me-1' role='group'>" +
639- "<button class='btn btn-outline-secondary btn-move-up' title='Move Up'><i class='bi bi-arrow-up'></i></button>" +
640- "<button class='btn btn-outline-secondary btn-move-down' title='Move Down'><i class='bi bi-arrow-down'></i></button>" +
636+ "<div class='btn-group btn-group-sm me-1' role='group' aria-label='Reorder chapter' >" +
637+ "<button class='btn btn-outline-secondary btn-move-up' title='Move Up' aria-label='Move chapter up' ><i class='bi bi-arrow-up'></i></button>" +
638+ "<button class='btn btn-outline-secondary btn-move-down' title='Move Down' aria-label='Move chapter down' ><i class='bi bi-arrow-down'></i></button>" +
641639 "</div>" +
642- "<div class='btn-group btn-group-sm me-1' role='group'>" +
643- "<button class='btn btn-outline-success btn-add-before' title='Add Before'><i class='bi bi-plus-circle'></i></button>" +
644- "<button class='btn btn-outline-success btn-add-after' title='Add After'><i class='bi bi-plus-circle'></i></button>" +
640+ "<div class='btn-group btn-group-sm me-1' role='group' aria-label='Insert around chapter' >" +
641+ "<button class='btn btn-outline-success btn-add-before' title='Add Before' aria-label='Add chapter before' ><i class='bi bi-plus-circle'></i></button>" +
642+ "<button class='btn btn-outline-success btn-add-after' title='Add After' aria-label='Add chapter after' ><i class='bi bi-plus-circle'></i></button>" +
645643 "</div>" +
646- "<button class='btn btn-sm btn-outline-danger btn-delete-chapter' title='Delete Chapter'><i class='bi bi-trash'></i></button>" +
644+ "<button class='btn btn-sm btn-outline-danger btn-delete-chapter' title='Delete Chapter' aria-label='Delete chapter' ><i class='bi bi-trash'></i></button>" +
647645 "</td>" +
648- "</tr>" ;
649- $row . before ( newRow ) ;
646+ "</tr>"
647+ ) ;
648+ }
649+
650+ // Add chapter before
651+ $ ( "#chapter-tbody" ) . on ( "click" , ".btn-add-before" , function ( ) {
652+ var $row = $ ( this ) . closest ( "tr" ) ;
653+ $row . before ( buildNewChapterRowHtml ( ) ) ;
650654 renumberChapters ( ) ;
651655 markOutlineDirty ( ) ;
652656 } ) ;
653657
654658 // Add chapter after
655659 $ ( "#chapter-tbody" ) . on ( "click" , ".btn-add-after" , function ( ) {
656660 var $row = $ ( this ) . closest ( "tr" ) ;
657- var newRow =
658- "<tr>" +
659- "<td class='chapter-number'></td>" +
660- "<td><div class='editable-cell' contenteditable='true' data-field='title'>New Chapter</div></td>" +
661- "<td><div class='editable-cell' contenteditable='true' data-field='summary'>Enter chapter summary...</div></td>" +
662- "<td class='text-center'>" +
663- "<div class='btn-group btn-group-sm me-1' role='group'>" +
664- "<button class='btn btn-outline-secondary btn-move-up' title='Move Up'><i class='bi bi-arrow-up'></i></button>" +
665- "<button class='btn btn-outline-secondary btn-move-down' title='Move Down'><i class='bi bi-arrow-down'></i></button>" +
666- "</div>" +
667- "<div class='btn-group btn-group-sm me-1' role='group'>" +
668- "<button class='btn btn-outline-success btn-add-before' title='Add Before'><i class='bi bi-plus-circle'></i></button>" +
669- "<button class='btn btn-outline-success btn-add-after' title='Add After'><i class='bi bi-plus-circle'></i></button>" +
670- "</div>" +
671- "<button class='btn btn-sm btn-outline-danger btn-delete-chapter' title='Delete Chapter'><i class='bi bi-trash'></i></button>" +
672- "</td>" +
673- "</tr>" ;
674- $row . after ( newRow ) ;
661+ $row . after ( buildNewChapterRowHtml ( ) ) ;
675662 renumberChapters ( ) ;
676663 markOutlineDirty ( ) ;
677664 } ) ;
0 commit comments