File: /home/salamatk/takarzan.ir/wp-content/themes/xts-luman/js/scripts/wishlist.min.js
(a=>{XTSThemeModule.wishlist=function(){if("undefined"!=typeof Cookies){var t="xts_wishlist_count",e=(XTSThemeModule.$body.hasClass("logged-in")&&(t+="_logged"),xts_settings.is_multisite&&(t+="_"+xts_settings.current_blog_id),a(".xts-header-el.xts-header-wishlist, .xts-navbar-wishlist")),t=Cookies.get(t);if(0<e.length)if(void 0!==t)try{var s=JSON.parse(t);e.find(".xts-wishlist-count, .xts-navbar-count").text(s)}catch(t){console.log("cant parse cookies json")}else e.find(".xts-wishlist-count, .xts-navbar-count").text(0);XTSThemeModule.$body.on("click",".xts-wishlist-btn a",function(t){var s=a(this),e=s.data("product-id"),o=s.data("added-text"),i=s.data("key");if(s.hasClass("xts-added"))return!0;t.preventDefault(),s.addClass("xts-loading"),a.ajax({url:xts_settings.ajaxurl,data:{action:"xts_add_to_wishlist",product_id:e,key:i},dataType:"json",method:"GET",success:function(t){t?(s.addClass("xts-added"),XTSThemeModule.$document.trigger("xtsAddedToWishlist"),t.wishlist_content&&n(t),(0<s.find("span").length?s.find("span"):s).text(o),XTSThemeModule.$document.trigger("xtsUpdateTooltip",s.parent())):console.log("something wrong loading wishlist data ",t)},error:function(){console.log("We cant add to wishlist. Something wrong with AJAX response. Probably some PHP conflict.")},complete:function(){s.removeClass("xts-loading")}})}),XTSThemeModule.$body.on("click",".xts-remove-wishlist-btn",function(t){var s=a(this),e=s.data("product-id"),o=s.data("key");if(s.find("a").hasClass("xts-loading"))return!0;t.preventDefault(),s.find("a").addClass("xts-loading"),a.ajax({url:xts_settings.ajaxurl,data:{action:"xts_remove_from_wishlist",product_id:e,key:o},dataType:"json",method:"GET",success:function(t){t.wishlist_content?(n(t),XTSThemeModule.$document.trigger("xtsWishlistRemoveSuccess")):console.log("something wrong loading wishlist data ",t)},error:function(){console.log("We cant remove from wishlist. Something wrong with AJAX response. Probably some PHP conflict.")},complete:function(){s.find("a").removeClass("xts-loading")}})})}function n(t){0<e.length&&e.find(".xts-wishlist-count, .xts-navbar-count").text(t.count);var s=a(".xts-wishlist-content");0<s.length&&!s.hasClass("xts-wishlist-preview")&&s.replaceWith(t.wishlist_content)}},a(document).ready(function(){XTSThemeModule.wishlist()})})(jQuery);