author | Anthony Ly <anthonyly.com@gmail.com> |
Mon, 19 Nov 2012 18:26:13 +0100 | |
changeset 194 | 32102edaa81b |
parent 136 | bde1974c263b |
permissions | -rw-r--r-- |
136 | 1 |
jQuery(document).ready( function($) { |
2 |
var before, addBefore, addAfter, delBefore; |
|
3 |
||
4 |
before = function() { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
5 |
var nonce = $('#newmeta [name="_ajax_nonce"]').val(), postId = $('#post_ID').val(); |
136 | 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 |
} ); |