jQuery(document).ready(function(c){"use strict";c(document).on("click","a.compare:not(.added)",function(o){o.preventDefault();var e=c(this),t=c(".yith-woocompare-widget ul.products-list"),a=e.parents(".yith-woocompare-related"),r=!!a.length,i=r?a.data("iframe"):"no",n={action:yith_woocompare.actionadd,id:e.data("product_id"),context:"frontend",is_related:r,iframe:i};"undefined"!=typeof c.fn.block&&(e.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"20px 20px",opacity:.6}}),t.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"20px 20px",opacity:.6}})),c.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionadd),data:n,dataType:r?"html":"json",success:function(o){r?(c("#yith-woocompare").replaceWith(c(o).filter("#yith-woocompare")),d(!1),c(document).trigger("yith_woocompare_page_refreshed",[!1]),e.addClass("added").attr("href","#").text(yith_woocompare.added_label)):(o.added&&e.addClass("added").attr("href",o.table_url).text(yith_woocompare.is_page?yith_woocompare.view_label:yith_woocompare.added_label),d(o.widget_table),"yes"!=yith_woocompare.auto_open||o.only_one||yith_woocompare.is_page||c("body").trigger("yith_woocompare_open_popup",{response:o.table_url,button:e}),c("body").trigger("yith_woocompare_product_added")),p(),"undefined"!=typeof c.fn.block&&(e.unblock(),t.unblock())}})}),yith_woocompare.is_page||c(document).on("click","a.compare.added",function(o){o.preventDefault();var e=this.href;void 0!==e&&c("body").trigger("yith_woocompare_open_popup",{response:e,button:c(this)})}),c("body").on("yith_woocompare_open_popup",function(o,e){var t=e.response;e.button;yith_woocompare.force_showing_popup||768<=c(window).width()?(c.colorbox({href:t,iframe:!0,width:"80%",height:"80%",fixed:!0,className:"yith_woocompare_colorbox",close:yith_woocompare.close_label,onClosed:function(){yith_woocompare.im_in_page?location.reload():(d(!1),p())},onComplete:function(){a(),c.dataTableFunction()}}),c(window).resize(function(){c.colorbox.resize({width:"90%",height:"90%"})})):window.location=yith_woocompare.page_url}),c(document).on("click",".compare-list .remove a, a.yith_woocompare_clear",function(o){o.preventDefault();var i=c(this),n=i.data("product_id"),e={action:yith_woocompare.actionremove,id:n,iframe:i.data("iframe"),context:"frontend"};"undefined"!=typeof c.fn.block&&i.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"20px 20px",opacity:.6}}),c.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionremove),data:e,dataType:"html",success:function(o){var e=c(o).filter("#yith-woocompare");c("#yith-woocompare").replaceWith(e);var t="all"==n?".compare.added":'.compare[data-product_id="'+n+'"]',a=i.data("product_id"),r=yith_woocompare.custom_label_for_compare_button?i.closest("tbody").find("tr"+yith_woocompare.selector_for_custom_label_compare_button).find("td.product_"+a).text():yith_woocompare.button_text;c(t,window.parent.document).removeClass("added").html(r),d(!1),p(),c(document).trigger("yith_woocompare_product_removed",[""])}})}),c(".yith-woocompare-open a, a.yith-woocompare-open").on("click",function(o){yith_woocompare.is_page||(o.preventDefault(),c("body").trigger("yith_woocompare_open_popup",{response:function(o,e){o=escape(o),e=escape(e);var t=document.location.search,a=o+"="+e,r=new RegExp("(&|\\?)"+o+"=[^&]*");t=t.replace(r,"$1"+a),RegExp.$1||(t+=(0<t.length?"&":"?")+a);return t}("action",yith_woocompare.actionview)+"&iframe=1"}))}),c(".yith-woocompare-widget").on("click","a.compare-widget",function(o){yith_woocompare.is_page||(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 e=c(".yith-woocompare-widget .products-list").data("lang"),t=c(this),a=t.data("product_id");void 0===a&&(a=t.attr("href").split("id=")[1]);var r={action:yith_woocompare.actionremove,id:a,context:"frontend",responseType:"product_list",lang:e},i=t.parents(".yith-woocompare-widget").find("ul.products-list");"undefined"!=typeof c.fn.block&&i.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"20px 20px",opacity:.6}}),c.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionremove),data:r,dataType:"html",success:function(o){var t=c("#yith-woocompare");t.length&&c.get(window.location,function(o){var e=c(o).find("#yith-woocompare");t.replaceWith(e),c(document).trigger("yith_woocompare_page_refreshed",[e])}),d(o),p(),"undefined"!=typeof c.fn.block&&i.unblock(),"all"==a?c(".compare.added").removeClass("added").html(yith_woocompare.button_text):c('.compare[data-product_id="'+a+'"]').removeClass("added").html(yith_woocompare.button_text)}})}),c(document).on("click","#yith-woocompare-cat-nav li > a",function(o){o.preventDefault();var e=c(this),t=e.closest("#yith-woocompare"),a=e.data("cat_id"),r=e.closest("#yith-woocompare-cat-nav > ul"),i=r.data("product_ids"),n=r.data("iframe");c.ajax({url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionfilter),data:{action:yith_woocompare.actionfilter,yith_compare_cat:a,yith_compare_prod:i,context:"frontend",iframe:n},dataType:"html",success:function(o){var e=c(o).filter("#yith-woocompare");t.replaceWith(e),c(document).trigger("yith_woocompare_page_refreshed",[e])}})});var a=function(){if("undefined"!=typeof c.fn.owlCarousel){var o=c("#yith-woocompare-related"),e=o.find(".related-products"),t=o.find(".related-slider-nav");if(!o.length)return;e.owlCarousel({autoplay:yith_woocompare.autoplay_related,autoplayHoverPause:!0,loop:!0,margin:15,responsiveClass:!0,responsive:{0:{items:2},480:{items:3},768:{items:yith_woocompare.num_related}}}),t.length&&(t.find(".related-slider-nav-prev").click(function(){e.trigger("prev.owl.carousel")}),t.find(".related-slider-nav-next").click(function(){e.trigger("next.owl.carousel")}))}};function n(o){for(var e=o+"=",t=document.cookie.split(";"),a=0;a<t.length;a++){for(var r=t[a];" "==r.charAt(0);)r=r.substring(1);if(0==r.indexOf(e))return decodeURIComponent(r.substring(e.length,r.length))}return""}function d(o){var e,t,a,r,i=c(".yith-woocomerce-widget-content");i.length&&(e=i.data("lang"),o?i.replaceWith(o):(t={action:yith_woocompare.actionreload,context:"frontend",lang:e},"undefined"!=typeof c.fn.block&&i.block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"20px 20px",opacity:.6}}),c.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionreload),data:t,success:function(o){"undefined"!=typeof c.fn.block&&i.unblock(),i.replaceWith(o)}})),void 0!==(a=i).data("hide")&&(((r=n(yith_woocompare.cookie_name))?JSON.parse(r):"").length?a.closest(".yith-woocompare-widget").show():a.closest(".yith-woocompare-widget").hide()),c(document).trigger("yith_woocompare_widget_updated"))}function p(){var o,e,t,a,r=c(".yith-woocompare-counter");r.length&&(o=r.data("type"),a=r.data("text_o"),t=(e=n(yith_woocompare.cookie_name))?JSON.parse(e).length:0,a=a.replace("{{count}}",t),r.find(".yith-woocompare-count").html("text"===o?a:t)),c(document).trigger("yith_woocompare_counter_updated",t)}a(),c(document).on("yith_woocompare_product_removed yith_woocompare_page_refreshed",a),c.dataTableFunction=function(o){var e,t=o&&o.length?o:c(document).find("#yith-woocompare table.compare-list");t.length&&"undefined"!=typeof c.fn.DataTable&&"undefined"!=typeof c.fn.imagesLoaded&&(t.each(function(){var o=c(this);o.imagesLoaded(function(){e=o.DataTable({info:!1,scrollX:!0,scrollCollapse:!0,paging:!1,ordering:!1,searching:!1,autoWidth:!1,destroy:!0,fixedColumns:{leftColumns:yith_woocompare.fixedcolumns}})})}),c(window).off("orientationchange").on("orientationchange",function(){e.destroy(),c.dataTableFunction(!1)}))},c.dataTableFunction(!1),c(document).on("yith_woocompare_product_removed yith_woocompare_page_refreshed",function(o,e){var t=!!e&&c(e).find("table.compare-list");c.dataTableFunction(t)}),c("body").on("added_to_cart",function(o,e,t,a){c(a).closest("table.compare-list").length&&a.hide()}),d(),p()});