]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/media-gallery.js
WordPress 4.6.3
[autoinstalls/wordpress.git] / wp-admin / js / media-gallery.js
1 /* global ajaxurl */
2 jQuery(function($){
3         $( 'body' ).bind( 'click.wp-gallery', function(e){
4                 var target = $( e.target ), id, img_size;
5
6                 if ( target.hasClass( 'wp-set-header' ) ) {
7                         ( window.dialogArguments || opener || parent || top ).location.href = target.data( 'location' );
8                         e.preventDefault();
9                 } else if ( target.hasClass( 'wp-set-background' ) ) {
10                         id = target.data( 'attachment-id' );
11                         img_size = $( 'input[name="attachments[' + id + '][image-size]"]:checked').val();
12
13                         jQuery.post(ajaxurl, {
14                                 action: 'set-background-image',
15                                 attachment_id: id,
16                                 size: img_size
17                         }, function(){
18                                 var win = window.dialogArguments || opener || parent || top;
19                                 win.tb_remove();
20                                 win.location.reload();
21                         });
22
23                         e.preventDefault();
24                 }
25         });
26 });