1 /* global ajaxurl, attachMediaBoxL10n */
6 open: function( af_name, af_val ) {
7 var overlay = $( '.ui-find-overlay' );
9 if ( overlay.length === 0 ) {
10 $( 'body' ).append( '<div class="ui-find-overlay"></div>' );
16 if ( af_name && af_val ) {
17 $( '#affected' ).attr( 'name', af_name ).val( af_val );
20 $( '#find-posts' ).show();
22 $('#find-posts-input').focus().keyup( function( event ){
23 if ( event.which == 27 ) {
28 // Pull some results up by default
35 $('#find-posts-response').html('');
36 $('#find-posts').hide();
37 $( '.ui-find-overlay' ).hide();
41 $( '.ui-find-overlay' ).on( 'click', function () {
48 ps: $( '#find-posts-input' ).val(),
50 _ajax_nonce: $('#_ajax_nonce').val()
52 spinner = $( '.find-box-search .spinner' );
60 }).always( function() {
62 }).done( function( x ) {
64 $( '#find-posts-response' ).text( attachMediaBoxL10n.error );
67 $( '#find-posts-response' ).html( x.data );
69 $( '#find-posts-response' ).text( attachMediaBoxL10n.error );
74 $( document ).ready( function() {
75 // Open up a manage media frame into the grid.
76 wp.media && wp.media({
78 container: $('#wpbody-content > .wrap')
81 $( '#find-posts-submit' ).click( function( event ) {
82 if ( ! $( '#find-posts-response input[type="radio"]:checked' ).length )
83 event.preventDefault();
85 $( '#find-posts .find-box-search :input' ).keypress( function( event ) {
86 if ( 13 == event.which ) {
91 $( '#find-posts-search' ).click( findPosts.send );
92 $( '#find-posts-close' ).click( findPosts.close );
93 $( '#doaction, #doaction2' ).click( function( event ) {
94 $( 'select[name^="action"]' ).each( function() {
95 if ( $(this).val() === 'attach' ) {
96 event.preventDefault();
102 // Enable whole row to be clicked
103 $( '.find-box-inside' ).on( 'click', 'tr', function() {
104 $( this ).find( '.found-radio input' ).prop( 'checked', true );