External Libraries: Further fix jQuery deprecations in WordPress core.

This addresses `JQMIGRATE` warnings in some admin files and the Thickbox library.

Follow-up to [50001], [50270].

Props bordoni, poena.
See #51812.

git-svn-id: https://develop.svn.wordpress.org/trunk@50367 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2021-02-16 20:23:19 +00:00
parent e23d442cd9
commit 9bac3d3401
7 changed files with 36 additions and 36 deletions

View File

@@ -25,7 +25,7 @@
var name = $newAppPassField.val();
if ( 0 === name.length ) {
$newAppPassField.focus();
$newAppPassField.trigger( 'focus' );
return;
}
@@ -60,7 +60,7 @@
name: response.name,
password: response.password
} ) );
$( '.new-application-password-notice' ).focus();
$( '.new-application-password-notice' ).trigger( 'focus' );
$appPassTbody.prepend( tmplAppPassRow( response ) );
@@ -105,7 +105,7 @@
}
$tr.remove();
addNotice( wp.i18n.__( 'Application password revoked.' ), 'success' ).focus();
addNotice( wp.i18n.__( 'Application password revoked.' ), 'success' ).trigger( 'focus' );
}
} ).fail( handleErrorResponse );
} );
@@ -133,7 +133,7 @@
$appPassSection.children( '.new-application-password' ).remove();
$appPassTwrapper.hide();
addNotice( wp.i18n.__( 'All application passwords revoked.' ), 'success' ).focus();
addNotice( wp.i18n.__( 'All application passwords revoked.' ), 'success' ).trigger( 'focus' );
}
} ).fail( handleErrorResponse );
} );
@@ -145,7 +145,7 @@
$el.fadeTo( 100, 0, function () {
$el.slideUp( 100, function () {
$el.remove();
$newAppPassField.focus();
$newAppPassField.trigger( 'focus' );
} );
} );
} );

View File

