--- a/wp/wp-admin/js/inline-edit-post.js Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/js/inline-edit-post.js Tue Dec 15 13:49:49 2020 +0100
@@ -5,7 +5,7 @@
* @output wp-admin/js/inline-edit-post.js
*/
-/* global inlineEditL10n, ajaxurl, typenow, inlineEditPost */
+/* global ajaxurl, typenow, inlineEditPost */
window.wp = window.wp || {};
@@ -19,7 +19,7 @@
* @type {Object}
*
* @property {string} type The type of inline editor.
- * @property {string} what The prefix before the post id.
+ * @property {string} what The prefix before the post ID.
*
*/
( function( $, wp ) {
@@ -29,41 +29,42 @@
/**
* Initializes the inline and bulk post editor.
*
- * Binds event handlers to the escape key to close the inline editor
+ * Binds event handlers to the Escape key to close the inline editor
* and to the save and close buttons. Changes DOM to be ready for inline
* editing. Adds event handler to bulk edit.
*
- * @memberof inlineEditPost
* @since 2.7.0
*
- * @returns {void}
+ * @memberof inlineEditPost
+ *
+ * @return {void}
*/
init : function(){
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
- // Post id prefix.
+ // Post ID prefix.
t.what = '#post-';
/**
- * Binds the escape key to revert the changes and close the quick editor.
+ * Binds the Escape key to revert the changes and close the quick editor.
*
- * @returns {boolean} The result of revert.
+ * @return {boolean} The result of revert.
*/
qeRow.keyup(function(e){
- // Revert changes if escape key is pressed.
+ // Revert changes if Escape key is pressed.
if ( e.which === 27 ) {
return inlineEditPost.revert();
}
});
/**
- * Binds the escape key to revert the changes and close the bulk editor.
+ * Binds the Escape key to revert the changes and close the bulk editor.
*
- * @returns {boolean} The result of revert.
+ * @return {boolean} The result of revert.
*/
bulkRow.keyup(function(e){
- // Revert changes if escape key is pressed.
+ // Revert changes if Escape key is pressed.
if ( e.which === 27 ) {
return inlineEditPost.revert();
}
@@ -72,7 +73,7 @@
/**
* Reverts changes and close the quick editor if the cancel button is clicked.
*
- * @returns {boolean} The result of revert.
+ * @return {boolean} The result of revert.
*/
$( '.cancel', qeRow ).click( function() {
return inlineEditPost.revert();
@@ -81,16 +82,16 @@
/**
* Saves changes in the quick editor if the save(named: update) button is clicked.
*
- * @returns {boolean} The result of save.
+ * @return {boolean} The result of save.
*/
$( '.save', qeRow ).click( function() {
return inlineEditPost.save(this);
});
/**
- * If enter is pressed, and the target is not the cancel button, save the post.
+ * If Enter is pressed, and the target is not the cancel button, save the post.
*
- * @returns {boolean} The result of save.
+ * @return {boolean} The result of save.
*/
$('td', qeRow).keydown(function(e){
if ( e.which === 13 && ! $( e.target ).hasClass( 'cancel' ) ) {
@@ -101,7 +102,7 @@
/**
* Reverts changes and close the bulk editor if the cancel button is clicked.
*
- * @returns {boolean} The result of revert.
+ * @return {boolean} The result of revert.
*/
$( '.cancel', bulkRow ).click( function() {
return inlineEditPost.revert();
@@ -157,8 +158,9 @@
* Toggles the quick edit window, hiding it when it's active and showing it when
* inactive.
*
+ * @since 2.7.0
+ *
* @memberof inlineEditPost
- * @since 2.7.0
*
* @param {Object} el Element within a post table row.
*/
@@ -170,8 +172,9 @@
/**
* Creates the bulk editor row to edit multiple posts at once.
*
+ * @since 2.7.0
+ *
* @memberof inlineEditPost
- * @since 2.7.0
*/
setBulk : function(){
var te = '', type = this.type, c = true;
@@ -195,8 +198,8 @@
if ( $(this).prop('checked') ) {
c = false;
var id = $(this).val(), theTitle;
- theTitle = $('#inline_'+id+' .post_title').html() || inlineEditL10n.notitle;
- te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
+ theTitle = $('#inline_'+id+' .post_title').html() || wp.i18n.__( '(no title)' );
+ te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+ wp.i18n.__( 'Remove From Bulk Edit' ) +'">X</a>'+theTitle+'</div>';
}
});
@@ -242,12 +245,13 @@
/**
* Creates a quick edit window for the post that has been clicked.
*
- * @memberof inlineEditPost
* @since 2.7.0
*
- * @param {number|Object} id The id of the clicked post or an element within a post
+ * @memberof inlineEditPost
+ *
+ * @param {number|Object} id The ID of the clicked post or an element within a post
* table row.
- * @returns {boolean} Always returns false at the end of execution.
+ * @return {boolean} Always returns false at the end of execution.
*/
edit : function(id) {
var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, f, val, pw;
@@ -285,7 +289,7 @@
/**
* Replaces the image for a Twemoji(Twitter emoji) with it's alternate text.
*
- * @returns Alternate text from the image.
+ * @return {string} Alternate text from the image.
*/
val.find( 'img' ).replaceWith( function() { return this.alt; } );
val = val.text();
@@ -323,7 +327,7 @@
var terms = $(this),
taxname = $(this).attr('id').replace('_' + id, ''),
textarea = $('textarea.tax_input_' + taxname, editRow),
- comma = inlineEditL10n.comma;
+ comma = wp.i18n._x( ',', 'tag delimiter' ).trim();
terms.find( 'img' ).replaceWith( function() { return this.alt; } );
terms = terms.text();
@@ -381,13 +385,13 @@
/**
* Saves the changes made in the quick edit window to the post.
- * AJAX saving is only for Quick Edit and not for bulk edit.
+ * Ajax saving is only for Quick Edit and not for bulk edit.
*
* @since 2.7.0
*
- * @param {int} id The id for the post that has been changed.
- * @returns {boolean} false, so the form does not submit when pressing
- * Enter on a focused field.
+ * @param {number} id The ID for the post that has been changed.
+ * @return {boolean} False, so the form does not submit when pressing
+ * Enter on a focused field.
*/
save : function(id) {
var params, fields, page = $('.post_status_page').val() || '';
@@ -409,7 +413,7 @@
fields = $('#edit-'+id).find(':input').serialize();
params = fields + '&' + $.param(params);
- // Make ajax request.
+ // Make Ajax request.
$.post( ajaxurl, params,
function(r) {
var $errorNotice = $( '#edit-' + id + ' .inline-edit-save .notice-error' ),
@@ -427,7 +431,7 @@
$( this ).find( '.editinline' )
.attr( 'aria-expanded', 'false' )
.focus();
- wp.a11y.speak( inlineEditL10n.saved );
+ wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) );
});
} else {
r = r.replace( /<.[^<>]*?>/g, '' );
@@ -437,8 +441,8 @@
}
} else {
$errorNotice.removeClass( 'hidden' );
- $error.html( inlineEditL10n.error );
- wp.a11y.speak( inlineEditL10n.error );
+ $error.text( wp.i18n.__( 'Error while saving the changes.' ) );
+ wp.a11y.speak( wp.i18n.__( 'Error while saving the changes.' ) );
}
},
'html');
@@ -450,10 +454,11 @@
/**
* Hides and empties the Quick Edit and/or Bulk Edit windows.
*
- * @memberof inlineEditPost
* @since 2.7.0
*
- * @returns {boolean} Always returns false.
+ * @memberof inlineEditPost
+ *
+ * @return {boolean} Always returns false.
*/
revert : function(){
var $tableWideFat = $( '.widefat' ),
@@ -491,14 +496,15 @@
},
/**
- * Gets the id for a the post that you want to quick edit from the row in the quick
+ * Gets the ID for a the post that you want to quick edit from the row in the quick
* edit table.
*
- * @memberof inlineEditPost
* @since 2.7.0
*
- * @param {Object} o DOM row object to get the id for.
- * @returns {string} The post id extracted from the table row in the object.
+ * @memberof inlineEditPost
+ *
+ * @param {Object} o DOM row object to get the ID for.
+ * @return {string} The post ID extracted from the table row in the object.
*/
getId : function(o) {
var id = $(o).closest('tr').attr('id'),
@@ -523,14 +529,20 @@
row.find('.check-column checkbox').prop('checked', false);
if ( lock_data.avatar_src ) {
- avatar = $( '<img class="avatar avatar-18 photo" width="18" height="18" alt="" />' ).attr( 'src', lock_data.avatar_src.replace( /&/g, '&' ) );
+ avatar = $( '<img />', {
+ 'class': 'avatar avatar-18 photo',
+ width: 18,
+ height: 18,
+ alt: '',
+ src: lock_data.avatar_src,
+ srcset: lock_data.avatar_src_2x ? lock_data.avatar_src_2x + ' 2x' : undefined
+ } );
row.find('.column-title .locked-avatar').empty().append( avatar );
}
row.addClass('wp-locked');
}
} else if ( row.hasClass('wp-locked') ) {
- // Make room for the CSS animation
- row.removeClass('wp-locked').delay(1000).find('.locked-info span').empty();
+ row.removeClass( 'wp-locked' ).find( '.locked-info span' ).empty();
}
});
}).on( 'heartbeat-send.wp-check-locked-posts', function( e, data ) {
@@ -547,7 +559,7 @@
}
}).ready( function() {
- // Set the heartbeat interval to 15 sec.
+ // Set the heartbeat interval to 15 seconds.
if ( typeof wp !== 'undefined' && wp.heartbeat ) {
wp.heartbeat.interval( 15 );
}