WordPress/wp-admin/js/media.min.js

1 line
1.8 KiB
JavaScript
Raw Normal View History

var findPosts;!function(o){findPosts={open:function(n,i){var s=o(".ui-find-overlay");return 0===s.length&&(o("body").append('<div class="ui-find-overlay"></div>'),findPosts.overlay()),s.show(),n&&i&&o("#affected").attr("name",n).val(i),o("#find-posts").show(),o("#find-posts-input").focus().keyup(function(n){27==n.which&&findPosts.close()}),findPosts.send(),!1},close:function(){o("#find-posts-response").empty(),o("#find-posts").hide(),o(".ui-find-overlay").hide()},overlay:function(){o(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var n={ps:o("#find-posts-input").val(),action:"find_posts",_ajax_nonce:o("#_ajax_nonce").val()},i=o(".find-box-search .spinner");i.addClass("is-active"),o.ajax(ajaxurl,{type:"POST",data:n,dataType:"json"}).always(function(){i.removeClass("is-active")}).done(function(n){n.success||o("#find-posts-response").text(attachMediaBoxL10n.error),o("#find-posts-response").html(n.data)}).fail(function(){o("#find-posts-response").text(attachMediaBoxL10n.error)})}},o(document).ready(function(){var n,i=o("#wp-media-grid");i.length&&window.wp&&window.wp.media&&(n=_wpMediaGridSettings,window.wp.media({frame:"manage",container:i,library:n.queryVars}).open()),o("#find-posts-submit").click(function(n){o('#find-posts-response input[type="radio"]:checked').length||n.preventDefault()}),o("#find-posts .find-box-search :input").keypress(function(n){if(13==n.which)return findPosts.send(),!1}),o("#find-posts-search").click(findPosts.send),o("#find-posts-close").click(findPosts.close),o("#doaction, #doaction2").click(function(n){o('select[name^="action"]').each(function(){"attach"===o(this).val()&&(n.preventDefault(),findPosts.open())})}),o(".find-box-inside").on("click","tr",function(){o(this).find(".found-radio input").prop("checked",!0)})})}(jQuery);