jQuery(document).ready(function(c){if(c(document.body).hasClass("elementor-editor-active"))return!1;c(document).on("click",".product a.compare:not(.added)",function(o){o.preventDefault();var e=c(this),o={action:yith_woocompare.actionadd,id:e.data("product_id"),context:"frontend"},t=c(".yith-woocompare-widget ul.products-list");"undefined"!=typeof c.fn.block&&(e.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}}),t.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}})),c.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionadd),data:o,dataType:"json",success:function(o){"undefined"!=typeof c.fn.block&&(e.unblock(),t.unblock()),e.addClass("added").attr("href",o.table_url).text(yith_woocompare.added_label),t.html(o.widget_table),"yes"==yith_woocompare.auto_open&&c("body").trigger("yith_woocompare_open_popup",{response:o.table_url,button:e})}})}),c(document).on("click",".product a.compare.added",function(o){o.preventDefault();o=this.href;void 0!==o&&c("body").trigger("yith_woocompare_open_popup",{response:o,button:c(this)})}),c("body").on("yith_woocompare_open_popup",function(o,e){e=e.response;if(768<=c(window).width())c.colorbox({href:e,iframe:!0,width:"90%",height:"90%",className:"yith_woocompare_colorbox",close:yith_woocompare.close_label,onClosed:function(){var e=c(".yith-woocompare-widget ul.products-list"),o={action:yith_woocompare.actionreload,context:"frontend"};"undefined"!=typeof c.fn.block&&e.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}}),c.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionreload),data:o,success:function(o){"undefined"!=typeof c.fn.block&&e.unblock().html(o),e.html(o)}})}}),c(window).resize(function(){c.colorbox.resize({width:"90%",height:"90%"})});else{var t=e.split("?");if(2<=t.length){for(var a=encodeURIComponent("iframe")+"=",r=t[1].split(/[&;]/g),n=r.length;0<n--;)-1!==r[n].lastIndexOf(a,0)&&r.splice(n,1);e=t[0]+"?"+r.join("&")}window.open(e,yith_woocompare.table_title)}}),c(document).on("click",".remove a",function(o){o.preventDefault();var e=c(this),o={action:yith_woocompare.actionremove,id:e.data("product_id"),context:"frontend"};c("td.product_"+o.id+", th.product_"+o.id);"undefined"!=typeof c.fn.block&&e.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}}),c.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionremove),data:o,dataType:"html",success:function(o){o=c(o).filter("#yith-woocompare");c("#yith-woocompare").replaceWith(o),c('.compare[data-product_id="'+e.data("product_id")+'"]',window.parent.document).removeClass("added").html(yith_woocompare.button_text),c(document).trigger("yith_woocompare_product_removed")}})}),c(".yith-woocompare-open a, a.yith-woocompare-open").on("click",function(o){o.preventDefault(),c("body").trigger("yith_woocompare_open_popup",{response:function(o,e){o=escape(o),e=escape(e);var t=document.location.search,e=o+"="+e,o=new RegExp("(&|\\?)"+o+"=[^&]*");t=t.replace(o,"$1"+e),RegExp.$1||(t+=(0<t.length?"&":"?")+e);return t}("action",yith_woocompare.actionview)+"&iframe=true"})}),c(".yith-woocompare-widget").on("click","a.compare",function(o){o.preventDefault(),c("body").trigger("yith_woocompare_open_popup",{response:c(this).attr("href")})}).on("click","li a.remove, a.clear-all",function(o){o.preventDefault();var o=c(".yith-woocompare-widget .products-list").data("lang"),e=c(this),t=e.data("product_id"),o={action:yith_woocompare.actionremove,id:t,context:"frontend",responseType:"product_list",lang:o},a=e.parents(".yith-woocompare-widget").find("ul.products-list");"undefined"!=typeof c.fn.block&&a.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}}),c.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionremove),data:o,dataType:"html",success:function(o){c("all"==t?".compare.added":'.compare[data-product_id="'+t+'"]').removeClass("added").html(yith_woocompare.button_text),a.html(o),"undefined"!=typeof c.fn.block&&a.unblock()}})}),c("body").on("added_to_cart",function(o,e,t,a){c(a).closest("table.compare-list").length&&a.hide()})});