jQuery(document).ready(function(e){"use strict";function i(i){var t=[];e(i).children(".thumb").children("img").each(function(){t.push(e(this).data("img-id"))}),i.siblings(".ci-upload-to-gallery-ids").val(t.join(","))}function t(i){var t=i.children(".ci-upload-to-gallery-ids"),a=i.children(".ci-upload-to-gallery-preview");e.ajax({type:"post",url:blockchain_lite_plugin_PostMeta.ajaxurl,data:{action:"blockchain_lite_plugin_featgal_AJAXPreview",ids:t.val()},dataType:"text",beforeSend:function(){a.empty().html("

"+blockchain_lite_plugin_PostMeta.tLoading+"

")},success:function(i){"FAIL"==i?a.empty().html("

"+blockchain_lite_plugin_PostMeta.tPreviewUnavailable+"

"):(i=e.parseJSON(i),a.empty(),e.each(i,function(i,t){e('
').appendTo(a)}))}})}e(".ci-cf-wrap .blockchain-lite-color-picker").each(function(){e(this).wpColorPicker()}),e(".ci-cf-wrap .blockchain-lite-alpha-color-picker").alphaColorPicker(),e(".ci-cf-wrap").each(function(){if(e(this).find(".ci-cf-section").length>1){var i=e(this),t=i.find(".ci-cf-section");t.not(":first").hide(),e('').prependTo(i),t.each(function(){var t=e(this).find(".ci-cf-title").text(),a=e('
  • ').html(t);e(".ci-cf-tabs",i).append(a)});var a=e(".ci-cf-tab",i);a.first().addClass("ci-cf-tab-active"),a.on("click",function(i){e(this).addClass("ci-cf-tab-active").siblings(".ci-cf-tab").removeClass("ci-cf-tab-active");var t=e(this).index(),a=e(this).parents(".ci-cf-wrap").children(".ci-cf-section").get(t);e(a).show().siblings(".ci-cf-section").hide(),"object"==typeof google&&"object"==typeof google.maps&&e(a).find(".gllpLatlonPicker").length>0&&google.maps.event.trigger(window,"resize",{}),i.preventDefault()})}}),e("body").on("click",".ci-media-button",function(i){i.preventDefault();var t=e(this),a=t.siblings(".ci-uploaded-id"),l=t.siblings(".ci-uploaded-url"),c=t.siblings(".upload-preview"),n=t.data("multi"),o=t.data("frame");void 0===n&&(n=!1),void 0===o&&(o="select");var s=wp.media({frame:o,title:1==n?blockchain_lite_plugin_PostMeta.tSelectFiles:blockchain_lite_plugin_PostMeta.tSelectFile,button:{text:1==n?blockchain_lite_plugin_PostMeta.tUseTheseFiles:blockchain_lite_plugin_PostMeta.tUseThisFile},multiple:n}).on("select",function(){s.state().get("selection").map(function(e){var e=e.toJSON();if(0==n&&(a.length>0&&a.val(e.id).trigger("change"),l.length>0&&l.val(e.url).trigger("change"),c.length>0)){var i='';c.html(i)}})}).open()}),e("body").on("click",".ci-upload-preview a.close",function(i){i.preventDefault(),e(this).parent().html("").siblings(".ci-uploaded-id").val("")}),e("body").on("click",".ci-upload-to-gallery",function(i){i.preventDefault();var a=e(this),l=a.parents(".ci-media-manager-gallery"),c=a.siblings(".ci-upload-to-gallery-ids"),n=(a.siblings("p").find('.ci-upload-to-gallery-random > input[type="checkbox"]'),wp.media({frame:"select",title:blockchain_lite_plugin_PostMeta.tSelectFiles,button:{text:blockchain_lite_plugin_PostMeta.tUseTheseFiles},multiple:!0}).on("select",function(e){var i=n.state().get("selection"),a=c.val(),o=[];a.length>0&&(o=a.split(",")),i.map(function(e){var e=e.toJSON();o.push(e.id)}),c.val(o.join(",")),t(l)}).open())}),e("body").on("click",".ci-media-manager-gallery .thumb a.close",function(t){t.preventDefault();var a=e(this).parent().parent();e(this).parent().remove(),i(a)});var a=e(".ci-upload-to-gallery-preview");a.length>0&&a.sortable({update:function(t,a){i(e(this))}})});