[ Root ] [ Search ] [ Index ]

PHP Cross Reference of WordPress 3.0.1

Provided by Yoast

title

Body

[close]

/wp-admin/js/ -> media.dev.js (source)

   1  
   2  var findPosts;
   3  (function($){
   4      findPosts = {
   5          open : function(af_name, af_val) {
   6              var st = document.documentElement.scrollTop || $(document).scrollTop();
   7  
   8              if ( af_name && af_val ) {
   9                  $('#affected').attr('name', af_name).val(af_val);
  10              }
  11              $('#find-posts').show().draggable({
  12                  handle: '#find-posts-head'
  13              }).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-250px'});
  14  
  15              $('#find-posts-input').focus().keyup(function(e){
  16                  if (e.which == 27) { findPosts.close(); } // close on Escape
  17              });
  18  
  19              return false;
  20          },
  21  
  22          close : function() {
  23              $('#find-posts-response').html('');
  24              $('#find-posts').draggable('destroy').hide();
  25          },
  26  
  27          send : function() {
  28              var post = {
  29                  ps: $('#find-posts-input').val(),
  30                  action: 'find_posts',
  31                  _ajax_nonce: $('#_ajax_nonce').val()
  32              };
  33  
  34              var selectedItem;
  35              $("input[@name='itemSelect[]']:checked").each(function() { selectedItem = $(this).val() });
  36              post['post_type'] = selectedItem;
  37  
  38              $.ajax({
  39                  type : 'POST',
  40                  url : ajaxurl,
  41                  data : post,
  42                  success : function(x) { findPosts.show(x); },
  43                  error : function(r) { findPosts.error(r); }
  44              });
  45          },
  46  
  47          show : function(x) {
  48  
  49              if ( typeof(x) == 'string' ) {
  50                  this.error({'responseText': x});
  51                  return;
  52              }
  53  
  54              var r = wpAjax.parseAjaxResponse(x);
  55  
  56              if ( r.errors ) {
  57                  this.error({'responseText': wpAjax.broken});
  58              }
  59              r = r.responses[0];
  60              $('#find-posts-response').html(r.data);
  61          },
  62  
  63          error : function(r) {
  64              var er = r.statusText;
  65  
  66              if ( r.responseText ) {
  67                  er = r.responseText.replace( /<.[^<>]*?>/g, '' );
  68              }
  69              if ( er ) {
  70                  $('#find-posts-response').html(er);
  71              }
  72          }
  73      };
  74  
  75      $(document).ready(function() {
  76          $('#find-posts-submit').click(function(e) {
  77              if ( '' == $('#find-posts-response').html() )
  78                  e.preventDefault();
  79          });
  80          $('#doaction, #doaction2').click(function(e){
  81              $('select[name^="action"]').each(function(){
  82                  if ( $(this).val() == 'attach' ) {
  83                      e.preventDefault();
  84                      findPosts.open();
  85                  }
  86              });
  87          });
  88      });
  89  })(jQuery);


Generated: Thu Oct 14 05:12:05 2010 Cross-referenced by PHPXref 0.7