PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 3.2.0
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v3.2.0
3.2.0 3.1.0 3.0.0 2.13.2 2.13.1 2.13.0 trunk 1.0.0 2.1.0 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.12.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.1 2.5.3 2.5.4 2.5.5 All 57 releases
slider-blocks / build / blocks / post-slider / frontend.js

frontend.js in GutSlider – All in One Slider and Carousel Blocks for Gutenberg 3.2.0, at build/blocks/post-slider/frontend.js

1 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";window.addEventListener("DOMContentLoaded",(()=>{const t=document.querySelectorAll(".wp-block-gutsliders-post-slider");t.length>0&&t.forEach((t=>{const e=t.querySelector(".swiper:not(.gutslider-thumbs)"),s=t.dataset.swiperOptions,r=JSON.parse(s),o=t.querySelector(".gutslider-thumbs");let a=null;o&&t.dataset.thumbsOptions&&(a=new Swiper(o,JSON.parse(t.dataset.thumbsOptions)));const n=new Swiper(e,{...r,...a&&{thumbs:{swiper:a}}});!function(t,e){const s=t.dataset.loadMore;if(!s)return;const r=t.querySelector(".gs-post-more__status");let o=0,a=!1,n=!1;const i=async()=>{if(!a&&!n){a=!0,t.classList.add("is-loading-more");try{const a=new URL(s,window.location.href);a.searchParams.set("post",t.dataset.post),a.searchParams.set("block",t.dataset.block),a.searchParams.set("page",String(o+1));const i=await fetch(a.toString(),{credentials:"same-origin"});if(!i.ok)throw new Error(String(i.status));const c=await i.json();if(o+=1,c.html){const t=document.createElement("div");t.innerHTML=c.html,e.appendSlide([...t.children].map((t=>t.outerHTML))),e.update()}r&&(r.textContent=c.count?(t.dataset.labelLoaded||"%d").replace("%d",c.count):""),c.more||(n=!0)}catch(t){n=!0}finally{a=!1,t.classList.remove("is-loading-more")}}};e.on("reachEnd",i),e.isEnd&&i()}(t,n),function(t,e){if(!t||!e)return()=>{};const s=()=>[...e.querySelectorAll(".gs-post-list__item")],r=()=>{const e=t.realIndex;s().forEach(((t,s)=>{const r=s===e;t.classList.toggle("is-active",r),t.style.setProperty("--gs-progress","0"),r?t.setAttribute("aria-current","true"):t.removeAttribute("aria-current")}))};t.on("slideChange",r),t.on("autoplayTimeLeft",((e,r,o)=>{s()[t.realIndex]?.style.setProperty("--gs-progress",String(Math.min(1,Math.max(0,1-o))))})),e.addEventListener("click",(e=>{const r=e.target.closest(".gs-post-list__item");if(!r)return;const o=s().indexOf(r);t.params.loop?t.slideToLoop(o):t.slideTo(o)})),e.classList.toggle("has-autoplay",!!t.params.autoplay?.enabled),r()}(n,t.querySelector(":scope > .gs-post-list"));const i=t.dataset.rprev,c=t.dataset.rnext;if(i&&c){const t=document.querySelector(`.${i}`),s=document.querySelector(`.${c}`);t&&t.addEventListener("click",(()=>{e.swiper.slidePrev()})),s&&s.addEventListener("click",(()=>{e.swiper.slideNext()}))}}))}))})();