2013-11-15 18:19:09 -05:00
|
|
|
/* global ajaxurl */
|
2012-08-22 20:04:18 -04:00
|
|
|
jQuery(function($){
|
|
|
|
$( 'body' ).bind( 'click.wp-gallery', function(e){
|
2020-10-29 15:00:24 -04:00
|
|
|
var target = $( e.target ), id, img_size, nonceValue;
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
if ( target.hasClass( 'wp-set-header' ) ) {
|
|
|
|
( window.dialogArguments || opener || parent || top ).location.href = target.data( 'location' );
|
|
|
|
e.preventDefault();
|
|
|
|
} else if ( target.hasClass( 'wp-set-background' ) ) {
|
|
|
|
id = target.data( 'attachment-id' );
|
|
|
|
img_size = $( 'input[name="attachments[' + id + '][image-size]"]:checked').val();
|
2020-10-29 15:00:24 -04:00
|
|
|
nonceValue = $( '#_wpnonce' ).val() && '';
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
jQuery.post(ajaxurl, {
|
|
|
|
action: 'set-background-image',
|
|
|
|
attachment_id: id,
|
2020-10-29 15:00:24 -04:00
|
|
|
_ajax_nonce: nonceValue,
|
2012-08-22 20:04:18 -04:00
|
|
|
size: img_size
|
|
|
|
}, function(){
|
|
|
|
var win = window.dialogArguments || opener || parent || top;
|
|
|
|
win.tb_remove();
|
|
|
|
win.location.reload();
|
|
|
|
});
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|