Repository URL to install this package:
|
Version:
1.8.76 ▾
|
jsarnowski/blocksy-companion-pro
/
premium
/
extensions
/
woocommerce-extra
/
static
/
bundle
/
wish-list.js
|
|---|
!function(){"use strict";var t={n:function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},d:function(e,n){for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e=window.ctEvents,n=t.n(e),i=window.ctFrontend;function o(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}var s=function(t,e){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:365;if(i){var o=new Date;o.setTime(o.getTime()+24*i*60*60*1e3),n="; expires="+o.toGMTString()}else n="";document.cookie=t+"="+e+n+"; path=/"},c=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.operation,i=t.productId,r=t.el,c=t.cb,a=void 0===c?function(){}:c,l=ct_localizations.blc_ext_wish_list.list,u=l;if(e){var d=i||Array.from(r.classList).find((function(t){return 0===t.indexOf("post-")})).split("-")[1];"add"===e&&(u=[].concat(o(l),[parseFloat(d)])),"remove"===e&&(u=l.filter((function(t){return parseFloat(t)!==parseFloat(d)}))),"yes"===window.ct_localizations.blc_ext_wish_list.user_logged_in?fetch("".concat(ct_localizations.ajax_url,"?action=blc_ext_wish_list_sync_likes"),{method:"POST",body:JSON.stringify(u),headers:{Accept:"application/json","Content-Type":"application/json"}}).then((function(t){return t.json()})).then((function(t){var e=t.success;t.data,e&&a()})):(s("blc_products_wish_list",JSON.stringify(u)),setTimeout((function(){a()}))),window.ct_localizations.blc_ext_wish_list.list=u,n().trigger("blocksy:woocommerce:wish-list-change",{operation:e,productId:d})}Array.from(document.querySelectorAll('.ct-header-wishlist, [data-id="wishlist"]')).map((function(t){t.classList.remove("ct-added"),t.classList.add("ct-adding"),t.removeAttribute("style"),o(document.querySelectorAll(".ct-dynamic-count-wishlist")).map((function(t){t.innerHTML=u.length,t.dataset.count=u.length})),setTimeout((function(){t.classList.remove("ct-adding"),t.classList.add("ct-added")}))}))},a=!1;(0,i.registerDynamicChunk)("blocksy_ext_woo_extra_wish_list",{mount:function(t,e){var n=e.event;if(!n){if(a)return;return a=!0,void fetch("".concat(ct_localizations.ajax_url,"?action=blc_ext_wish_list_get_all_likes"),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"}}).then((function(t){return t.json()})).then((function(t){t.success;var e=t.data;window.ct_localizations.blc_ext_wish_list={list:e.likes,user_logged_in:e.user_logged_in},c();var n=e.likes;o(document.querySelectorAll('[class*="ct-wishlist-button"], .ct-wishlist-remove, .wishlist-product-remove > .remove, .product-mobile-actions > [href*="wishlist-remove"]')).map((function(t){t.classList.remove("active"),n.indexOf(parseFloat(t.getAttribute("href").replace("#wishlist-add-","")))>-1&&t.classList.add("active")}))}))}n.preventDefault(),n.stopPropagation(),c({productId:t.dataset.id,el:t.closest(".type-product")||t.closest("li"),operation:t.classList.contains("active")||t.classList.contains("remove")?"remove":"add",cb:function(){t.closest(".wishlist-table")&&1===t.closest("tbody").children.length&&location.reload()}}),t.classList.contains("remove")||t.classList.toggle("active"),t.closest(".wishlist-table")&&(1===t.closest("tbody").children.length||t.closest("tr").remove())}})}();