summaryrefslogtreecommitdiffstatshomepage
path: root/src/js/_enqueues/admin/edit-comments.js
diff options
context:
space:
mode:
authorAndrea Fercia <afercia@git.wordpress.org>2019-03-18 15:21:17 +0000
committerAndrea Fercia <afercia@git.wordpress.org>2019-03-18 15:21:17 +0000
commit01b2c8e34b29f8d37a6f1a43dca5a0a71fccb611 (patch)
treeb46d9c1b07d99a1f2edfb83069ade1f3bd350fab /src/js/_enqueues/admin/edit-comments.js
parent6d2f78d9bacf931fb9d4ba031e135c4eb5b17713 (diff)
downloadwordpress-01b2c8e34b29f8d37a6f1a43dca5a0a71fccb611.tar.gz
wordpress-01b2c8e34b29f8d37a6f1a43dca5a0a71fccb611.zip
Accessibility: Improve the Comments and Privacy count text.
- standardizes the Comment count string to `%s Comment in moderation', '%s Comments in moderation` so it can be bulk-updated - adds the string as visually hidden text in the admin menu - introduces an `updateInModerationText` JS simple function, responsible to correctly update all the related text using the data from the AJAX response - adds a visually hidden text "1 Privacy Policy update" to the Privacy menu items count - adds/improves translators comments Changes that apply to all the count bubbles (Updates, plugins, etc.) - makes the bubbles and their text slightly bigger - improves the active menu item bubble contrast by changing the background color to red (option 2 in the screenshot attached in a previous comment) Props adamsoucie, afercia. Fixes #33030. git-svn-id: https://develop.svn.wordpress.org/trunk@44924 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src/js/_enqueues/admin/edit-comments.js')
-rw-r--r--src/js/_enqueues/admin/edit-comments.js58
1 files changed, 38 insertions, 20 deletions
diff --git a/src/js/_enqueues/admin/edit-comments.js b/src/js/_enqueues/admin/edit-comments.js
index fff7191a1a..62fd7fa7d0 100644
--- a/src/js/_enqueues/admin/edit-comments.js
+++ b/src/js/_enqueues/admin/edit-comments.js
@@ -7,7 +7,7 @@
(function($) {
var getCount, updateCount, updateCountText, updatePending, updateApproved,
- updateHtmlTitle, updateDashboardText, adminTitle = document.title,
+ updateHtmlTitle, updateDashboardText, updateInModerationText, adminTitle = document.title,
isDashboard = $('#dashboard_right_now').length,
titleDiv, titleRegEx;
@@ -86,20 +86,38 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved,
});
};
- updateDashboardText = function ( response ) {
+ updateDashboardText = function( response ) {
if ( ! isDashboard || ! response || ! response.i18n_comments_text ) {
return;
}
- var rightNow = $( '#dashboard_right_now' );
+ $( '.comment-count a', '#dashboard_right_now' ).text( response.i18n_comments_text );
+ };
+
+ /**
+ * Updates the "comments in moderation" text across the UI.
+ *
+ * @since 5.2.0
+ *
+ * @param {object} response Ajax response from the server.
+ *
+ * @return {void}
+ */
+ updateInModerationText = function( response ) {
+ if ( ! response || ! response.i18n_moderation_text ) {
+ return;
+ }
- $( '.comment-count a', rightNow ).text( response.i18n_comments_text );
- $( '.comment-mod-count a', rightNow ).text( response.i18n_moderation_text )
- .parent()
- [ response.in_moderation > 0 ? 'removeClass' : 'addClass' ]( 'hidden' );
+ // Update the "comment in moderation" text across the UI.
+ $( '.comments-in-moderation-text' ).text( response.i18n_moderation_text );
+ // Hide the "comment in moderation" text in the Dashboard "At a Glance" widget.
+ if ( isDashboard && response.in_moderation ) {
+ $( '.comment-mod-count', '#dashboard_right_now' )
+ [ response.in_moderation > 0 ? 'removeClass' : 'addClass' ]( 'hidden' );
+ }
};
- updateHtmlTitle = function ( diff ) {
+ updateHtmlTitle = function( diff ) {
var newTitle, regExMatch, titleCount, commentFrag;
titleRegEx = titleRegEx || new RegExp( adminCommentsL10n.docTitleCommentsCount.replace( '%s', '\\([0-9' + thousandsSeparator + ']+\\)' ) + '?' );
@@ -238,6 +256,7 @@ window.setCommentsList = function() {
diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
if ( response ) {
updateDashboardText( response.supplemental );
+ updateInModerationText( response.supplemental );
updatePending( diff, response.supplemental.postId );
updateApproved( -1 * diff, response.supplemental.postId );
} else {
@@ -318,13 +337,18 @@ window.setCommentsList = function() {
spamDiff, trashDiff, pendingDiff, approvedDiff,
- approved = commentRow.hasClass( 'approved' ),
+ /*
+ * As `wpList` toggles only the `unapproved` class, the approved comment
+ * rows can have both the `approved` and `unapproved` classes.
+ */
+ approved = commentRow.hasClass( 'approved' ) && ! commentRow.hasClass( 'unapproved' ),
unapproved = commentRow.hasClass( 'unapproved' ),
spammed = commentRow.hasClass( 'spam' ),
trashed = commentRow.hasClass( 'trash' ),
undoing = false; // ticket #35904
updateDashboardText( newTotal );
+ updateInModerationText( newTotal );
// the order of these checks is important
// .unspam can also have .approve or .unapprove
@@ -508,7 +532,7 @@ window.setCommentsList = function() {
refillTheExtraList();
animated = $( ':animated', '#the-comment-list' );
- animatedCallback = function () {
+ animatedCallback = function() {
if ( ! $( '#the-comment-list tr:visible' ).length ) {
theList.get(0).wpList.add( theExtraList.find( '.no-items' ).clone() );
}
@@ -603,10 +627,6 @@ window.commentReply = {
});
this.comments_listing = $('#comments-form > input[name="comment_status"]').val() || '';
-
- /* $(listTable).bind('beforeChangePage', function(){
- commentReply.close();
- }); */
},
addEvents : function(r) {
@@ -843,12 +863,10 @@ window.commentReply = {
}
if ( r.supplemental.i18n_comments_text ) {
- if ( isDashboard ) {
- updateDashboardText( r.supplemental );
- } else {
- updateApproved( 1, r.supplemental.parent_post_id );
- updateCountText( 'span.all-count', 1 );
- }
+ updateDashboardText( r.supplemental );
+ updateInModerationText( r.supplemental );
+ updateApproved( 1, r.supplemental.parent_post_id );
+ updateCountText( 'span.all-count', 1 );
}
c = $.trim(r.data); // Trim leading whitespaces