!function($){"use strict";$(document).ready(function(){$("#gallery-upload-button").click(function(e){var t=$(this).parent().parent(),a=$(this);e.preventDefault();var l=wp.media({title:a.data("upload-title"),button:{text:a.data("upload-button")},editing:!0,type:"image",multiple:"add"}).on("select",function(){var e=l.state().get("selection"),a=e.toJSON(),i="";$(".images .attachment-thumbnail",t).each(function(e){$(this).remove()}),$.each(a,function(e,a){$(".images",t).append('<img src="'+a.sizes.thumbnail.url+'" class="attachment-thumbnail">'),i+=a.id+","}),$("#curly_galleries",t).val(i).trigger("change"),t.hasClass("upload_file")||($("img",t).length>0?$(".image-preview",t).attr("src",a.url):($('<img src="'+a.url+'" class="image-preview">').insertBefore($(":last-child",t)),$(".image-clear-button",t).attr("style","display:inline-block")))}).open()}),$("#gallery-clear-button").click(function(e){e.preventDefault(),$("#curly_galleries").val(""),$("#gallery-images").children().remove()})})}(jQuery);