'use strict';(function(d,k,h){const g=function(){this.form=h.getElementById("tb_admin_new_gs");this.loadAddNewForm();this.addNew();this.deleteStyle();this.restore();this.scalePreview()},e=themifyGlobalStylesVars;g.prototype.addNew=function(){const a=h.getElementsByClassName("tb_admin_save_gs")[0],b=this;a&&a.addEventListener("click",function(c){c.preventDefault();b.validateForm()?(c.target.text=e.messages.creating,d.ajax({type:"POST",url:e.ajaxurl,dataType:"json",data:{action:"tb_save_custom_global_style",
nonce:e.nonce,form_data:d(b.form).serialize()},success(f){"failed"===f.status?(alert(f.msg),c.target.text=e.messages.create):"success"===f.status?k.location=f.url:c.target.text=e.messages.create}})):alert(e.messages.formValid)})};g.prototype.validateForm=function(){let a=!0;d.each(d(this.form).serializeArray(),function(b,c){if(""==c.value)return a=!1});return a};g.prototype.loadAddNewForm=function(){const a=d(".tb_add_new_gs");0!==a.length&&a.magnificPopup({type:"inline",midClick:!0,callbacks:{close(){h.getElementById("tb_admin_new_gs").reset()}}})};
g.prototype.deleteStyle=function(){const a=d(".tb_remove_gs");if(0!==a.length)a.on("click",function(b){b.preventDefault();const c=d(this);b=c.parents(".tb_admin_gs_list").data("list");confirm("publish"===b?themifyGlobalStylesVars.messages.deleteConfirm:themifyGlobalStylesVars.messages.deleteConfirm2)&&(c.parents(".tb_gs_element").fadeOut(),d.ajax({type:"POST",url:e.ajaxurl,dataType:"json",data:{action:"tb_delete_global_style",nonce:e.nonce,status:b,id:c.attr("data-id")},success(f){"failed"===f.status&&
(alert(f.msg),c.parents(".tb_gs_element").fadeIn())}}))})};g.prototype.restore=function(){const a=d(".tb_gs_restore");if(0!==a.length)a.on("click",function(b){b.preventDefault();const c=d(this);c.parents(".tb_gs_element").fadeOut();d.ajax({type:"POST",url:e.ajaxurl,dataType:"json",data:{action:"tb_restore_global_style",nonce:e.nonce,id:c.attr("data-id")},success(f){"failed"===f.status&&(alert(f.msg),c.parents(".tb_gs_element").fadeIn())}})})};g.prototype.scalePreview=function(){d(".themify_builder_content").each(function(){let a=
d(this);var b=a.parent();b=Math.min(b.width()/a.outerWidth(),b.height()/a.outerHeight());a.css({transform:"translate(-50%, -50%) scale("+b+")"})})};new g})(jQuery,window,document);
