X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8ab4a4532479e8db471032b51042ec8c4716d091..b22765f41bf0b2021b9beb9120ee0ac91fa89292:/wp-admin/js/inline-edit-tax.js diff --git a/wp-admin/js/inline-edit-tax.js b/wp-admin/js/inline-edit-tax.js index e1746462..3bbf4fb7 100644 --- a/wp-admin/js/inline-edit-tax.js +++ b/wp-admin/js/inline-edit-tax.js @@ -1,7 +1,8 @@ /* global inlineEditL10n, ajaxurl */ +window.wp = window.wp || {}; var inlineEditTax; -(function($) { +( function( $, wp ) { inlineEditTax = { init : function() { @@ -22,10 +23,10 @@ inlineEditTax = { } }); - $( 'a.cancel', row ).click( function() { + $( '.cancel', row ).click( function() { return inlineEditTax.revert(); }); - $( 'a.save', row ).click( function() { + $( '.save', row ).click( function() { return inlineEditTax.save(this); }); $( 'input, select', row ).keydown( function( e ) { @@ -54,7 +55,7 @@ inlineEditTax = { } editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); - $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); + $( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '.wp-list-table.widefat:first thead' ).length ); $(t.what+id).hide().after(editRow).after(''); @@ -96,7 +97,9 @@ inlineEditTax = { // make ajax request $.post( ajaxurl, params, function(r) { - var row, new_id, option_value; + var row, new_id, option_value, + $errorSpan = $( '#edit-' + id + ' .inline-edit-save .error' ); + $( 'table.widefat .spinner' ).removeClass( 'is-active' ); if (r) { @@ -117,15 +120,24 @@ inlineEditTax = { // Update the value in the Parent dropdown. $( '#parent' ).find( 'option[value=' + option_value + ']' ).text( row.find( '.row-title' ).text() ); - row.hide().fadeIn(); + row.hide().fadeIn( 400, function() { + // Move focus back to the Quick Edit link. + row.find( '.editinline' ).focus(); + wp.a11y.speak( inlineEditL10n.saved ); + }); + } else { - $('#edit-'+id+' .inline-edit-save .error').html(r).show(); + $errorSpan.html( r ).show(); + // Some error strings may contain HTML entities (e.g. `“`), let's use the HTML element's text. + wp.a11y.speak( $errorSpan.text() ); } } else { - $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show(); + $errorSpan.html( inlineEditL10n.error ).show(); + wp.a11y.speak( inlineEditL10n.error ); } } ); + // Prevent submitting the form when pressing Enter on a focused field. return false; }, @@ -136,10 +148,9 @@ inlineEditTax = { $( 'table.widefat .spinner' ).removeClass( 'is-active' ); $('#'+id).siblings('tr.hidden').addBack().remove(); id = id.substr( id.lastIndexOf('-') + 1 ); - $(this.what+id).show(); + // Show the taxonomy row and move focus back to the Quick Edit link. + $( this.what + id ).show().find( '.editinline' ).focus(); } - - return false; }, getId : function(o) { @@ -149,4 +160,4 @@ inlineEditTax = { }; $(document).ready(function(){inlineEditTax.init();}); -})(jQuery); +})( jQuery, window.wp );