accordion.js
2 months ago
add-to-cart.js
2 months ago
animated-heading.js
2 months ago
block-animations.js
2 months ago
carousel.js
2 months ago
count-animations.js
2 months ago
countdown.js
2 months ago
form.js
2 months ago
popup.js
2 months ago
progress-bar.js
2 months ago
reveal-button.js
2 months ago
sticky.js
2 months ago
table-of-contents-smooth-scroll.js
2 months ago
typing-animations.js
2 months ago
carousel.js
1 lines
| 1 | (()=>{"use strict";const e="_superbCarouselGoTo",t="_superbCarouselCurrentIndex",s="_superbCarouselSlidesPerView",r=wp.i18n.__,o=wp.i18n.sprintf;function i(i){const n=i.querySelector(".superb-carousel-track"),a=i.querySelectorAll(".superb-carousel-slide"),u=i.querySelector(".superb-carousel-dots"),l=i.querySelector(".superb-carousel-prev"),c=i.querySelector(".superb-carousel-next");if(!n||!a.length)return;const d=a.length;let b=!1;const f="true"===i.getAttribute("data-adaptive-height");function h(e,t){if(!f)return;const s=a[e]?a[e].offsetHeight:0;n.style.transition=t?"none":"transform 0.4s ease, height 0.4s ease",n.style.height=s+"px",t&&(n.offsetHeight,n.style.transition="transform 0.4s ease, height 0.4s ease")}function p(){const e=i[t],r=i[s],o=Math.max(0,d-r);l&&(0===e?(l.setAttribute("disabled",""),l.setAttribute("aria-disabled","true")):(l.removeAttribute("disabled"),l.setAttribute("aria-disabled","false"))),c&&(e>=o?(c.setAttribute("disabled",""),c.setAttribute("aria-disabled","true")):(c.removeAttribute("disabled"),c.setAttribute("aria-disabled","false")))}function A(){if(!u)return;u.replaceChildren();const t=i[s],n=Math.ceil(d/t);for(let t=0;t<n;t++){const n=document.createElement("button");n.className="superb-carousel-dot",n.setAttribute("role","tab"),n.setAttribute("type","button"),n.setAttribute("aria-label",o(r("Go to slide %d","superb-blocks"),t+1)),n.setAttribute("aria-selected",0===t?"true":"false"),function(t){n.addEventListener("click",(function(){i[e](t*i[s])}))}(t),u.appendChild(n)}g()}function g(){if(!u)return;const e=i[s],r=u.querySelectorAll(".superb-carousel-dot"),o=Math.floor(i[t]/e);for(let e=0;e<r.length;e++){const t=e===o;t?r[e].classList.add("superb-carousel-dot-active"):r[e].classList.remove("superb-carousel-dot-active"),r[e].setAttribute("aria-selected",t?"true":"false")}}function m(e,a){if(b)return;const u=Math.max(0,d-i[s]);e<0&&(e=0),e>u&&(e=u),i[t]=e,n.style.transition=a?"none":f?"transform 0.4s ease, height 0.4s ease":"transform 0.4s ease";const l=-e*(100/i[s]);n.style.transform="translateX("+l+"%)",h(e,a),g(),p(),i.setAttribute("aria-label",o(r("Carousel, slide %1$d of %2$d","superb-blocks"),e+1,d)),b=!0,setTimeout((function(){b=!1,a&&(n.style.transition=f?"transform 0.4s ease, height 0.4s ease":"transform 0.4s ease")}),450)}f&&(n.style.alignItems="flex-start"),i._superbCarouselUpdateHeight=function(e){h(i[t],!e)},i[s]=1,i[t]=0,i._superbCarouselBuildDots=A,i[e]=m;let v=0,y=0,k=!1;n.addEventListener("touchstart",(function(e){v=e.touches[0].clientX,y=e.touches[0].clientY,k=!0}),{passive:!0}),n.addEventListener("touchend",(function(r){if(!k)return;k=!1;const o=r.changedTouches[0].clientX-v,n=r.changedTouches[0].clientY-y;if(Math.abs(o)>=30&&Math.abs(o)>Math.abs(n)){const r=i[s];o<0?i[e](i[t]+r):i[e](i[t]-r)}}),{passive:!0}),i.addEventListener("keydown",(function(r){const o=i[s];"ArrowLeft"===r.key?(r.preventDefault(),i[e](i[t]-o)):"ArrowRight"===r.key&&(r.preventDefault(),i[e](i[t]+o))})),l&&l.addEventListener("click",(function(){const r=i[s];i[e](i[t]-r)})),c&&c.addEventListener("click",(function(){const r=i[s];i[e](i[t]+r)})),i.setAttribute("role","region"),i.setAttribute("aria-roledescription","carousel"),i.setAttribute("aria-label",o(r("Carousel, slide %1$d of %2$d","superb-blocks"),1,d));for(let e=0;e<a.length;e++)a[e].setAttribute("role","group"),a[e].setAttribute("aria-roledescription","slide"),a[e].setAttribute("aria-label",o(r("Slide %1$d of %2$d","superb-blocks"),e+1,d));if(A(),p(),m(0,!0),f){let e;new ResizeObserver((function(){clearTimeout(e),e=setTimeout((function(){h(i[t],!0)}),100)})).observe(i)}}document.addEventListener("DOMContentLoaded",(function(){const e=document.querySelectorAll(".wp-block-superb-addons-carousel");for(let t=0;t<e.length;t++)i(e[t])}))})(); |