1 /** |
1 /** |
2 * @output wp-admin/js/set-post-thumbnail.js |
2 * @output wp-admin/js/set-post-thumbnail.js |
3 */ |
3 */ |
4 |
4 |
5 /* global setPostThumbnailL10n, ajaxurl, post_id, alert */ |
5 /* global ajaxurl, post_id, alert */ |
6 /* exported WPSetAsThumbnail */ |
6 /* exported WPSetAsThumbnail */ |
7 |
7 |
8 window.WPSetAsThumbnail = function( id, nonce ) { |
8 window.WPSetAsThumbnail = function( id, nonce ) { |
9 var $link = jQuery('a#wp-post-thumbnail-' + id); |
9 var $link = jQuery('a#wp-post-thumbnail-' + id); |
10 |
10 |
11 $link.text( setPostThumbnailL10n.saving ); |
11 $link.text( wp.i18n.__( 'Saving…' ) ); |
12 jQuery.post(ajaxurl, { |
12 jQuery.post(ajaxurl, { |
13 action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie ) |
13 action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie ) |
14 }, function(str){ |
14 }, function(str){ |
15 var win = window.dialogArguments || opener || parent || top; |
15 var win = window.dialogArguments || opener || parent || top; |
16 $link.text( setPostThumbnailL10n.setThumbnail ); |
16 $link.text( wp.i18n.__( 'Use as featured image' ) ); |
17 if ( str == '0' ) { |
17 if ( str == '0' ) { |
18 alert( setPostThumbnailL10n.error ); |
18 alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) ); |
19 } else { |
19 } else { |
20 jQuery('a.wp-post-thumbnail').show(); |
20 jQuery('a.wp-post-thumbnail').show(); |
21 $link.text( setPostThumbnailL10n.done ); |
21 $link.text( wp.i18n.__( 'Done' ) ); |
22 $link.fadeOut( 2000 ); |
22 $link.fadeOut( 2000 ); |
23 win.WPSetThumbnailID(id); |
23 win.WPSetThumbnailID(id); |
24 win.WPSetThumbnailHTML(str); |
24 win.WPSetThumbnailHTML(str); |
25 } |
25 } |
26 } |
26 } |