diff --git a/src/js/_enqueues/admin/application-passwords.js b/src/js/_enqueues/admin/application-passwords.js index cab592519b..622597e5a8 100644 --- a/src/js/_enqueues/admin/application-passwords.js +++ b/src/js/_enqueues/admin/application-passwords.js @@ -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' ); } ); } ); } ); diff --git a/src/js/_enqueues/admin/privacy-tools.js b/src/js/_enqueues/admin/privacy-tools.js index 331cf29959..c4565550da 100644 --- a/src/js/_enqueues/admin/privacy-tools.js +++ b/src/js/_enqueues/admin/privacy-tools.js @@ -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 ); diff --git a/src/js/_enqueues/admin/site-health.js b/src/js/_enqueues/admin/site-health.js index 1112f9adac..aabc91d6a1 100644 --- a/src/js/_enqueues/admin/site-health.js +++ b/src/js/_enqueues/admin/site-health.js @@ -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 ); diff --git a/src/js/_enqueues/admin/xfn.js b/src/js/_enqueues/admin/xfn.js index b72540d335..fdbe6a368f 100644 --- a/src/js/_enqueues/admin/xfn.js +++ b/src/js/_enqueues/admin/xfn.js @@ -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 ) { diff --git a/src/js/_enqueues/lib/pointer.js b/src/js/_enqueues/lib/pointer.js index 15849bc6ed..9d043f6dee 100644 --- a/src/js/_enqueues/lib/pointer.js +++ b/src/js/_enqueues/lib/pointer.js @@ -19,7 +19,7 @@ buttons: function( event, t ) { var button = $('').text( wp.i18n.__( 'Dismiss' ) ); - return button.bind( 'click.pointer', function(e) { + return button.on( 'click.pointer', function(e) { e.preventDefault(); t.element.pointer('close'); }); diff --git a/src/js/_enqueues/vendor/thickbox/thickbox.js b/src/js/_enqueues/vendor/thickbox/thickbox.js index 391fd4186e..fdd3bb991c 100644 --- a/src/js/_enqueues/vendor/thickbox/thickbox.js +++ b/src/js/_enqueues/vendor/thickbox/thickbox.js @@ -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("
"); - 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("
"); - 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(""+thickboxL10n.close+""+caption+"" + "
"+caption+"
" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "
"); - 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("
"); 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("
"+caption+"
"); }else{//iframe modal - jQuery("#TB_overlay").unbind(); + jQuery("#TB_overlay").off(); jQuery("#TB_window").append(""); } }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("
"+caption+"
"); }else{//ajax modal - jQuery("#TB_overlay").unbind(); + jQuery("#TB_overlay").off(); jQuery("#TB_window").append("
"); } }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; } diff --git a/src/js/media/views/attachment/details.js b/src/js/media/views/attachment/details.js index 5891fdf049..226a2714d2 100644 --- a/src/js/media/views/attachment/details.js +++ b/src/js/media/views/attachment/details.js @@ -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' ); }, /**