PluginProbe
Qi Blocks / 1.0.7
Qi Blocks v1.0.7
1.5.3 1.5.2 1.5.1 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 All 45 releases
qi-blocks / assets / dist / product-list-script.js

product-list-script.js in Qi Blocks 1.0.7, at assets/dist/product-list-script.js

1 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 !function(){"use strict";var t={n:function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,{a:o}),o},d:function(e,o){for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e=jQuery,o=t.n(e);document.addEventListener("DOMContentLoaded",(function(){n.init()}));const n={init:function(t){this.holder=document.querySelectorAll(".qi-block-product-list"),this.holder.length&&[...this.holder].map((e=>{n.initItem(e,t)}))},getRealCurrentItem:function(t){return"string"==typeof t&&""!==t&&(t=qiBlocksEditor.qodefGetCurrentBlockElement.get(t)),t},initItem:function(t,e){if(!(t=n.getRealCurrentItem(t)))return;const o=t.querySelectorAll(".qi-block-button");o.length&&[...o].map((t=>{n.initButtonAction(t)})),n.initInfoBelowSwap(t,e)},initButtonAction:function(t){const e=t.querySelector(".qodef-m-icon"),i=t.querySelector(".qodef-add-to-cart-button-link");if(e){const o=document.body.classList.contains("wp-admin")?300:0;let n="auto";setTimeout((()=>{t&&t.classList.contains("qodef-type--icon-boxed")?n=parseInt(window.getComputedStyle(t).getPropertyValue("height"),10)+"px":i&&i.classList.contains("qodef-type--icon-boxed")&&(n=parseInt(window.getComputedStyle(i).getPropertyValue("height"),10)+"px"),e.style.width=n}),o)}o()(document.body).on("added_to_cart",(()=>{const e=setInterval((()=>{let o;o=t.classList.contains("add_to_cart_button")?t.nextElementSibling:t.querySelector(".added_to_cart"),o&&(clearInterval(e),n.setViewButtonMarkup(t,o))}),100)}))},setViewButtonMarkup:function(t,e){let o,n=["product_type_simple","add_to_cart_button","ajax_add_to_cart","added"];o=t.classList.contains("add_to_cart_button")?t:t.querySelector(".add_to_cart_button");let i=o.getAttribute("class").split(" ");i.length&&i.forEach((t=>{n.includes(t)||e.classList.add(t)})),e.innerHTML=o.innerHTML,e.querySelector(".qodef-m-text").innerHTML=qiBlocks.vars.viewCartText,e.classList.add("qodef--init")},initInfoBelowSwap:function(t,e){if(t.classList.contains("qodef-item-layout--info-below-swap")){const o=t.querySelectorAll(".qodef-e");o.length&&[...o].map((t=>{let o=t.querySelector(".qodef-e-swap-holder");if(o){let t=0;e&&(t=200,o.style.removeProperty("--qodef-max-width"),o.style.removeProperty("--qodef-max-height")),setTimeout((()=>{let t=o.querySelector(".qodef-woo-product-price"),e=o.querySelector(".qodef-e-to-swap .qi-block-button"),n=e?e.getBoundingClientRect().width:0,i=e?e.getBoundingClientRect().height:0,r=t?t.getBoundingClientRect().width:0,d=t?t.getBoundingClientRect().height:0,c=Math.ceil(Math.max(n,r)),l=Math.ceil(Math.max(i,d))+"px",a=o.parentNode.getBoundingClientRect().width;o.style.setProperty("--qodef-max-width",(a<c?a:c)+"px"),o.style.setProperty("--qodef-max-height",l),o.classList.add("qodef--initialized")}),t)}}))}}}}();