Make WordPress Core

Changeset 50367


Ignore:
Timestamp:
02/16/2021 08:23:19 PM (6 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/js
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/application-passwords.js

    r50030 r50367  
    2626
    2727                if ( 0 === name.length ) {
    28                         $newAppPassField.focus();
     28                        $newAppPassField.trigger( 'focus' );
    2929                        return;
    3030                }
     
    6161                                password: response.password
    6262                        } ) );
    63                         $( '.new-application-password-notice' ).focus();
     63                        $( '.new-application-password-notice' ).trigger( 'focus' );
    6464
    6565                        $appPassTbody.prepend( tmplAppPassRow( response ) );
     
    106106                                $tr.remove();
    107107
    108                                 addNotice( wp.i18n.__( 'Application password revoked.' ), 'success' ).focus();
     108                                addNotice( wp.i18n.__( 'Application password revoked.' ), 'success' ).trigger( 'focus' );
    109109                        }
    110110                } ).fail( handleErrorResponse );
     
    134134                                $appPassTwrapper.hide();
    135135
    136                                 addNotice( wp.i18n.__( 'All application passwords revoked.' ), 'success' ).focus();
     136                                addNotice( wp.i18n.__( 'All application passwords revoked.' ), 'success' ).trigger( 'focus' );
    137137                        }
    138138                } ).fail( handleErrorResponse );
     
    146146                        $el.slideUp( 100, function () {
    147147                                $el.remove();
    148                                 $newAppPassField.focus();
     148                                $newAppPassField.trigger( 'focus' );
    149149                        } );
    150150                } );
  • trunk/src/js/_enqueues/admin/privacy-tools.js

    r50161 r50367  
    7373                $rowActions.addClass( 'processing' );
    7474
    75                 $action.blur();
     75                $action.trigger( 'blur' );
    7676                clearResultsAfterRow( $requestRow );
    7777                setExportProgress( 0 );
     
    178178                $rowActions.addClass( 'processing' );
    179179
    180                 $action.blur();
     180                $action.trigger( 'blur' );
    181181                clearResultsAfterRow( $requestRow );
    182182                setErasureProgress( 0 );
  • trunk/src/js/_enqueues/admin/site-health.js

    r50001 r50367  
    2525                e.clearSelection();
    2626                // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
    27                 triggerElement.focus();
     27                triggerElement.trigger( 'focus' );
    2828
    2929                // Show success visual feedback.
  • trunk/src/js/_enqueues/admin/xfn.js

    r45448 r50367  
    77jQuery( document ).ready(function( $ ) {
    88        $( '#link_rel' ).prop( 'readonly', true );
    9         $( '#linkxfndiv input' ).bind( 'click keyup', function() {
     9        $( '#linkxfndiv input' ).on( 'click keyup', function() {
    1010                var isMe = $( '#me' ).is( ':checked' ), inputs = '';
    1111                $( 'input.valinp' ).each( function() {
  • trunk/src/js/_enqueues/lib/pointer.js

    r48266 r50367  
    2020                                var button = $('<a class="close" href="#"></a>').text( wp.i18n.__( 'Dismiss' ) );
    2121
    22                                 return button.bind( 'click.pointer', function(e) {
     22                                return button.on( 'click.pointer', function(e) {
    2323                                        e.preventDefault();
    2424                                        t.element.pointer('close');
  • trunk/src/js/_enqueues/vendor/thickbox/thickbox.js

    r43309 r50367  
    3636        var g = this.rel || false;
    3737        tb_show(t,a,g);
    38         this.blur();
     38        this.trigger( 'blur' );
    3939        return false;
    4040}
     
    5050                        if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
    5151                                jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe><div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
    52                                 jQuery("#TB_overlay").click(tb_remove);
     52                                jQuery("#TB_overlay").trigger( 'click', tb_remove );
    5353                        }
    5454                }else{//all others
    5555                        if(document.getElementById("TB_overlay") === null){
    5656                                jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
    57                                 jQuery("#TB_overlay").click(tb_remove);
     57                                jQuery("#TB_overlay").trigger( 'click', tb_remove );
    5858                                jQuery( 'body' ).addClass( 'modal-open' );
    5959                        }
     
    142142                        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>");
    143143
    144                         jQuery("#TB_closeWindowButton").click(tb_remove);
     144                        jQuery("#TB_closeWindowButton").trigger( 'click', tb_remove );
    145145
    146146                        if (!(TB_PrevHTML === "")) {
    147147                                function goPrev(){
    148                                         if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);}
     148                                        if(jQuery(document).off("click",goPrev)){jQuery(document).off("click",goPrev);}
    149149                                        jQuery("#TB_window").remove();
    150150                                        jQuery("body").append("<div id='TB_window'></div>");
     
    152152                                        return false;
    153153                                }
    154                                 jQuery("#TB_prev").click(goPrev);
     154                                jQuery("#TB_prev").trigger( 'click', goPrev );
    155155                        }
    156156
     
    162162                                        return false;
    163163                                }
    164                                 jQuery("#TB_next").click(goNext);
    165 
    166                         }
    167 
    168                         jQuery(document).bind('keydown.thickbox', function(e){
     164                                jQuery("#TB_next").trigger( 'click', goNext );
     165
     166                        }
     167
     168                        jQuery(document).on('keydown.thickbox', function(e){
    169169                                if ( e.which == 27 ){ // close
    170170                                        tb_remove();
     
    172172                                } else if ( e.which == 190 ){ // display previous image
    173173                                        if(!(TB_NextHTML == "")){
    174                                                 jQuery(document).unbind('thickbox');
     174                                                jQuery(document).off('thickbox');
    175175                                                goNext();
    176176                                        }
    177177                                } else if ( e.which == 188 ){ // display next image
    178178                                        if(!(TB_PrevHTML == "")){
    179                                                 jQuery(document).unbind('thickbox');
     179                                                jQuery(document).off('thickbox');
    180180                                                goPrev();
    181181                                        }
     
    186186                        tb_position();
    187187                        jQuery("#TB_load").remove();
    188                         jQuery("#TB_ImageOff").click(tb_remove);
     188                        jQuery("#TB_ImageOff").trigger( 'click', tb_remove );
    189189                        jQuery("#TB_window").css({'visibility':'visible'}); //for safari using css instead of show
    190190                        };
     
    207207                                                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>");
    208208                                        }else{//iframe modal
    209                                         jQuery("#TB_overlay").unbind();
     209                                        jQuery("#TB_overlay").off();
    210210                                                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>");
    211211                                        }
     
    215215                                                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>");
    216216                                                }else{//ajax modal
    217                                                 jQuery("#TB_overlay").unbind();
     217                                                jQuery("#TB_overlay").off();
    218218                                                jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
    219219                                                }
     
    226226                        }
    227227
    228                         jQuery("#TB_closeWindowButton").click(tb_remove);
     228                        jQuery("#TB_closeWindowButton").trigger( 'click', tb_remove );
    229229
    230230                                if(url.indexOf('TB_inline') != -1){
    231231                                        jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
    232                                         jQuery("#TB_window").bind('tb_unload', function () {
     232                                        jQuery("#TB_window").on('tb_unload', function () {
    233233                                                jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished
    234234                                        });
     
    254254
    255255                if(!params['modal']){
    256                         jQuery(document).bind('keydown.thickbox', function(e){
     256                        jQuery(document).on('keydown.thickbox', function(e){
    257257                                if ( e.which == 27 ){ // close
    258258                                        tb_remove();
     
    269269                 */
    270270                if ( $closeBtn.find( '.tb-close-icon' ).is( ':visible' ) ) {
    271                         $closeBtn.focus();
     271                        $closeBtn.trigger( 'focus' );
    272272                }
    273273
     
    284284
    285285function tb_remove() {
    286         jQuery("#TB_imageOff").unbind("click");
    287         jQuery("#TB_closeWindowButton").unbind("click");
     286        jQuery("#TB_imageOff").off("click");
     287        jQuery("#TB_closeWindowButton").off("click");
    288288        jQuery( '#TB_window' ).fadeOut( 'fast', function() {
    289                 jQuery( '#TB_window, #TB_overlay, #TB_HideSelect' ).trigger( 'tb_unload' ).unbind().remove();
     289                jQuery( '#TB_window, #TB_overlay, #TB_HideSelect' ).trigger( 'tb_unload' ).off().remove();
    290290                jQuery( 'body' ).trigger( 'thickbox:removed' );
    291291        });
     
    296296                jQuery("html").css("overflow","");
    297297        }
    298         jQuery(document).unbind('.thickbox');
     298        jQuery(document).off('.thickbox');
    299299        return false;
    300300}
  • trunk/src/js/media/views/attachment/details.js

    r49195 r50367  
    4949                        event.clearSelection();
    5050                        // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
    51                         triggerElement.focus();
     51                        triggerElement.trigger( 'focus' );
    5252
    5353                        // Show success visual feedback.
     
    106106        moveFocus: function() {
    107107                if ( this.previousAttachment.length ) {
    108                         this.previousAttachment.focus();
     108                        this.previousAttachment.trigger( 'focus' );
    109109                        return;
    110110                }
    111111
    112112                if ( this.nextAttachment.length ) {
    113                         this.nextAttachment.focus();
     113                        this.nextAttachment.trigger( 'focus' );
    114114                        return;
    115115                }
     
    117117                // Fallback: move focus to the "Select Files" button in the media modal.
    118118                if ( this.controller.uploader && this.controller.uploader.$browser ) {
    119                         this.controller.uploader.$browser.focus();
     119                        this.controller.uploader.$browser.trigger( 'focus' );
    120120                        return;
    121121                }
     
    134134                $( '.media-frame' )
    135135                        .attr( 'tabindex', '-1' )
    136                         .focus();
     136                        .trigger( 'focus' );
    137137        },
    138138
Note: See TracChangeset for help on using the changeset viewer.