';
+ var id = $( this ).val(),
+ theTitle = $( '#inline_' + id + ' .post_title' ).html() || wp.i18n.__( '(no title)' ),
+ buttonVisuallyHiddenText = wp.i18n.sprintf(
+ /* translators: %s: Post title. */
+ wp.i18n.__( 'Remove “%s” from Bulk Edit' ),
+ theTitle
+ );
+
+ te += '
' + theTitle + '
';
}
});
@@ -208,18 +214,34 @@
return this.revert();
}
- // Add onclick events to the delete-icons in the bulk editors the post title list.
- $('#bulk-titles').html(te);
+ // Populate the list of items to bulk edit.
+ $( '#bulk-titles' ).html( '
' + te + '
' );
+
/**
- * Binds on click events to the checkboxes before the posts in the table.
+ * Binds on click events to handle the list of items to bulk edit.
*
* @listens click
*/
- $('#bulk-titles a').on( 'click', function(){
- var id = $(this).attr('id').substr(1);
+ $( '#bulk-titles .ntdelbutton' ).click( function() {
+ var $this = $( this ),
+ id = $this.attr( 'id' ).substr( 1 ),
+ $prev = $this.parent().prev().children( '.ntdelbutton' ),
+ $next = $this.parent().next().children( '.ntdelbutton' );
+
+ $( 'table.widefat input[value="' + id + '"]' ).prop( 'checked', false );
+ $( '#_' + id ).parent().remove();
+ wp.a11y.speak( wp.i18n.__( 'Item removed.' ), 'assertive' );
- $('table.widefat input[value="' + id + '"]').prop('checked', false);
- $('#ttle'+id).remove();
+ // Move focus to a proper place when items are removed.
+ if ( $next.length ) {
+ $next.focus();
+ } else if ( $prev.length ) {
+ $prev.focus();
+ } else {
+ $( '#bulk-titles-list' ).remove();
+ inlineEditPost.revert();
+ wp.a11y.speak( wp.i18n.__( 'All selected items have been removed. Select new items to use Bulk Actions.' ) );
+ }
});
// Enable auto-complete for tags when editing posts.
@@ -238,6 +260,8 @@
} );
}
+ // Set initial focus on the Bulk Edit region.
+ $( '#bulk-edit .inline-edit-wrapper' ).attr( 'tabindex', '-1' ).focus();
// Scrolls to the top of the table where the editor is rendered.
$('html, body').animate( { scrollTop: 0 }, 'fast' );
},
@@ -270,6 +294,10 @@
editRow = $('#inline-edit').clone(true);
$( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
+ // Remove the ID from the copied row and let the `for` attribute reference the hidden ID.
+ $( 'td', editRow ).find('#quick-edit-legend').removeAttr('id');
+ $( 'td', editRow ).find('p[id^="quick-edit-"]').removeAttr('id');
+
$(t.what+id).removeClass('is-expanded').hide().after(editRow).after('