X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8f374b7233bc2815ccc387e448d208c5434eb961..6c8f14c09105d0afa4c1574215c59b5021040e76:/wp-admin/js/media-gallery.js diff --git a/wp-admin/js/media-gallery.js b/wp-admin/js/media-gallery.js index 81e51131..38e4f7b4 100644 --- a/wp-admin/js/media-gallery.js +++ b/wp-admin/js/media-gallery.js @@ -1 +1,25 @@ -jQuery(function(a){a("body").bind("click.wp-gallery",function(d){var c=a(d.target),f,b;if(c.hasClass("wp-set-header")){(window.dialogArguments||opener||parent||top).location.href=c.data("location");d.preventDefault()}else{if(c.hasClass("wp-set-background")){f=c.data("attachment-id");b=a('input[name="attachments['+f+'][image-size]"]:checked').val();jQuery.post(ajaxurl,{action:"set-background-image",attachment_id:f,size:b},function(){var e=window.dialogArguments||opener||parent||top;e.tb_remove();e.location.reload()});d.preventDefault()}}})}); \ No newline at end of file +jQuery(function($){ + $( 'body' ).bind( 'click.wp-gallery', function(e){ + var target = $( e.target ), id, img_size; + + 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(); + + jQuery.post(ajaxurl, { + action: 'set-background-image', + attachment_id: id, + size: img_size + }, function(){ + var win = window.dialogArguments || opener || parent || top; + win.tb_remove(); + win.location.reload(); + }); + + e.preventDefault(); + } + }); +});