var belly_upload_frame_obj;!function($){jQuery(document).ready(function($){function initWHColorPicker(widget){widget.find(".wh-color-picker").wpColorPicker({change:_.throttle(function(){$(this).trigger("change")},3e3)})}function onFormUpdate(event,widget){initWHColorPicker(widget)}jQuery(document).on("click","input.wh-image-picker",function(event){var $this=$(this);event.preventDefault();var bellyImageObject=wp.media.controller.Library.extend({defaults:_.defaults({id:"belly-state-insert",title:$this.data("uploader_title"),allowLocalEdits:!1,displaySettings:!0,displayUserSettings:!1,multiple:!1,library:wp.media.query({type:"image"})},wp.media.controller.Library.prototype.defaults)});belly_upload_frame_obj=wp.media.frames.belly_upload_frame_obj=wp.media({button:{text:jQuery(this).data("uploader_button_text")},state:"belly-state-insert",states:[new bellyImageObject],multiple:!1}),belly_upload_frame_obj.on("select",function(){var state=belly_upload_frame_obj.state("belly-state-insert"),selection=state.get("selection"),display=state.display(selection.first()).toJSON(),object_attachment=selection.first().toJSON();display=wp.media.string.props(display,object_attachment);var image_field=$this.siblings(".image-field-hidden"),image_url=display.src;image_field.val(image_url),image_field.trigger("change");var image_preview_wrap=$this.siblings(".field-image-preview"),image_html='';image_preview_wrap.html(image_html);var btn_remove_image=$this.siblings(".btn-image-remove");btn_remove_image.css("display","inline-block")}),belly_upload_frame_obj.open()}),jQuery(document).on("click","input.btn-image-remove",function(e){e.preventDefault();var $this=$(this),image_field=$this.siblings(".image-field-hidden");image_field.val("");var image_preview_wrap=$this.siblings(".field-image-preview");image_preview_wrap.html(""),$this.css("display","none"),image_field.trigger("change")}),$(document).on("widget-added widget-updated",onFormUpdate),$(document).ready(function(){$("#widgets-right .widget:has(.wh-color-picker)").each(function(){initWHColorPicker($(this))})})})}(jQuery);