Changeset 60700
- Timestamp:
- 09/01/2025 09:20:13 PM (3 months ago)
- File:
-
- 1 edited
-
trunk/src/js/_enqueues/admin/tags.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/admin/tags.js
r59960 r60700 31 31 if ( r ) { 32 32 data = t.attr('href').replace(/[^?]*\?/, '').replace(/action=delete/, 'action=delete-tag'); 33 34 tr.children().css('backgroundColor', '#faafaa'); 35 36 // Disable pointer events and all form controls/links in the row 37 tr.css('pointer-events', 'none'); 38 tr.find(':input, a').prop('disabled', true).attr('tabindex', -1); 33 39 34 40 /** … … 41 47 */ 42 48 $.post(ajaxurl, data, function(r){ 49 var message; 43 50 if ( '1' == r ) { 44 51 $('#ajax-response').empty(); 52 let nextFocus = tr.next( 'tr' ).find( 'a.row-title' ); 53 let prevFocus = tr.prev( 'tr' ).find( 'a.row-title' ); 54 // If there is neither a next row or a previous row, focus the tag input field. 55 if ( nextFocus.length < 1 && prevFocus.length < 1 ) { 56 nextFocus = $( '#tag-name' ).trigger( 'focus' ); 57 } else { 58 if ( nextFocus.length < 1 ) { 59 nextFocus = prevFocus; 60 } 61 } 62 45 63 tr.fadeOut('normal', function(){ tr.remove(); }); 46 64 … … 54 72 $('select#parent option[value="' + data.match(/tag_ID=(\d+)/)[1] + '"]').remove(); 55 73 $('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove(); 56 74 nextFocus.trigger( 'focus' ); 75 message = wp.i18n.__( 'The selected tag has been deleted.' ); 76 57 77 } else if ( '-1' == r ) { 58 $('#ajax-response').empty().append('<div class="notice notice-error"><p>' + wp.i18n.__( 'Sorry, you are not allowed to do that.' ) + '</p></div>'); 59 tr.children().css('backgroundColor', ''); 78 message = wp.i18n.__( 'Sorry, you are not allowed to do that.' ); 79 $('#ajax-response').empty().append('<div class="notice notice-error"><p>' + message + '</p></div>'); 80 resetRowAfterFailure( tr ); 60 81 61 82 } else { 62 $('#ajax-response').empty().append('<div class="notice notice-error"><p>' + wp.i18n.__( 'An error occurred while processing your request. Please try again later.' ) + '</p></div>'); 63 tr.children().css('backgroundColor', ''); 83 message = wp.i18n.__( 'An error occurred while processing your request. Please try again later.' ); 84 $('#ajax-response').empty().append('<div class="notice notice-error"><p>' + message + '</p></div>'); 85 resetRowAfterFailure( tr ); 64 86 } 87 wp.a11y.speak( message, 'assertive' ); 65 88 }); 66 67 tr.children().css('backgroundColor', '#f33');68 89 } 69 90 70 91 return false; 71 92 }); 93 94 /** 95 * Restores the original UI state of a table row after an AJAX failure. 96 * 97 * @param {jQuery} tr The table row to reset. 98 * @return {void} 99 */ 100 function resetRowAfterFailure( tr ) { 101 tr.children().css( 'backgroundColor', '' ); 102 tr.css( 'pointer-events', '' ); 103 tr.find( ':input, a' ).prop( 'disabled', false ).removeAttr( 'tabindex' ); 104 } 72 105 73 106 /**
Note: See TracChangeset
for help on using the changeset viewer.