]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/custom-fields.js
Wordpress 3.5
[autoinstalls/wordpress.git] / wp-admin / js / custom-fields.js
index dbe2f4816e0f8c60ac87a4b45876435c719fc661..9eab214553ddacb770d4465c02a4273b19810da9 100644 (file)
@@ -1 +1,34 @@
-jQuery(document).ready(function(d){var c,b,e,a;c=function(){var g=d('#newmeta [name="_ajax_nonce"]').val(),f=d("#post_ID").val();if(!g||!f){return false}return[g,f]};b=function(g){var f=c();if(!f){return false}g.data=g.data.replace(/_ajax_nonce=[a-f0-9]+/,"_ajax_nonce="+f[0])+"&post_id="+f[1];return g};e=function(j,i){var f=d("postid",j).text(),g;if(!f){return}d("#post_ID").attr("name","post_ID").val(f);g=d("#hiddenaction");if("post"==g.val()){g.val("postajaxpost")}};a=function(g){var f=c();if(!f){return false}g.data._ajax_nonce=f[0];g.data.post_id=f[1];return g};d("#the-list").wpList({addBefore:b,addAfter:e,delBefore:a}).find(".updatemeta, .deletemeta").attr("type","button")});
\ No newline at end of file
+jQuery(document).ready( function($) {
+       var before, addBefore, addAfter, delBefore;
+
+       before = function() {
+               var nonce = $('#newmeta [name="_ajax_nonce"]').val(), postId = $('#post_ID').val();
+               if ( !nonce || !postId ) { return false; }
+               return [nonce,postId];
+       }
+
+       addBefore = function( s ) {
+               var b = before();
+               if ( !b ) { return false; }
+               s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1];
+               return s;
+       };
+
+       addAfter = function( r, s ) {
+               var postId = $('postid', r).text(), h;
+               if ( !postId ) { return; }
+               $('#post_ID').attr( 'name', 'post_ID' ).val( postId );
+               h = $('#hiddenaction');
+               if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); }
+       };
+
+       delBefore = function( s ) {
+               var b = before(); if ( !b ) return false;
+               s.data._ajax_nonce = b[0]; s.data.post_id = b[1];
+               return s;
+       }
+
+       $('#the-list')
+               .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } )
+               .find('.updatemeta, .deletemeta').attr( 'type', 'button' );
+} );