~canonical-sysadmins/wordpress/4.7.4

« back to all changes in this revision

Viewing changes to wp-admin/js/set-post-thumbnail.js

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* global setPostThumbnailL10n, ajaxurl, post_id, alert */
 
2
/* exported WPSetAsThumbnail */
 
3
 
 
4
function WPSetAsThumbnail( id, nonce ) {
 
5
        var $link = jQuery('a#wp-post-thumbnail-' + id);
 
6
 
 
7
        $link.text( setPostThumbnailL10n.saving );
 
8
        jQuery.post(ajaxurl, {
 
9
                action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
 
10
        }, function(str){
 
11
                var win = window.dialogArguments || opener || parent || top;
 
12
                $link.text( setPostThumbnailL10n.setThumbnail );
 
13
                if ( str == '0' ) {
 
14
                        alert( setPostThumbnailL10n.error );
 
15
                } else {
 
16
                        jQuery('a.wp-post-thumbnail').show();
 
17
                        $link.text( setPostThumbnailL10n.done );
 
18
                        $link.fadeOut( 2000 );
 
19
                        win.WPSetThumbnailID(id);
 
20
                        win.WPSetThumbnailHTML(str);
 
21
                }
 
22
        }
 
23
        );
 
24
}