| 1 |
(()=>{"use strict";document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".ablocks-block--progress-tracker").forEach(t=>{!function(t,e=!1){const r=t?.querySelector(".ablocks-block-progress-bar"),o=t?.querySelector(".ablocks-block-progress-circle"),n=t?.getAttribute("data-layout"),c=t?.getAttribute("data-direction"),s=t?.getAttribute("data-progress-relative"),l=t?.getAttribute("data-progress-relative-selector"),a=t?.querySelector(".ablocks-block-progress__text"),i=o?.querySelector(".ablocks-block-progress-circle__svg-bar"),u=e?window:document.querySelector('[name="editor-canvas"]')?.contentWindow;if(!u)return;const d=t=>{const e=Math.min(Math.max(Math.floor(t),0),100);"bar"===n?(t=>{r&&(r.style.width=`${t}%`),a&&(a.textContent=`${Math.round(t)}%`)})(e):"circle"===n&&(t=>{if(a&&(a.textContent=`${Math.round(t)}%`),i){const e=parseFloat(i.getAttribute("r")||0);if(!e)return;const r=2*Math.PI*e,o=r-t/100*r;i.style.strokeDashoffset="left"===c?`-${o}`:o}})(e)},g=()=>{const t=u.scrollY||0,e=u.innerHeight||0,r=(u.document.documentElement.scrollHeight||0)-e;d(r>0?t/r*100:20)},b=()=>{if(!l)return;const e=t?.ownerDocument?.querySelector(l);if(!e)return;const r=e.getBoundingClientRect().top,o=e.offsetHeight,n=u.innerHeight;if(0!==o)if(r<n&&r+o>0){const t=Math.min(n-r,o),e=Math.max(0,Math.min(100,t/o*100));d(t>=o?100:e)}else d(0);else d(0)};"entire_page"===s?u.addEventListener("scroll",g):"selector"===s&&l&&u.addEventListener("scroll",b),g(),l&&b()}(t,!0)})})})(); |