diff --git a/src/js/_enqueues/lib/image-edit.js b/src/js/_enqueues/lib/image-edit.js index 16a634aa6c..cc9c8a67a6 100644 --- a/src/js/_enqueues/lib/image-edit.js +++ b/src/js/_enqueues/lib/image-edit.js @@ -5,9 +5,10 @@ * @output wp-admin/js/image-edit.js */ - /* global imageEditL10n, ajaxurl, confirm */ + /* global ajaxurl, confirm */ (function($) { + var __ = wp.i18n.__; /** * Contains all the methods to initialise and control the image editor. @@ -137,28 +138,34 @@ } }); - $( document ).on( 'image-editor-image-loaded', this.focusManager ); + $( document ).on( 'image-editor-ui-ready', this.focusManager ); }, /** * Toggles the wait/load icon in the editor. * * @since 2.9.0 + * @since 5.5.0 Added the triggerUIReady parameter. * * @memberof imageEdit * - * @param {number} postid The post ID. - * @param {number} toggle Is 0 or 1, fades the icon in then 1 and out when 0. + * @param {number} postid The post ID. + * @param {number} toggle Is 0 or 1, fades the icon in when 1 and out when 0. + * @param {boolean} triggerUIReady Whether to trigger a custom event when the UI is ready. Default false. * * @return {void} */ - toggleEditor : function(postid, toggle) { + toggleEditor: function( postid, toggle, triggerUIReady ) { var wait = $('#imgedit-wait-' + postid); if ( toggle ) { wait.fadeIn( 'fast' ); } else { - wait.fadeOut('fast'); + wait.fadeOut( 'fast', function() { + if ( triggerUIReady ) { + $( document ).trigger( 'image-editor-ui-ready' ); + } + } ); } }, @@ -402,10 +409,16 @@ t.toggleEditor(postid, 0); }) - .on('error', function() { - $('#imgedit-crop-' + postid).empty().append('
' + imageEditL10n.error + '
' + errorMessage + '
' + ret.error + '
' + response.data.error + '
' + ret.msg + '
' + response.data.msg + '
' + errorMessage + '
$msg->error
$msg->error
$msg->msg
$msg->msg