1 /* global ajaxurl, wpAjax */
6 open : function(af_name, af_val) {
7 var st = document.documentElement.scrollTop || $(document).scrollTop(),
8 overlay = $( '.ui-find-overlay' );
10 if ( overlay.length === 0 ) {
11 $( 'body' ).append( '<div class="ui-find-overlay"></div>' );
17 if ( af_name && af_val ) {
18 $('#affected').attr('name', af_name).val(af_val);
20 $('#find-posts').show().draggable({
21 handle: '#find-posts-head'
22 }).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-328px'});
24 $('#find-posts-input').focus().keyup(function(e){
25 if (e.which == 27) { findPosts.close(); } // close on Escape
28 // Pull some results up by default
35 $('#find-posts-response').html('');
36 $('#find-posts').draggable('destroy').hide();
37 $( '.ui-find-overlay' ).hide();
40 overlay : function() {
41 $( '.ui-find-overlay' ).css(
42 { 'z-index': '999', 'width': $( document ).width() + 'px', 'height': $( document ).height() + 'px' }
43 ).on('click', function () {
50 ps: $('#find-posts-input').val(),
52 _ajax_nonce: $('#_ajax_nonce').val()
54 spinner = $( '.find-box-search .spinner' );
62 success : function(x) { findPosts.show(x); spinner.hide(); },
63 error : function(r) { findPosts.error(r); spinner.hide(); }
69 if ( typeof(x) == 'string' ) {
70 this.error({'responseText': x});
74 var r = wpAjax.parseAjaxResponse(x);
77 this.error({'responseText': wpAjax.broken});
80 $('#find-posts-response').html(r.data);
82 // Enable whole row to be clicked
83 $( '.found-posts td' ).on( 'click', function () {
84 $( this ).parent().find( '.found-radio input' ).prop( 'checked', true );
89 var er = r.statusText;
91 if ( r.responseText ) {
92 er = r.responseText.replace( /<.[^<>]*?>/g, '' );
95 $('#find-posts-response').html(er);
100 $(document).ready(function() {
101 $('#find-posts-submit').click(function(e) {
102 if ( '' === $('#find-posts-response').html() )
105 $( '#find-posts .find-box-search :input' ).keypress( function( event ) {
106 if ( 13 == event.which ) {
111 $( '#find-posts-search' ).click( findPosts.send );
112 $( '#find-posts-close' ).click( findPosts.close );
113 $('#doaction, #doaction2').click(function(e){
114 $('select[name^="action"]').each(function(){
115 if ( $(this).val() == 'attach' ) {
122 $(window).resize(function() {