]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/media-gallery.js
Wordpress 3.5
[autoinstalls/wordpress.git] / wp-admin / js / media-gallery.js
index 81e51131afbadfe76a8cb6112a6fdbf0774b59a3..38e4f7b481999af4af717af529b79e5574953a05 100644 (file)
@@ -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();
+               }
+       });
+});