@@ -72,7 +72,7 @@ jQuery( document ).ready( function( $ ) {
$rowActions.addClass( 'processing' );
$action.blur();
$action.trigger( 'blur' );
clearResultsAfterRow( $requestRow );
setExportProgress( 0 );
@@ -177,7 +177,7 @@ jQuery( document ).ready( function( $ ) {
$rowActions.addClass( 'processing' );
$action.blur();
$action.trigger( 'blur' );
clearResultsAfterRow( $requestRow );
setErasureProgress( 0 );

View File

@@ -24,7 +24,7 @@ jQuery( document ).ready( function( $ ) {
// Clear the selection and move focus back to the trigger.
e.clearSelection();
// Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
triggerElement.focus();
triggerElement.trigger( 'focus' );
// Show success visual feedback.
clearTimeout( successTimeout );

View File

@@ -6,7 +6,7 @@
*/
jQuery( document ).ready(function( $ ) {
$( '#link_rel' ).prop( 'readonly', true );
$( '#linkxfndiv input' ).bind( 'click keyup', function() {
$( '#linkxfndiv input' ).on( 'click keyup', function() {
var isMe = $( '#me' ).is( ':checked' ), inputs = '';
$( 'input.valinp' ).each( function() {
if ( isMe ) {

View File

@@ -19,7 +19,7 @@
buttons: function( event, t ) {
var button = $('<a class="close" href="#"></a>').text( wp.i18n.__( 'Dismiss' ) );
return button.bind( 'click.pointer', function(e) {
return button.on( 'click.pointer', function(e) {
e.preventDefault();
t.element.pointer('close');
});

View File

@@ -35,7 +35,7 @@ function tb_click(){
var a = this.href || this.alt;
var g = this.rel || false;
tb_show(t,a,g);
this.blur();
this.trigger( 'blur' );
return false;
}
@@ -49,12 +49,12 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
jQuery("html").css("overflow","hidden");
if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe><div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
jQuery("#TB_overlay").click(tb_remove);
jQuery("#TB_overlay").trigger( 'click', tb_remove );
}
}else{//all others
if(document.getElementById("TB_overlay") === null){
jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
jQuery("#TB_overlay").click(tb_remove);
jQuery("#TB_overlay").trigger( 'click', tb_remove );
jQuery( 'body' ).addClass( 'modal-open' );
}
}
@@ -141,17 +141,17 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
TB_HEIGHT = imageHeight + 60;
jQuery("#TB_window").append("<a href='' id='TB_ImageOff'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><button type='button' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><span class='tb-close-icon'></span></button></div>");
jQuery("#TB_closeWindowButton").click(tb_remove);
jQuery("#TB_closeWindowButton").trigger( 'click', tb_remove );
if (!(TB_PrevHTML === "")) {
function goPrev(){
if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);}
if(jQuery(document).off("click",goPrev)){jQuery(document).off("click",goPrev);}
jQuery("#TB_window").remove();
jQuery("body").append("<div id='TB_window'></div>");
tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
return false;
}
jQuery("#TB_prev").click(goPrev);
jQuery("#TB_prev").trigger( 'click', goPrev );
}
if (!(TB_NextHTML === "")) {
@@ -161,22 +161,22 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
tb_show(TB_NextCaption, TB_NextURL, imageGroup);
return false;
}
jQuery("#TB_next").click(goNext);
jQuery("#TB_next").trigger( 'click', goNext );
}
jQuery(document).bind('keydown.thickbox', function(e){
jQuery(document).on('keydown.thickbox', function(e){
if ( e.which == 27 ){ // close
tb_remove();
} else if ( e.which == 190 ){ // display previous image
if(!(TB_NextHTML == "")){
jQuery(document).unbind('thickbox');
jQuery(document).off('thickbox');
goNext();
}
} else if ( e.which == 188 ){ // display next image
if(!(TB_PrevHTML == "")){
jQuery(document).unbind('thickbox');
jQuery(document).off('thickbox');
goPrev();
}
}
@@ -185,7 +185,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
tb_position();
jQuery("#TB_load").remove();
jQuery("#TB_ImageOff").click(tb_remove);
jQuery("#TB_ImageOff").trigger( 'click', tb_remove );
jQuery("#TB_window").css({'visibility':'visible'}); //for safari using css instead of show
};
@@ -206,7 +206,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
if(params['modal'] != "true"){//iframe no modal
jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><button type='button' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><span class='tb-close-icon'></span></button></div></div><iframe frameborder='0' hspace='0' allowtransparency='true' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' >"+thickboxL10n.noiframes+"</iframe>");
}else{//iframe modal
jQuery("#TB_overlay").unbind();
jQuery("#TB_overlay").off();
jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' allowtransparency='true' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'>"+thickboxL10n.noiframes+"</iframe>");
}
}else{// not an iframe, ajax
@@ -214,7 +214,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
if(params['modal'] != "true"){//ajax no modal
jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><button type='button' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><span class='tb-close-icon'></span></button></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
}else{//ajax modal
jQuery("#TB_overlay").unbind();
jQuery("#TB_overlay").off();
jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
}
}else{//this means the window is already up, we are just loading new content via ajax
@@ -225,11 +225,11 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
}
}
jQuery("#TB_closeWindowButton").click(tb_remove);
jQuery("#TB_closeWindowButton").trigger( 'click', tb_remove );
if(url.indexOf('TB_inline') != -1){
jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
jQuery("#TB_window").bind('tb_unload', function () {
jQuery("#TB_window").on('tb_unload', function () {
jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished
});
tb_position();
@@ -253,7 +253,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
}
if(!params['modal']){
jQuery(document).bind('keydown.thickbox', function(e){
jQuery(document).on('keydown.thickbox', function(e){
if ( e.which == 27 ){ // close
tb_remove();
return false;
@@ -268,7 +268,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
* In other admin screens is hidden and replaced by a different icon.
*/
if ( $closeBtn.find( '.tb-close-icon' ).is( ':visible' ) ) {
$closeBtn.focus();
$closeBtn.trigger( 'focus' );
}
} catch(e) {
@@ -283,10 +283,10 @@ function tb_showIframe(){
}
function tb_remove() {
jQuery("#TB_imageOff").unbind("click");
jQuery("#TB_closeWindowButton").unbind("click");
jQuery("#TB_imageOff").off("click");
jQuery("#TB_closeWindowButton").off("click");
jQuery( '#TB_window' ).fadeOut( 'fast', function() {
jQuery( '#TB_window, #TB_overlay, #TB_HideSelect' ).trigger( 'tb_unload' ).unbind().remove();
jQuery( '#TB_window, #TB_overlay, #TB_HideSelect' ).trigger( 'tb_unload' ).off().remove();
jQuery( 'body' ).trigger( 'thickbox:removed' );
});
jQuery( 'body' ).removeClass( 'modal-open' );
@@ -295,7 +295,7 @@ function tb_remove() {
jQuery("body","html").css({height: "auto", width: "auto"});
jQuery("html").css("overflow","");
}
jQuery(document).unbind('.thickbox');
jQuery(document).off('.thickbox');
return false;
}

View File

@@ -48,7 +48,7 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
// Clear the selection and move focus back to the trigger.
event.clearSelection();
// Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
triggerElement.focus();
triggerElement.trigger( 'focus' );
// Show success visual feedback.
clearTimeout( successTimeout );
@@ -105,18 +105,18 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
*/
moveFocus: function() {
if ( this.previousAttachment.length ) {
this.previousAttachment.focus();
this.previousAttachment.trigger( 'focus' );
return;
}
if ( this.nextAttachment.length ) {
this.nextAttachment.focus();
this.nextAttachment.trigger( 'focus' );
return;
}
// Fallback: move focus to the "Select Files" button in the media modal.
if ( this.controller.uploader && this.controller.uploader.$browser ) {
this.controller.uploader.$browser.focus();
this.controller.uploader.$browser.trigger( 'focus' );
return;
}
@@ -133,7 +133,7 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
// Last fallback: make the frame focusable and move focus to it.
$( '.media-frame' )
.attr( 'tabindex', '-1' )
.focus();
.trigger( 'focus' );
},
/**