| 1 |
function MultiPostThumbnailsSetThumbnailHTML(html, id, post_type){ |
| 2 |
jQuery('.inside', '#' + post_type + '-' + id).html(html); |
| 3 |
}; |
| 4 |
|
| 5 |
function MultiPostThumbnailsSetThumbnailID(thumb_id, id, post_type){ |
| 6 |
var field = jQuery('input[value=_' + post_type + '_' + id + '_thumbnail_id]', '#list-table'); |
| 7 |
if ( field.size() > 0 ) { |
| 8 |
jQuery('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(thumb_id); |
| 9 |
} |
| 10 |
}; |
| 11 |
|
| 12 |
function MultiPostThumbnailsRemoveThumbnail(id, post_type, nonce){ |
| 13 |
jQuery.post(ajaxurl, { |
| 14 |
action:'set-' + post_type + '-' + id + '-thumbnail', post_id: jQuery('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie) |
| 15 |
}, function(str){ |
| 16 |
if ( str == '0' ) { |
| 17 |
alert( setPostThumbnailL10n.error ); |
| 18 |
} else { |
| 19 |
MultiPostThumbnailsSetThumbnailHTML(str, id, post_type); |
| 20 |
} |
| 21 |
} |
| 22 |
); |
| 23 |
}; |
| 24 |
|
| 25 |
|
| 26 |
function MultiPostThumbnailsSetAsThumbnail(thumb_id, id, post_type, nonce){ |
| 27 |
var $link = jQuery('a#' + post_type + '-' + id + '-thumbnail-' + thumb_id); |
| 28 |
|
| 29 |
$link.text( setPostThumbnailL10n.saving ); |
| 30 |
jQuery.post(ajaxurl, { |
| 31 |
action:'set-' + post_type + '-' + id + '-thumbnail', post_id: post_id, thumbnail_id: thumb_id, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie) |
| 32 |
}, function(str){ |
| 33 |
var win = window.dialogArguments || opener || parent || top; |
| 34 |
$link.text( setPostThumbnailL10n.setThumbnail ); |
| 35 |
if ( str == '0' ) { |
| 36 |
alert( setPostThumbnailL10n.error ); |
| 37 |
} else { |
| 38 |
$link.show(); |
| 39 |
$link.text( setPostThumbnailL10n.done ); |
| 40 |
$link.fadeOut( 2000, function() { |
| 41 |
jQuery('tr.' + post_type + '-' + id + '-thumbnail').hide(); |
| 42 |
}); |
| 43 |
win.MultiPostThumbnailsSetThumbnailID(thumb_id, id, post_type); |
| 44 |
win.MultiPostThumbnailsSetThumbnailHTML(str, id, post_type); |
| 45 |
} |
| 46 |
} |
| 47 |
); |
| 48 |
} |