summaryrefslogtreecommitdiffstatshomepage
path: root/src/js/_enqueues/lib/ajax-response.js
diff options
context:
space:
mode:
authorJoe Dolson <joedolson@git.wordpress.org>2021-11-15 22:23:01 +0000
committerJoe Dolson <joedolson@git.wordpress.org>2021-11-15 22:23:01 +0000
commit74d7ef73b361fff82605291282588dc05059dc27 (patch)
tree8f50550046db2b422cceadf27cd432835857824d /src/js/_enqueues/lib/ajax-response.js
parent706018e08fd091e0958d9f1b04d411efc25abf8b (diff)
downloadwordpress-74d7ef73b361fff82605291282588dc05059dc27.tar.gz
wordpress-74d7ef73b361fff82605291282588dc05059dc27.zip
Taxonomy: Display update notices when adding terms.
Display notice and announce to screen readers when a new term is added. Props manishamakhija, birgire, dilipbheda, afercia, hellofromTonya. Fixes #42937. git-svn-id: https://develop.svn.wordpress.org/trunk@52170 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src/js/_enqueues/lib/ajax-response.js')
-rw-r--r--src/js/_enqueues/lib/ajax-response.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/js/_enqueues/lib/ajax-response.js b/src/js/_enqueues/lib/ajax-response.js
index 38816f3c38..659b91e023 100644
--- a/src/js/_enqueues/lib/ajax-response.js
+++ b/src/js/_enqueues/lib/ajax-response.js
@@ -18,7 +18,7 @@ window.wpAjax = jQuery.extend( {
return r;
},
parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission.
- var parsed = {}, re = jQuery('#' + r).empty(), err = '';
+ var parsed = {}, re = jQuery('#' + r).empty(), err = '', successmsg = '';
if ( x && typeof x === 'object' && x.getElementsByTagName('wp_ajax') ) {
parsed.responses = [];
@@ -27,6 +27,7 @@ window.wpAjax = jQuery.extend( {
var th = jQuery(this), child = jQuery(this.firstChild), response;
response = { action: th.attr('action'), what: child.get(0).nodeName, id: child.attr('id'), oldId: child.attr('old_id'), position: child.attr('position') };
response.data = jQuery( 'response_data', child ).text();
+ successmsg += response.data;
response.supplemental = {};
if ( !jQuery( 'supplemental', child ).children().each( function() {
response.supplemental[this.nodeName] = jQuery(this).text();
@@ -46,7 +47,14 @@ window.wpAjax = jQuery.extend( {
} ).length ) { response.errors = false; }
parsed.responses.push( response );
} );
- if ( err.length ) { re.html( '<div class="error">' + err + '</div>' ); }
+ if ( err.length ) {
+ re.html( '<div class="error">' + err + '</div>' );
+ wp.a11y.speak( err );
+ } else {
+ re.html( '<div class="updated notice is-dismissible"><p>' + successmsg + '</p></div>');
+ jQuery(document).trigger( 'wp-updates-notice-added' );
+ wp.a11y.speak( successmsg );
+ }
return parsed;
}
if ( isNaN(x) ) { return !re.html('<div class="error"><p>' + x + '</p></div>'); }