wp/wp-admin/js/set-post-thumbnail.js
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 9 177826044cd9
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     1
/* global setPostThumbnailL10n, ajaxurl, post_id, alert */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     2
/* exported WPSetAsThumbnail */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     4
function WPSetAsThumbnail( id, nonce ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
	var $link = jQuery('a#wp-post-thumbnail-' + id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
	$link.text( setPostThumbnailL10n.saving );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
	jQuery.post(ajaxurl, {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     9
		action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
	}, function(str){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
		var win = window.dialogArguments || opener || parent || top;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
		$link.text( setPostThumbnailL10n.setThumbnail );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
		if ( str == '0' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
			alert( setPostThumbnailL10n.error );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
			jQuery('a.wp-post-thumbnail').show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
			$link.text( setPostThumbnailL10n.done );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
			$link.fadeOut( 2000 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
			win.WPSetThumbnailID(id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
			win.WPSetThumbnailHTML(str);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
}