]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/custom-fields.dev.js
Wordpress 2.9-scripts
[autoinstalls/wordpress.git] / wp-admin / js / custom-fields.dev.js
1 jQuery(document).ready( function($) {
2         var before, addBefore, addAfter, delBefore;
3
4         before = function() {
5                 var nonce = $('#newmeta [name=_ajax_nonce]').val(), postId = $('#post_ID').val();
6                 if ( !nonce || !postId ) { return false; }
7                 return [nonce,postId];
8         }
9
10         addBefore = function( s ) {
11                 var b = before();
12                 if ( !b ) { return false; }
13                 s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1];
14                 return s;
15         };
16
17         addAfter = function( r, s ) {
18                 var postId = $('postid', r).text(), h;
19                 if ( !postId ) { return; }
20                 $('#post_ID').attr( 'name', 'post_ID' ).val( postId );
21                 h = $('#hiddenaction');
22                 if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); }
23         };
24
25         delBefore = function( s ) {
26                 var b = before(); if ( !b ) return false;
27                 s.data._ajax_nonce = b[0]; s.data.post_id = b[1];
28                 return s;
29         }
30
31         $('#the-list')
32                 .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } )
33                 .find('.updatemeta, .deletemeta').attr( 'type', 'button' );
34 } );