!function(a){a(document).ready(function(){function b(){a(".fac-agp-color-picker").wpColorPicker({defaultColor:!1,change:function(a,b){d()},clear:function(){d()},palettes:!0}),a(".fac-element").change(function(a){d()})}function c(){d();var b="action=getPreview&nonce="+ajax_fac.ajax_nonce;b=b+"&"+a("#fac-constructor-params").serialize();var c=a(".fac-constructor-preview-container");e(),a.ajax({url:ajax_fac.ajax_url,type:"POST",data:b,dataType:"json",cache:!1,success:function(b){a(c).html(b.preview),f(),g()},error:function(a,b,c){f()}})}function d(){a(".fac-constructor-preview-container").html(""),g()}function e(){a(".fac-constructor-spinner").css("visibility","visible"),g()}function f(){a(".fac-constructor-spinner").css("visibility","hidden"),g()}function g(){a.colorbox.resize(),a(".fac-constructor-field .iris-picker").css("position","absolute"),a("#colorbox, #cboxOverlay, #cboxWrapper").css("overflow","visible")}b(),a(".widgets-sortables .fac-promotion-text-color").wpColorPicker(),a(".widgets-sortables .fac-promotion-background-color").wpColorPicker(),a(".fac-constructor-type-select").val(0),/Android|iPhone|iPad|iPod|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?a("#fac-constructor-box").colorbox({inline:!0,width:"96%"}):a("#fac-constructor-box").colorbox({inline:!0,width:"50%"}),a(".fac-constructor-preview-button").click(function(a){c()}),a(".fac-constructor-type-select").change(function(c){d();var h={},i=a(this).closest("#cboxContent");h.action="getElementParameters",h.nonce=ajax_fac.ajax_nonce,h.key=a(this).val(),e(),a.ajax({url:ajax_fac.ajax_url,type:"POST",data:h,dataType:"json",cache:!1,success:function(c){var d="";c.content&&(d=a(c.content).find(".fac-constructor-params").html()),a(i).find(".fac-constructor-params").html(d),b(),f(),a(".fac-constructor-preview-container").html(c.preview),g(),a("a.fac-hint").hover(function(){var b=a(this).parent().find("p.fac-note");b.show();var c=a(this).offset().left-b.outerWidth(),d=a(this).offset().top+a(this).outerHeight();b.offset({top:d,left:c})},function(){var b=a(this).parent().find("p.fac-note");b.hide()})},error:function(a,b,c){f()}})})})}(jQuery);