web/wp-admin/js/media-gallery.js
changeset 204 09a1c134465b
parent 194 32102edaa81b
--- a/web/wp-admin/js/media-gallery.js	Wed Dec 19 12:35:13 2012 -0800
+++ b/web/wp-admin/js/media-gallery.js	Wed Dec 19 17:46:52 2012 -0800
@@ -1,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();
+		}
+	});
+});