Coding Standards: Wrap some long lines in `js/_enqueues/admin/post.js` per the JS coding standards for better readability.

See #53359.
Built from https://develop.svn.wordpress.org/trunk@52228


git-svn-id: http://core.svn.wordpress.org/trunk@51820 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-11-20 02:49:58 +00:00
parent 742cd201e6
commit c9ecd13aca
2 changed files with 64 additions and 22 deletions

View File

@ -135,21 +135,26 @@ window.wp = window.wp || {};
* @global * @global
*/ */
window.WPRemoveThumbnail = function(nonce){ window.WPRemoveThumbnail = function(nonce){
$.post(ajaxurl, { $.post(
action: 'set-post-thumbnail', post_id: $( '#post_ID' ).val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie ) ajaxurl, {
}, action: 'set-post-thumbnail',
post_id: $( '#post_ID' ).val(),
thumbnail_id: -1,
_ajax_nonce: nonce,
cookie: encodeURIComponent( document.cookie )
},
/** /**
* Handle server response * Handle server response
* *
* @param {string} str Response, will be '0' when an error occurred otherwise contains link to add Featured Image. * @param {string} str Response, will be '0' when an error occurred otherwise contains link to add Featured Image.
*/ */
function(str){ function(str){
if ( str == '0' ) { if ( str == '0' ) {
alert( __( 'Could not set that as the thumbnail image. Try a different attachment.' ) ); alert( __( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
} else { } else {
WPSetThumbnailHTML(str); WPSetThumbnailHTML(str);
}
} }
}
); );
}; };
@ -207,7 +212,9 @@ window.wp = window.wp || {};
height: 64, height: 64,
alt: '', alt: '',
src: received.lock_error.avatar_src, src: received.lock_error.avatar_src,
srcset: received.lock_error.avatar_src_2x ? received.lock_error.avatar_src_2x + ' 2x' : undefined srcset: received.lock_error.avatar_src_2x ?
received.lock_error.avatar_src_2x + ' 2x' :
undefined
} ); } );
wrap.find('div.post-locked-avatar').empty().append( avatar ); wrap.find('div.post-locked-avatar').empty().append( avatar );
} }
@ -666,11 +673,15 @@ jQuery( function($) {
}); });
// Sync checked items between "All {taxonomy}" and "Most used" lists. // Sync checked items between "All {taxonomy}" and "Most used" lists.
$('#' + taxonomy + 'checklist, #' + taxonomy + 'checklist-pop').on( 'click', 'li.popular-category > label input[type="checkbox"]', function() { $('#' + taxonomy + 'checklist, #' + taxonomy + 'checklist-pop').on(
var t = $(this), c = t.is(':checked'), id = t.val(); 'click',
if ( id && t.parents('#taxonomy-'+taxonomy).length ) 'li.popular-category > label input[type="checkbox"]',
$('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).prop( 'checked', c ); function() {
}); var t = $(this), c = t.is(':checked'), id = t.val();
if ( id && t.parents('#taxonomy-'+taxonomy).length )
$('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).prop( 'checked', c );
}
);
}); // End cats. }); // End cats.
@ -749,11 +760,28 @@ jQuery( function($) {
mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(); mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val();
attemptedDate = new Date( aa, mm - 1, jj, hh, mn ); attemptedDate = new Date( aa, mm - 1, jj, hh, mn );
originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val() ); originalDate = new Date(
currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() ); $('#hidden_aa').val(),
$('#hidden_mm').val() -1,
$('#hidden_jj').val(),
$('#hidden_hh').val(),
$('#hidden_mn').val()
);
currentDate = new Date(
$('#cur_aa').val(),
$('#cur_mm').val() -1,
$('#cur_jj').val(),
$('#cur_hh').val(),
$('#cur_mn').val()
);
// Catch unexpected date problems. // Catch unexpected date problems.
if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) { if (
attemptedDate.getFullYear() != aa ||
(1 + attemptedDate.getMonth()) != mm ||
attemptedDate.getDate() != jj ||
attemptedDate.getMinutes() != mn
) {
$timestampdiv.find('.timestamp-wrap').addClass('form-invalid'); $timestampdiv.find('.timestamp-wrap').addClass('form-invalid');
return false; return false;
} else { } else {
@ -820,7 +848,10 @@ jQuery( function($) {
); );
// Show or hide the "Save Draft" button. // Show or hide the "Save Draft" button.
if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) { if (
$('option:selected', postStatus).val() == 'private' ||
$('option:selected', postStatus).val() == 'publish'
) {
$('#save-post').hide(); $('#save-post').hide();
} else { } else {
$('#save-post').show(); $('#save-post').show();
@ -994,7 +1025,10 @@ jQuery( function($) {
$el = $( '#editable-post-name' ); $el = $( '#editable-post-name' );
revert_e = $el.html(); revert_e = $el.html();
buttons.html( '<button type="button" class="save button button-small">' + __( 'OK' ) + '</button> <button type="button" class="cancel button-link">' + __( 'Cancel' ) + '</button>' ); buttons.html(
'<button type="button" class="save button button-small">' + __( 'OK' ) + '</button> ' +
'<button type="button" class="cancel button-link">' + __( 'Cancel' ) + '</button>'
);
// Save permalink changes. // Save permalink changes.
buttons.children( '.save' ).on( 'click', function() { buttons.children( '.save' ).on( 'click', function() {
@ -1050,7 +1084,10 @@ jQuery( function($) {
slug_value = ( c > full.length / 4 ) ? '' : full; slug_value = ( c > full.length / 4 ) ? '' : full;
slug_label = __( 'URL Slug' ); slug_label = __( 'URL Slug' );
$el.html( '<label for="new-post-slug" class="screen-reader-text">' + slug_label + '</label><input type="text" id="new-post-slug" value="' + slug_value + '" autocomplete="off" spellcheck="false" />' ).children( 'input' ).on( 'keydown', function( e ) { $el.html(
'<label for="new-post-slug" class="screen-reader-text">' + slug_label + '</label>' +
'<input type="text" id="new-post-slug" value="' + slug_value + '" autocomplete="off" spellcheck="false" />'
).children( 'input' ).on( 'keydown', function( e ) {
var key = e.which; var key = e.which;
// On [Enter], just save the new slug, don't save the post. // On [Enter], just save the new slug, don't save the post.
if ( 13 === key ) { if ( 13 === key ) {
@ -1224,7 +1261,12 @@ jQuery( function($) {
$textarea.on( 'keydown.wp-autosave', function( event ) { $textarea.on( 'keydown.wp-autosave', function( event ) {
// Key [S] has code 83. // Key [S] has code 83.
if ( event.which === 83 ) { if ( event.which === 83 ) {
if ( event.shiftKey || event.altKey || ( isMac && ( ! event.metaKey || event.ctrlKey ) ) || ( ! isMac && ! event.ctrlKey ) ) { if (
event.shiftKey ||
event.altKey ||
( isMac && ( ! event.metaKey || event.ctrlKey ) ) ||
( ! isMac && ! event.ctrlKey )
) {
return; return;
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.9-alpha-52227'; $wp_version = '5.9-alpha-52228';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.