From 45f7e68d549355c902a9abf6c5ffa21499dce369 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 16 May 2020 17:25:11 +0000 Subject: [PATCH] Media: Expose media grid frame via `wp-media-grid-ready` trigger for easier customization. Props soulseekah. Fixes #50185. Built from https://develop.svn.wordpress.org/trunk@47807 git-svn-id: http://core.svn.wordpress.org/trunk@47583 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/media.js | 5 ++++- wp-admin/js/media.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-admin/js/media.js b/wp-admin/js/media.js index 5bcad08ef6..8b603205f6 100644 --- a/wp-admin/js/media.js +++ b/wp-admin/js/media.js @@ -147,11 +147,14 @@ if ( $mediaGridWrap.length && window.wp && window.wp.media ) { settings = _wpMediaGridSettings; - window.wp.media({ + var frame = window.wp.media({ frame: 'manage', container: $mediaGridWrap, library: settings.queryVars }).open(); + + // Fire a global ready event. + $mediaGridWrap.trigger( 'wp-media-grid-ready', frame ); } // Prevents form submission if no post has been selected. diff --git a/wp-admin/js/media.min.js b/wp-admin/js/media.min.js index 9a078c6a59..e4d448a391 100644 --- a/wp-admin/js/media.min.js +++ b/wp-admin/js/media.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(s){window.findPosts={open:function(n,i){var e=s(".ui-find-overlay");return 0===e.length&&(s("body").append('
'),findPosts.overlay()),e.show(),n&&i&&s("#affected").attr("name",n).val(i),s("#find-posts").show(),s("#find-posts-input").focus().keyup(function(n){27==n.which&&findPosts.close()}),findPosts.send(),!1},close:function(){s("#find-posts-response").empty(),s("#find-posts").hide(),s(".ui-find-overlay").hide()},overlay:function(){s(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var n={ps:s("#find-posts-input").val(),action:"find_posts",_ajax_nonce:s("#_ajax_nonce").val()},i=s(".find-box-search .spinner");i.addClass("is-active"),s.ajax(ajaxurl,{type:"POST",data:n,dataType:"json"}).always(function(){i.removeClass("is-active")}).done(function(n){n.success||s("#find-posts-response").text(attachMediaBoxL10n.error),s("#find-posts-response").html(n.data)}).fail(function(){s("#find-posts-response").text(attachMediaBoxL10n.error)})}},s(document).ready(function(){var n,i=s("#wp-media-grid");i.length&&window.wp&&window.wp.media&&(n=_wpMediaGridSettings,window.wp.media({frame:"manage",container:i,library:n.queryVars}).open()),s("#find-posts-submit").click(function(n){s('#find-posts-response input[type="radio"]:checked').length||n.preventDefault()}),s("#find-posts .find-box-search :input").keypress(function(n){if(13==n.which)return findPosts.send(),!1}),s("#find-posts-search").click(findPosts.send),s("#find-posts-close").click(findPosts.close),s("#doaction, #doaction2").click(function(i){s('select[name^="action"]').each(function(){var n=s(this).val();"attach"===n?(i.preventDefault(),findPosts.open()):"delete"===n&&(showNotice.warn()||i.preventDefault())})}),s(".find-box-inside").on("click","tr",function(){s(this).find(".found-radio input").prop("checked",!0)})})}(jQuery); \ No newline at end of file +!function(s){window.findPosts={open:function(n,i){var e=s(".ui-find-overlay");return 0===e.length&&(s("body").append('
'),findPosts.overlay()),e.show(),n&&i&&s("#affected").attr("name",n).val(i),s("#find-posts").show(),s("#find-posts-input").focus().keyup(function(n){27==n.which&&findPosts.close()}),findPosts.send(),!1},close:function(){s("#find-posts-response").empty(),s("#find-posts").hide(),s(".ui-find-overlay").hide()},overlay:function(){s(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var n={ps:s("#find-posts-input").val(),action:"find_posts",_ajax_nonce:s("#_ajax_nonce").val()},i=s(".find-box-search .spinner");i.addClass("is-active"),s.ajax(ajaxurl,{type:"POST",data:n,dataType:"json"}).always(function(){i.removeClass("is-active")}).done(function(n){n.success||s("#find-posts-response").text(attachMediaBoxL10n.error),s("#find-posts-response").html(n.data)}).fail(function(){s("#find-posts-response").text(attachMediaBoxL10n.error)})}},s(document).ready(function(){var n,i=s("#wp-media-grid");if(i.length&&window.wp&&window.wp.media){n=_wpMediaGridSettings;var e=window.wp.media({frame:"manage",container:i,library:n.queryVars}).open();i.trigger("wp-media-grid-ready",e)}s("#find-posts-submit").click(function(n){s('#find-posts-response input[type="radio"]:checked').length||n.preventDefault()}),s("#find-posts .find-box-search :input").keypress(function(n){if(13==n.which)return findPosts.send(),!1}),s("#find-posts-search").click(findPosts.send),s("#find-posts-close").click(findPosts.close),s("#doaction, #doaction2").click(function(i){s('select[name^="action"]').each(function(){var n=s(this).val();"attach"===n?(i.preventDefault(),findPosts.open()):"delete"===n&&(showNotice.warn()||i.preventDefault())})}),s(".find-box-inside").on("click","tr",function(){s(this).find(".found-radio input").prop("checked",!0)})})}(jQuery); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 6060afd35a..d78f6e38d0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47802'; +$wp_version = '5.5-alpha-47807'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.