| Server IP : 172.67.191.97 / Your IP : 104.23.243.196 Web Server : Apache/2.4.63 (Ubuntu) System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.4.5 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/idiomas/templates/g5_helium/custom/js/ |
Upload File : |
(function () {
"use strict";
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
function initBrochure(root) {
var pages = Array.prototype.slice.call(root.querySelectorAll("[data-brochure-page]"));
if (!pages.length) {
return;
}
var book = root.querySelector("[data-brochure-book]");
var counters = Array.prototype.slice.call(root.querySelectorAll("[data-brochure-counter]"));
var progress = root.querySelector("[data-brochure-progress]");
var title = root.querySelector("[data-brochure-title]");
var dots = Array.prototype.slice.call(root.querySelectorAll("[data-brochure-dot]"));
var thumbs = Array.prototype.slice.call(root.querySelectorAll("[data-brochure-thumb]"));
var status = root.querySelector("[data-brochure-status]");
var autoTimer = null;
var view = "auto";
var index = 0;
var zoom = 1;
var startX = 0;
var startY = 0;
function spreadEnabled() {
return false;
}
function nextIndex() {
if (spreadEnabled() && index > 0) {
return clamp(index + 2, 0, pages.length - 1);
}
return clamp(index + 1, 0, pages.length - 1);
}
function previousIndex() {
if (spreadEnabled() && index > 1) {
return clamp(index - 2, 0, pages.length - 1);
}
return clamp(index - 1, 0, pages.length - 1);
}
function normalizeForSpread(next) {
if (!spreadEnabled() || next === 0) {
return next;
}
return next % 2 === 0 ? next - 1 : next;
}
function announce(message) {
if (!status) {
return;
}
status.textContent = message;
root.classList.add("has-feedback");
window.clearTimeout(status._idiomaTimer);
status._idiomaTimer = window.setTimeout(function () {
root.classList.remove("has-feedback");
}, 2200);
}
function visiblePageText() {
var active = pages[index];
return active ? active.textContent.replace(/\s+/g, " ").trim() : "";
}
function stopAuto() {
if (autoTimer) {
window.clearInterval(autoTimer);
autoTimer = null;
}
root.classList.remove("is-autoplaying");
}
function startAuto() {
stopAuto();
root.classList.add("is-autoplaying");
announce("Reproduccion automatica activada");
autoTimer = window.setInterval(function () {
var next = nextIndex();
if (next === index) {
stopAuto();
announce("Llegaste al final del brochure");
return;
}
go(next);
}, 5200);
}
function stopSpeech() {
if ("speechSynthesis" in window) {
window.speechSynthesis.cancel();
}
root.classList.remove("is-speaking");
}
function update() {
var spread = spreadEnabled();
var second = spread && index > 0 && index + 1 < pages.length ? index + 1 : -1;
var shownEnd = second > -1 ? second : index;
root.dataset.view = spread ? "desktop" : "mobile";
root.style.setProperty("--brochure-zoom", zoom.toFixed(2));
pages.forEach(function (page, pageIndex) {
page.classList.toggle("is-active", pageIndex === index);
page.classList.toggle("is-next", pageIndex === second);
page.setAttribute("aria-hidden", pageIndex === index || pageIndex === second ? "false" : "true");
});
dots.forEach(function (dot, dotIndex) {
dot.classList.toggle("is-active", dotIndex === index || dotIndex === second);
dot.setAttribute("aria-current", dotIndex === index ? "true" : "false");
});
thumbs.forEach(function (thumb, thumbIndex) {
thumb.classList.toggle("is-active", thumbIndex === index || thumbIndex === second);
thumb.setAttribute("aria-current", thumbIndex === index ? "true" : "false");
});
counters.forEach(function (counter) {
counter.textContent = (index + 1) + (second > -1 ? "-" + (second + 1) : "") + " / " + pages.length;
});
if (progress) {
progress.style.width = (((shownEnd + 1) / pages.length) * 100).toFixed(2) + "%";
}
if (title) {
title.textContent = pages[index].getAttribute("data-title") || "Brochure interactivo";
}
root.querySelectorAll("[data-brochure-action='prev']").forEach(function (button) {
button.disabled = index === 0;
});
root.querySelectorAll("[data-brochure-action='next']").forEach(function (button) {
button.disabled = shownEnd >= pages.length - 1;
});
root.querySelectorAll("[data-brochure-action='auto']").forEach(function (button) {
button.classList.toggle("is-active", Boolean(autoTimer));
});
root.querySelectorAll("[data-brochure-action='listen']").forEach(function (button) {
button.classList.toggle("is-active", root.classList.contains("is-speaking"));
});
root.querySelectorAll("[data-brochure-view]").forEach(function (button) {
button.classList.toggle("is-active", button.getAttribute("data-brochure-view") === view);
});
}
function go(next) {
index = normalizeForSpread(clamp(next, 0, pages.length - 1));
update();
if (pages[index]) {
pages[index].scrollTop = 0;
}
}
root.addEventListener("click", function (event) {
var actionButton = event.target.closest("[data-brochure-action]");
var targetButton = event.target.closest("[data-brochure-target]");
var viewButton = event.target.closest("[data-brochure-view]");
if (targetButton && root.contains(targetButton)) {
go(parseInt(targetButton.getAttribute("data-brochure-target"), 10));
root.classList.remove("is-contents-open");
return;
}
if (viewButton && root.contains(viewButton)) {
view = viewButton.getAttribute("data-brochure-view") || "auto";
go(index);
return;
}
if (!actionButton || !root.contains(actionButton)) {
return;
}
var action = actionButton.getAttribute("data-brochure-action");
if (action === "prev") {
stopAuto();
go(previousIndex());
} else if (action === "next") {
stopAuto();
go(nextIndex());
} else if (action === "contents") {
root.classList.toggle("is-contents-open");
root.classList.remove("is-info-open");
} else if (action === "info") {
root.classList.toggle("is-info-open");
root.classList.remove("is-contents-open");
} else if (action === "close-panels") {
root.classList.remove("is-info-open", "is-contents-open");
} else if (action === "immersive") {
root.classList.toggle("is-immersive");
root.scrollIntoView({ behavior: "smooth", block: "start" });
} else if (action === "auto") {
if (autoTimer) {
stopAuto();
announce("Reproduccion automatica pausada");
} else {
startAuto();
}
} else if (action === "listen") {
if (!("speechSynthesis" in window)) {
announce("Tu navegador no permite lectura en voz alta");
return;
}
if (root.classList.contains("is-speaking")) {
stopSpeech();
announce("Lectura pausada");
update();
return;
}
stopSpeech();
var utterance = new SpeechSynthesisUtterance(visiblePageText());
utterance.lang = "es-CO";
utterance.rate = 0.92;
utterance.onend = function () {
root.classList.remove("is-speaking");
update();
};
root.classList.add("is-speaking");
window.speechSynthesis.speak(utterance);
announce("Leyendo la pagina actual");
update();
} else if (action === "share") {
var shareData = {
title: "Brochure Kids Starter 5 y 6 anos",
text: "Brochure interactivo del Centro de Idiomas Unillanos",
url: window.location.href.split("#")[0] + "#brochure-kids-5-6"
};
if (navigator.share) {
navigator.share(shareData).catch(function () {});
} else if (navigator.clipboard) {
navigator.clipboard.writeText(shareData.url).then(function () {
announce("Enlace copiado al portapapeles");
});
} else {
announce("Copia este enlace desde la barra del navegador");
}
} else if (action === "zoom-in") {
zoom = clamp(zoom + 0.12, 0.82, 1.42);
update();
} else if (action === "zoom-out") {
zoom = clamp(zoom - 0.12, 0.82, 1.42);
update();
} else if (action === "zoom-reset") {
zoom = 1;
update();
} else if (action === "fullscreen" && root.requestFullscreen) {
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
root.requestFullscreen();
}
} else if (action === "print") {
window.print();
}
});
root.addEventListener("touchstart", function (event) {
if (!event.changedTouches.length) {
return;
}
startX = event.changedTouches[0].clientX;
startY = event.changedTouches[0].clientY;
}, { passive: true });
root.addEventListener("touchend", function (event) {
if (!event.changedTouches.length) {
return;
}
var diffX = event.changedTouches[0].clientX - startX;
var diffY = event.changedTouches[0].clientY - startY;
if (Math.abs(diffX) > 52 && Math.abs(diffX) > Math.abs(diffY)) {
stopAuto();
go(diffX < 0 ? nextIndex() : previousIndex());
}
}, { passive: true });
document.addEventListener("keydown", function (event) {
if (!root.matches(":hover") && !root.contains(document.activeElement) && document.fullscreenElement !== root) {
return;
}
if (event.key === "ArrowRight") {
stopAuto();
go(nextIndex());
} else if (event.key === "ArrowLeft") {
stopAuto();
go(previousIndex());
} else if (event.key === "Escape") {
root.classList.remove("is-contents-open", "is-info-open", "is-immersive");
}
});
window.addEventListener("resize", function () {
go(index);
});
pages.forEach(function (page) {
page.scrollTop = 0;
});
if (book) {
book.setAttribute("tabindex", "0");
}
update();
}
function initTutorialHub(root) {
var profileButtons = Array.prototype.slice.call(root.querySelectorAll("[data-tutorial-profile]"));
var tabButtons = Array.prototype.slice.call(root.querySelectorAll("[data-tutorial-tab]"));
var items = Array.prototype.slice.call(root.querySelectorAll("[data-tutorial-item]"));
var readers = Array.prototype.slice.call(root.querySelectorAll(".idioma-pdf-brochure--tutorial"));
var empty = root.querySelector("[data-tutorial-empty]");
var profile = profileButtons.length ? profileButtons[0].getAttribute("data-tutorial-profile") : "profesor";
var tab = "tutorial";
var roleHashes = {
"rol-profesor": "profesor",
"rol-padres": "profesor",
"padres-de-familia": "profesor",
"rol-docente": "docente",
"docente": "docente",
"rol-ull": "ull",
"rol-pregrado": "ull",
"estudiantes-pregrado-plan-bull": "ull",
"rol-externo": "externo",
"rol-extension": "externo",
"estudiantes-extension": "externo"
};
function itemMatches(item) {
var profiles = (item.getAttribute("data-profile") || "").split(/\s+/);
var type = item.getAttribute("data-type") || "";
return profiles.indexOf(profile) !== -1 && type === tab;
}
function selectProfileFromHash(shouldScroll) {
var hash = window.location.hash ? window.location.hash.slice(1) : "";
var nextProfile = roleHashes[hash];
if (!nextProfile) {
return false;
}
profile = nextProfile;
tab = "tutorial";
showReader("", false);
update();
if (shouldScroll) {
window.setTimeout(function () {
var top = root.getBoundingClientRect().top + window.pageYOffset - 80;
window.scrollTo({ top: Math.max(top, 0), behavior: "smooth" });
}, 80);
}
return true;
}
function update() {
var visibleCount = 0;
profileButtons.forEach(function (button) {
var active = button.getAttribute("data-tutorial-profile") === profile;
button.classList.toggle("is-active", active);
button.setAttribute("aria-pressed", active ? "true" : "false");
});
tabButtons.forEach(function (button) {
var active = button.getAttribute("data-tutorial-tab") === tab;
button.classList.toggle("is-active", active);
button.setAttribute("aria-selected", active ? "true" : "false");
});
root.classList.remove("is-switching");
window.requestAnimationFrame(function () {
root.classList.add("is-switching");
});
items.forEach(function (item, index) {
var show = itemMatches(item);
item.hidden = !show;
item.style.display = show ? "" : "none";
item.classList.toggle("is-visible", show);
if (show) {
item.style.setProperty("--tutorial-delay", (visibleCount * 70) + "ms");
visibleCount += 1;
} else {
item.style.removeProperty("--tutorial-delay");
}
});
if (empty) {
empty.hidden = visibleCount > 0;
}
}
function showReader(targetId, shouldScroll) {
var target = null;
readers.forEach(function (reader) {
var active = reader.id === targetId;
reader.classList.toggle("is-reader-active", active);
reader.classList.toggle("is-reader-collapsed", !active);
reader.setAttribute("aria-hidden", active ? "false" : "true");
if (active) {
target = reader;
}
});
root.classList.toggle("has-open-reader", Boolean(target));
if (target && shouldScroll) {
window.setTimeout(function () {
var top = target.getBoundingClientRect().top + window.pageYOffset - 92;
window.scrollTo({ top: Math.max(top, 0), behavior: "smooth" });
}, 120);
}
}
root.addEventListener("click", function (event) {
var profileButton = event.target.closest("[data-tutorial-profile]");
var tabButton = event.target.closest("[data-tutorial-tab]");
var mediaButton = event.target.closest("[data-youtube-id], [data-youtube-url]");
var guideLink = event.target.closest("a[href^='#guia-']");
if (profileButton && root.contains(profileButton)) {
profile = profileButton.getAttribute("data-tutorial-profile") || profile;
showReader("", false);
update();
if (history.replaceState && window.location.hash.indexOf("#guia-") === 0) {
history.replaceState(null, "", window.location.pathname + window.location.search);
}
return;
}
if (tabButton && root.contains(tabButton)) {
tab = tabButton.getAttribute("data-tutorial-tab") || tab;
showReader("", false);
update();
if (history.replaceState && window.location.hash.indexOf("#guia-") === 0) {
history.replaceState(null, "", window.location.pathname + window.location.search);
}
return;
}
if (guideLink && root.contains(guideLink)) {
var targetId = guideLink.getAttribute("href").slice(1);
event.preventDefault();
showReader(targetId, true);
if (history.pushState) {
history.pushState(null, "", "#" + targetId);
}
return;
}
if (mediaButton && root.contains(mediaButton)) {
var youtubeId = mediaButton.getAttribute("data-youtube-id");
var youtubeUrl = mediaButton.getAttribute("data-youtube-url");
if (youtubeId) {
mediaButton.innerHTML = '<iframe src="https://www.youtube-nocookie.com/embed/' + encodeURIComponent(youtubeId) + '?autoplay=1&rel=0" title="Video tutorial" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen loading="lazy"></iframe>';
mediaButton.classList.add("is-playing");
} else if (youtubeUrl) {
window.open(youtubeUrl, "_blank", "noopener");
}
}
});
update();
if (!selectProfileFromHash(Boolean(window.location.hash))) {
showReader(window.location.hash ? window.location.hash.slice(1) : "", Boolean(window.location.hash));
}
window.addEventListener("hashchange", function () {
if (!selectProfileFromHash(true)) {
showReader(window.location.hash ? window.location.hash.slice(1) : "", Boolean(window.location.hash));
}
});
}
function boot() {
initTopbarOverlayMenus();
document.querySelectorAll("[data-idioma-brochure]").forEach(initBrochure);
document.querySelectorAll("[data-idioma-pdf-brochure]").forEach(initPdfBrochure);
document.querySelectorAll("[data-idioma-tutorial-hub]").forEach(initTutorialHub);
}
function initTopbarOverlayMenus() {
if (document.body.hasAttribute("data-idioma-topbar-ready")) {
return;
}
var menus = {
"230": null,
"235": [
{ label: "Sube documentación", href: "/plantillajoomla5.3/index.php/inscripcion" },
{ label: "Descarga formulario de inscripción", href: "/plantillajoomla5.3/index.php/inscripcion" },
{ label: "Inscripción pruebas diagnósticas", href: "/plantillajoomla5.3/index.php/academico/pruebas-internacionales" }
]
};
var overlay = document.createElement("div");
overlay.className = "idioma-topbar-floating";
overlay.hidden = true;
overlay.setAttribute("role", "menu");
document.body.appendChild(overlay);
document.body.setAttribute("data-idioma-topbar-ready", "true");
function nativeLinks(item) {
var dropdown = item ? item.querySelector(".g-dropdown") : null;
if (!dropdown) {
return [];
}
return Array.prototype.slice.call(dropdown.querySelectorAll("a[href]")).filter(function (link) {
return !link.closest(".g-go-back");
}).map(function (link) {
return {
href: link.href,
label: link.textContent.replace(/\s+/g, " ").trim()
};
});
}
function render(items) {
overlay.innerHTML = "";
items.forEach(function (link, index) {
var anchor = document.createElement("a");
anchor.href = link.href;
anchor.setAttribute("role", "menuitem");
anchor.innerHTML = '<span>' + (index + 1) + '</span><strong>' + link.label + '</strong>';
overlay.appendChild(anchor);
});
}
function open(item, items) {
var trigger = item.querySelector(".g-menu-item-container");
if (!trigger || !items.length) {
return;
}
var rect = trigger.getBoundingClientRect();
render(items);
overlay.hidden = false;
overlay.classList.add("is-active");
overlay.style.top = Math.round(rect.bottom + window.scrollY + 2) + "px";
overlay.style.left = Math.max(12, Math.round(rect.right + window.scrollX - 310)) + "px";
trigger.setAttribute("aria-expanded", "true");
}
function close() {
overlay.hidden = true;
overlay.classList.remove("is-active");
document.querySelectorAll(".g-menu-item-230 > .g-menu-item-container, .g-menu-item-235 > .g-menu-item-container").forEach(function (trigger) {
trigger.setAttribute("aria-expanded", "false");
});
}
document.addEventListener("click", function (event) {
var item = event.target.closest(".g-menu-item-230.g-parent, .g-menu-item-235.g-parent");
var insideOverlay = event.target.closest(".idioma-topbar-floating");
if (insideOverlay) {
close();
return;
}
if (!item) {
close();
return;
}
var idMatch = item.className.match(/g-menu-item-(230|235)/);
if (!idMatch || !event.target.closest(".g-menu-item-container")) {
return;
}
event.preventDefault();
event.stopPropagation();
if (event.stopImmediatePropagation) {
event.stopImmediatePropagation();
}
var configured = menus[idMatch[1]];
open(item, configured || nativeLinks(item));
}, true);
window.addEventListener("resize", close);
}
function initTopbarFloatingMenu(options) {
var item = document.querySelector(options.itemSelector);
if (!item || item.hasAttribute(options.readyAttribute)) {
return;
}
var trigger = null;
var dropdown = null;
Array.prototype.slice.call(item.children).forEach(function (child) {
if (child.classList.contains("g-menu-item-container")) {
trigger = child;
} else if (child.classList.contains("g-dropdown")) {
dropdown = child;
}
});
if (!trigger || !dropdown) {
return;
}
var sourceLinks = options.links || Array.prototype.slice.call(dropdown.querySelectorAll("a[href]")).filter(function (link) {
return !link.closest(".g-go-back");
}).map(function (link) {
return {
href: link.href,
label: link.textContent.replace(/\s+/g, " ").trim()
};
});
var floating = document.createElement("div");
floating.className = options.className;
floating.hidden = true;
floating.setAttribute("role", "menu");
sourceLinks.forEach(function (link, index) {
var clone = document.createElement("a");
clone.href = link.href;
clone.setAttribute("role", "menuitem");
clone.innerHTML = '<span>' + (index + 1) + '</span><strong>' + link.label + '</strong>';
floating.appendChild(clone);
});
document.body.appendChild(floating);
item.setAttribute(options.readyAttribute, "true");
trigger.setAttribute("role", "button");
trigger.setAttribute("tabindex", "0");
trigger.setAttribute("aria-haspopup", "true");
trigger.setAttribute("aria-expanded", "false");
function setOpen(open) {
var rect = trigger.getBoundingClientRect();
item.classList.toggle("g-selected", open);
dropdown.classList.toggle("g-active", open);
dropdown.classList.toggle("g-inactive", !open);
trigger.setAttribute("aria-expanded", open ? "true" : "false");
floating.hidden = !open;
floating.classList.toggle("is-active", open);
if (open) {
var width = options.width || 300;
floating.style.top = Math.round(rect.bottom + window.scrollY) + "px";
floating.style.left = Math.max(12, Math.round(rect.right + window.scrollX - width)) + "px";
floating.style.width = width + "px";
}
}
function toggle(event) {
if (event) {
event.preventDefault();
event.stopPropagation();
if (event.stopImmediatePropagation) {
event.stopImmediatePropagation();
}
}
setOpen(!dropdown.classList.contains("g-active"));
}
trigger.addEventListener("click", toggle);
document.addEventListener("click", function (event) {
var clickedTrigger = event.target.closest(options.itemSelector + " > .g-menu-item-container");
var clickedFloating = event.target.closest("." + options.className.split(" ")[0]);
if (clickedTrigger) {
toggle(event);
return;
}
if (!item.contains(event.target) && !clickedFloating) {
setOpen(false);
}
}, true);
trigger.addEventListener("keydown", function (event) {
if (event.key === "Enter" || event.key === " ") {
toggle(event);
} else if (event.key === "Escape") {
setOpen(false);
}
});
dropdown.addEventListener("click", function (event) {
var link = event.target.closest("a[href]");
if (link) {
setOpen(false);
}
});
floating.addEventListener("click", function (event) {
var link = event.target.closest("a[href]");
if (link) {
setOpen(false);
}
});
window.addEventListener("resize", function () {
if (floating.classList.contains("is-active")) {
setOpen(true);
}
});
window.addEventListener("scroll", function () {
if (floating.classList.contains("is-active")) {
setOpen(true);
}
}, { passive: true });
}
function initPdfBrochure(root) {
var frame = root.querySelector("[data-pdf-frame]");
var canvas = root.querySelector("[data-pdf-canvas]");
var loading = root.querySelector("[data-pdf-loading]");
var currentLabel = root.querySelector("[data-pdf-current]");
var totalLabel = root.querySelector("[data-pdf-total]");
var progress = root.querySelector("[data-pdf-progress]");
var dotsWrap = root.querySelector("[data-pdf-dots]") || root.querySelector(".idioma-pdf-brochure__dots");
var dots = Array.prototype.slice.call(root.querySelectorAll("[data-pdf-dot]"));
var source = root.getAttribute("data-pdf-src") || "";
var total = parseInt(root.getAttribute("data-pdf-pages"), 10) || dots.length || 1;
var page = 1;
var turnTimer = null;
var pdfDoc = null;
var renderTask = null;
var renderVersion = 0;
if (!source) {
return;
}
function pdfUrl(nextPage) {
return source + "#toolbar=0&navpanes=0&scrollbar=0&view=FitH&page=" + nextPage;
}
function setLoading(isLoading) {
root.classList.toggle("is-loading", Boolean(isLoading));
if (loading) {
loading.hidden = !isLoading;
}
}
function syncDots() {
if (!dotsWrap) {
return;
}
if (dots.length === total) {
return;
}
dotsWrap.innerHTML = "";
for (var index = 1; index <= total; index += 1) {
var dot = document.createElement("button");
dot.type = "button";
dot.setAttribute("data-pdf-dot", "");
dot.setAttribute("data-pdf-page", index);
dot.setAttribute("aria-label", "Pagina " + index);
dotsWrap.appendChild(dot);
}
dots = Array.prototype.slice.call(root.querySelectorAll("[data-pdf-dot]"));
}
function fallbackToFrame() {
root.classList.add("is-pdf-fallback");
if (frame) {
frame.setAttribute("src", pdfUrl(page));
}
setLoading(false);
}
function renderCanvas() {
if (!canvas || !pdfDoc) {
return;
}
var version = ++renderVersion;
var holder = canvas.parentElement;
var box = holder.getBoundingClientRect();
var context = canvas.getContext("2d");
setLoading(true);
pdfDoc.getPage(page).then(function (pdfPage) {
if (version !== renderVersion) {
return null;
}
var baseViewport = pdfPage.getViewport({ scale: 1 });
var availableWidth = Math.max(320, box.width - 52);
var availableHeight = Math.max(420, box.height - 52);
var cssScale = Math.min(availableWidth / baseViewport.width, availableHeight / baseViewport.height);
var pixelRatio = Math.min(window.devicePixelRatio || 1, 2);
var viewport = pdfPage.getViewport({ scale: cssScale * pixelRatio });
if (renderTask) {
renderTask.cancel();
}
canvas.width = Math.floor(viewport.width);
canvas.height = Math.floor(viewport.height);
canvas.style.width = Math.floor(viewport.width / pixelRatio) + "px";
canvas.style.height = Math.floor(viewport.height / pixelRatio) + "px";
canvas._idiomaPixelRatio = pixelRatio;
context.clearRect(0, 0, canvas.width, canvas.height);
renderTask = pdfPage.render({
canvasContext: context,
viewport: viewport
});
return renderTask.promise;
}).then(function () {
if (version === renderVersion) {
cropPrintedFooter(context, canvas);
root.classList.add("is-pdf-rendered");
setLoading(false);
}
}).catch(function (error) {
if (error && error.name === "RenderingCancelledException") {
return;
}
fallbackToFrame();
});
}
function cropPrintedFooter(context, targetCanvas) {
var cropHeight = Math.max(18, Math.floor(targetCanvas.height * 0.045));
var nextHeight = targetCanvas.height - cropHeight;
var imageData = context.getImageData(0, 0, targetCanvas.width, nextHeight);
var pixelRatio = targetCanvas._idiomaPixelRatio || 1;
targetCanvas.height = nextHeight;
targetCanvas.style.height = Math.floor(nextHeight / pixelRatio) + "px";
context.putImageData(imageData, 0, 0);
}
function update(nextPage, direction) {
syncDots();
page = clamp(nextPage, 1, total);
root.classList.remove("is-turning-next", "is-turning-prev");
root.classList.add("is-turning", direction === "prev" ? "is-turning-prev" : "is-turning-next");
window.clearTimeout(turnTimer);
turnTimer = window.setTimeout(function () {
root.classList.remove("is-turning", "is-turning-next", "is-turning-prev");
}, 520);
if (pdfDoc) {
renderCanvas();
} else if (frame && !canvas) {
frame.setAttribute("src", pdfUrl(page));
}
if (currentLabel) {
currentLabel.textContent = page;
}
if (totalLabel) {
totalLabel.textContent = total;
}
if (progress) {
progress.style.width = ((page / total) * 100).toFixed(2) + "%";
}
dots.forEach(function (dot, index) {
var active = index + 1 === page;
dot.classList.toggle("is-active", active);
dot.setAttribute("aria-current", active ? "true" : "false");
});
root.querySelectorAll("[data-pdf-action='prev']").forEach(function (button) {
button.disabled = page === 1;
});
root.querySelectorAll("[data-pdf-action='next']").forEach(function (button) {
button.disabled = page === total;
});
}
root.addEventListener("click", function (event) {
var actionButton = event.target.closest("[data-pdf-action]");
var dot = event.target.closest("[data-pdf-dot]");
if (dot && root.contains(dot)) {
var target = parseInt(dot.getAttribute("data-pdf-page"), 10) || 1;
update(target, target < page ? "prev" : "next");
return;
}
if (!actionButton || !root.contains(actionButton)) {
return;
}
var action = actionButton.getAttribute("data-pdf-action");
if (action === "prev") {
update(page - 1, "prev");
} else if (action === "next") {
update(page + 1, "next");
} else if (action === "fullscreen" && root.requestFullscreen) {
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
root.requestFullscreen();
}
}
});
document.addEventListener("keydown", function (event) {
if (!root.matches(":hover") && !root.contains(document.activeElement) && document.fullscreenElement !== root) {
return;
}
if (event.key === "ArrowRight") {
update(page + 1, "next");
} else if (event.key === "ArrowLeft") {
update(page - 1, "prev");
}
});
if (canvas && window.Promise) {
setLoading(true);
import("/plantillajoomla5.3/media/vendor/pdfjs/pdf.mjs").then(function (pdfjsLib) {
pdfjsLib.GlobalWorkerOptions.workerSrc = "/plantillajoomla5.3/media/vendor/pdfjs/pdf.worker.mjs";
return pdfjsLib.getDocument(source).promise;
}).then(function (documentProxy) {
pdfDoc = documentProxy;
total = pdfDoc.numPages || total;
syncDots();
update(page, "next");
}).catch(function () {
fallbackToFrame();
});
}
update(1, "next");
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", boot);
} else {
boot();
}
}());