Rotafilio_Vantive/js/config.min.js

1 line
5.1 KiB
JavaScript
Raw Normal View History

function renderPagination(e,t){const n=document.getElementById("coursenav-page-number"),o=document.getElementById("coursenav-total-pages");if(!Array.isArray(t))return;manageMenuVisibility(e,t);const r=t[e];if(!r)return;const s=t.filter((e=>e.moduleTitle===r.moduleTitle)),l=s.findIndex((e=>e.content===r.content));n&&(n.textContent=l+1),o&&(o.textContent=" / "+s.length),updateNavButtons(l,s)}function updateNavButtons(e,t){const n=document.getElementById("coursenav-next-btn"),o=document.getElementById("coursenav-prev-btn");if(!n||!o)return;const r=e+1===t.length,s=0===e,l=CourseNav.isDebug();n.classList.toggle("disabled",r&&!l),o.classList.toggle("disabled",s&&!l)}function manageMenuVisibility(e,t){const n=document.querySelectorAll("#coursenav-main-menu > ul.course-menu");if(!n.length)return;if(n[0].style.display="block",!Array.isArray(t)||!t.length){for(let e=1;e<n.length;e++)n[e].style.display="none";return}const o=t[e];if(!o?.moduleTitle){for(let e=1;e<n.length;e++)n[e].style.display="none";return}const r=o.moduleTitle;for(let e=1;e<n.length;e++){const o=Array.from(n[e].querySelectorAll(".coursenav-link")).some((e=>{const n=parseInt(e.dataset.coursenavindex);return n>=0&&t[n]?.moduleTitle===r}));n[e].style.display=o?"block":"none"}}function scrollToElementTop(e,t={}){const n=Object.assign({behavior:"smooth",block:"start",inline:"nearest"},t),o=document.querySelector(e);o&&o.scrollIntoView(n)}function animateOnScroll(e,t,n={}){const{threshold:o=.1,animateOnce:r=!0,prefix:s="animate__animated"}=n,l=new IntersectionObserver(((e,n)=>{e.forEach((e=>{e.isIntersecting?(e.target.classList.add(s,t),r&&n.unobserve(e.target)):r||e.target.classList.remove(s,t)}))}),{threshold:o});return document.querySelectorAll(e).forEach((e=>l.observe(e))),l}function scaleWrapCourseContent(){const e=document.querySelector(".wrap-course-content"),t=document.querySelector("#coursenav-main-content");if(!e)return;const n=document.querySelector("header"),o=document.querySelector("footer"),r=n?n.offsetHeight:0,s=o?o.offsetHeight:0,l=window.innerWidth,i=window.innerHeight-r;if(l<1366){const n=Math.min(l/1366,i/768);if(e.style.transform=`scale(${n})`,e.style.transformOrigin="top left",e.style.width="1366px",e.style.height="768px",e.style.position="absolute",e.style.left=(l-1366*n)/2+"px",e.style.top=r+(i-768*n)/2+"px",e.style.overflow="hidden",t){const e=688;t.style.height=e+"px"}}else e.style.transform="",e.style.transformOrigin="",e.style.width="100%",e.style.height="100vh",e.style.position="relative",e.style.left="",e.style.top="",e.style.overflow="hidden",t&&(t.style.height=`calc(100vh - ${r+s}px)`);e.style.zIndex="1"}function renderStepper(e,t,n,o=5){if("string"==typeof e&&(e=document.querySelector(e)),"string"==typeof n&&(n=document.querySelector(n)),!(e instanceof HTMLElement&&n instanceof HTMLElement))throw new Error("renderStepper: elementos inválidos.");e.querySelectorAll(".step").forEach((e=>e.remove()));const r=Array.from({length:o},((e,t)=>t/(o-1)*100)),s=r.map(((e,t)=>({p:e,i:t}))).filter((({p:e})=>e<=t)).pop().i;r.forEach(((t,n)=>{const o=document.createElement("div");o.classList.add("step"),n<s&&o.classList.add("completed"),n===s&&(o.classList.add("completed"),o.setAttribute("data-label",Math.round(t)+"%")),e.appendChild(o)})),e.style.setProperty("--pct",t+"%");const l=n.offsetWidth;n.style.left=`calc(${t}% - ${l}px)`,n.setAttribute("data-label",t+"%")}function gotoFirstMenuToolSlide(){const e=CourseNav.getCourseContentArray(),t=CourseNav.getCurrentSlide(),n=e.findIndex((e=>"Menús de la herramienta"===e.title&&e.moduleTitle===t.moduleTitle));-1!==n&&CourseNav.gotoSlide(n)}window.COURSE_CONFIG={COURSE_CONFIG_URL:"config.json",DEBUG:!1},document.addEventListener("DOMContentLoaded",(()=>{setTimeout(scaleWrapCourseContent,100),window.addEventListener("resize",(()=>setTimeout(scaleWrapCourseContent,100))),document.body.addEventListener("beforeSlideChange",(e=>{})),document.body.addEventListener("slideChange",(e=>{if(e.detail&&"number"==typeof e.detail.slideIndex&&Array.isArray(e.detail.contentArray)){renderPagination(e.detail.slideIndex,e.de