
ESTILO SIN ESFUERZO,
IMPACTO SIN RUIDO.
DESCUBRE LA ESENCIA DE TU PROXIMO LOOK
-
Hello world!
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
(function () {
if (window.emmyPremiumBound) {
return;
}
window.emmyPremiumBound = true;
var cfg = window.sistemaposStorefront || {};
var i18n = cfg.i18n || {};
var shopAjaxReady = false;
var shopAjaxLoading = false;
function onReady(fn) {
if (document.readyState === “loading”) {
document.addEventListener(“DOMContentLoaded”, fn);
} else {
fn();
}
}
function money(value) {
return “$ ” + Number(value || 0).toLocaleString(“es-CO”);
}
function bindHeaderShrink() {
var onScroll = function () {
document.body.classList.toggle(“emmy-header-compact”, window.scrollY > 24);
};
window.addEventListener(“scroll”, onScroll, { passive: true });
onScroll();
}
function bindScrollReveal() {
var nodes = document.querySelectorAll(
“body.home main > .wp-block-group, body.home main > .wp-block-cover, body.home main > .wp-block-columns, .emmy-about .wp-block-group, .emmy-about .wp-block-columns, .woocommerce-account .woocommerce”
);
if (!nodes.length || !(“IntersectionObserver” in window)) {
return;
}
nodes.forEach(function (el) {
el.classList.add(“emmy-reveal”);
});
var io = new IntersectionObserver(
function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add(“is-visible”);
io.unobserve(entry.target);
}
});
},
{ threshold: 0.12, rootMargin: “0px 0px -40px 0px” }
);
nodes.forEach(function (el) {
io.observe(el);
});
}
function bindShopFilterRange() {
var aside = document.querySelector(“.sistemapos-shop-filters”);
if (!aside || aside.getAttribute(“data-emmy-range”) === “1”) {
return;
}
aside.setAttribute(“data-emmy-range”, “1”);
var range = aside.querySelector(‘input[type=”range”][name=”max_price”]’);
var labels = aside.querySelectorAll(“.sistemapos-shop-filters__price-row span”);
if (!range || labels.length < 2) {
return;
}
range.addEventListener("input", function () {
labels[1].textContent = money(range.value);
});
}
function bindAjaxShopFilters() {
if (shopAjaxReady) {
return;
}
shopAjaxReady = true;
document.addEventListener("click", function (event) {
var layout = document.querySelector(".sistemapos-shop-layout");
var aside = document.querySelector(".sistemapos-shop-filters");
var link = event.target && event.target.closest ? event.target.closest("a") : null;
if (!link || !layout) {
return;
}
var fromAside = aside && aside.contains(link);
var fromPager = link.closest(".woocommerce-pagination, .wc-block-pagination, .wp-block-query-pagination");
if (!fromAside && !fromPager) {
return;
}
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
return;
}
event.preventDefault();
loadShopPage(link.href);
});
document.addEventListener("submit", function (event) {
var form = event.target;
if (!form || !form.classList || !form.classList.contains("sistemapos-shop-filters__price")) {
return;
}
event.preventDefault();
var url = new URL(window.location.href);
var data = new FormData(form);
data.forEach(function (value, key) {
url.searchParams.set(key, String(value));
});
loadShopPage(url.toString());
});
window.addEventListener("popstate", function () {
loadShopPage(window.location.href, true);
});
}
function loadShopPage(url, fromPop) {
var layout = document.querySelector(".sistemapos-shop-layout");
if (!layout || shopAjaxLoading) {
if (!layout) {
window.location.href = url;
}
return;
}
shopAjaxLoading = true;
layout.classList.add("is-loading");
fetch(url, { credentials: "same-origin" })
.then(function (res) {
return res.text();
})
.then(function (html) {
var doc = new DOMParser().parseFromString(html, "text/html");
var nextLayout = doc.querySelector(".sistemapos-shop-layout");
if (!nextLayout) {
window.location.href = url;
return;
}
layout.replaceWith(nextLayout);
bindShopFilterRange();
if (!fromPop) {
history.pushState({}, "", url);
}
})
.catch(function () {
window.location.href = url;
})
.then(function () {
shopAjaxLoading = false;
var shop = document.querySelector(".sistemapos-shop-layout");
if (shop) {
shop.classList.remove("is-loading");
}
});
}
function bindCartFeedback() {
document.body.addEventListener("added_to_cart", function () {
document.body.classList.add("emmy-cart-check");
var badge = document.querySelector(".wc-block-mini-cart__badge");
if (badge) {
badge.classList.remove("emmy-cart-bounce");
void badge.offsetWidth;
badge.classList.add("emmy-cart-bounce");
}
window.setTimeout(function () {
document.body.classList.remove("emmy-cart-check");
}, 1200);
});
if (window.jQuery) {
window.jQuery(document.body).on("added_to_cart", function () {
document.body.dispatchEvent(new Event("added_to_cart"));
});
}
}
function bindNewsletterValidation() {
document.querySelectorAll('form input[type="email"]').forEach(function (input) {
input.addEventListener("input", function () {
var ok = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(input.value);
input.classList.toggle("emmy-mail-ok", ok && input.value.length > 4);
});
});
}
function bindFreeShippingBar() {
var threshold = Number(cfg.freeShipping || 200000);
if (!threshold || !document.body.classList.contains(“woocommerce-cart”)) {
return;
}
var totalNode = document.querySelector(“.cart-subtotal .amount, .wc-block-components-totals-item__value”);
if (!totalNode) {
return;
}
var digits = String(totalNode.textContent || “”).replace(/[^\d]/g, “”);
var current = parseInt(digits, 10) || 0;
var wrap = document.createElement(“div”);
wrap.className = “emmy-free-ship”;
var missing = Math.max(0, threshold – current);
var label = document.createElement(“p”);
label.textContent =
missing > 0
? (i18n.freeShip || “Te faltan %s para envio gratis”).replace(“%s”, money(missing))
: i18n.freeOk || “Tienes envio gratis”;
var bar = document.createElement(“div”);
bar.className = “emmy-free-ship__bar”;
var fill = document.createElement(“div”);
fill.className = “emmy-free-ship__fill”;
fill.style.width = Math.min(100, Math.round((current / threshold) * 100)) + “%”;
bar.appendChild(fill);
wrap.appendChild(label);
wrap.appendChild(bar);
var host = document.querySelector(“.woocommerce-cart-form, .wc-block-cart”);
if (host) {
host.insertAdjacentElement(“afterbegin”, wrap);
}
}
function bindHeroCta() {
if (!document.body.classList.contains(“home”)) {
return;
}
var cover = document.querySelector(“.wp-block-cover, .wp-block-video, video”);
if (!cover || document.querySelector(“.emmy-hero-cta”)) {
return;
}
var parent = cover.closest(“.wp-block-cover”) || cover.parentNode;
if (!parent || parent.querySelector(“.wp-block-button, .emmy-hero-cta”)) {
return;
}
var shop = document.querySelector(‘a[href*=”tienda”], a[href*=”shop”]’);
var href = shop ? shop.getAttribute(“href”) : “/tienda/”;
var a = document.createElement(“a”);
a.className = “emmy-hero-cta wp-element-button”;
a.href = href;
a.textContent = i18n.heroCta || “Ver coleccion”;
parent.appendChild(a);
}
function bindQtyFlash() {
document.addEventListener(“change”, function (event) {
var input = event.target;
if (!input || !input.matches || !input.matches(“input.qty”)) {
return;
}
input.classList.remove(“emmy-qty-flash”);
void input.offsetWidth;
input.classList.add(“emmy-qty-flash”);
});
}
function mountPdpAccordion() {
if (document.querySelector(“.sistemapos-pdp-accordion”)) {
return;
}
var tabs = document.querySelector(“.woocommerce-tabs, .wc-tabs-wrapper”);
if (!tabs) {
return;
}
var wrap = document.createElement(“div”);
wrap.className = “sistemapos-pdp-accordion”;
var panels = [
{ title: i18n.details || “Detalles del producto”, src: “.woocommerce-Tabs-panel–description, #tab-description” },
{ title: i18n.sizes || “Guia de tallas”, src: “.woocommerce-Tabs-panel–additional_information, #tab-additional_information” }
];
panels.forEach(function (panel) {
var source = document.querySelector(panel.src);
if (!source) {
return;
}
var details = document.createElement(“details”);
var summary = document.createElement(“summary”);
summary.textContent = panel.title;
var body = document.createElement(“div”);
body.className = “sistemapos-pdp-accordion__body”;
body.innerHTML = source.innerHTML;
details.appendChild(summary);
details.appendChild(body);
wrap.appendChild(details);
});
if (!wrap.children.length) {
return;
}
var shipLink = document.querySelector(‘footer a[href*=”envio”], footer a[href*=”devoluc”], a[href*=”cambios”]’);
if (shipLink) {
var shipDetails = document.createElement(“details”);
var shipSummary = document.createElement(“summary”);
shipSummary.textContent = i18n.shipping || “Envios y devoluciones”;
var shipBody = document.createElement(“div”);
shipBody.className = “sistemapos-pdp-accordion__body”;
shipBody.appendChild(shipLink.cloneNode(true));
shipDetails.appendChild(shipSummary);
shipDetails.appendChild(shipBody);
wrap.appendChild(shipDetails);
}
tabs.insertAdjacentElement(“afterend”, wrap);
tabs.style.display = “none”;
}
function markOutOfStock() {
var stock = document.querySelector(“p.stock.out-of-stock”);
if (!stock) {
return;
}
stock.classList.add(“sistemapos-oos”);
var gallery = document.querySelector(“.woocommerce-product-gallery”);
if (gallery && !gallery.querySelector(“.sistemapos-oos-badge”)) {
var badge = document.createElement(“span”);
badge.className = “sistemapos-oos-badge”;
badge.textContent = stock.textContent || “Agotado”;
gallery.appendChild(badge);
}
if (document.querySelector(“.sistemapos-notify, .cwginstock-subscribe-form, .alert-box”)) {
return;
}
var note = document.createElement(“p”);
note.className = “sistemapos-notify”;
note.textContent = i18n.notify || “Avisame cuando vuelva”;
stock.insertAdjacentElement(“afterend”, note);
}
onReady(function () {
bindHeaderShrink();
bindScrollReveal();
bindShopFilterRange();
bindAjaxShopFilters();
bindCartFeedback();
bindNewsletterValidation();
bindFreeShippingBar();
bindHeroCta();
bindQtyFlash();
mountPdpAccordion();
markOutOfStock();
});
})();