/* * AGS 92 B2B – bočné mrakodrapy (skyscraper) pre akcie značiek – VIAC AKCIÍ NARAZ * Súbor: /buxus/docs/mrakodrap4.js.txt (v4, 28. 10. 2026), načítaný v pätičke (Container 22 → Content after) * v4: „zostáva X dní“ = celé dni do konca akcie (rovnako ako odpočet v lište), nie kalendárne dni vrátane dneška; pod 24 h „posledný deň akcie“. * v3: zoznam akcií (každá s vlastným dátumom, farbou, textami a fotkami), fotky z malých náhľadov, * štart až po načítaní stránky, na HU rešpektuje skryté značky (window.agsChicco.hide). * v2: fotky bez loading=lazy. v1: prvá verzia (jedna akcia). * * Nastavenie – riadok v Container 22 PRED týmto skriptom (zoznam; stačí aj jedna akcia bez [ ]): * * - od / do = začiatok a koniec; mimo tohto času sa akcia nezobrazí (po skončení zmizne sama) * - farba = farba odznaku a záložky (predvolená #e2156b) * - nazov = (voliteľné) malý nadpis hore, napr. { sk: 'CHICCO DAYS', … } (inak „AKCIA ZNAČKY“) * - text = (voliteľné) podnadpis pod zľavou (inak „na celý sortiment“) * - hladat / odkaz = kam vedie klik (vyhľadávanie značky alebo vlastná URL per trh) * - foto = cesty k obrázkom (malé náhľady /buxus/images/sky-.jpg, cache 30 dní) alebo kódy produktov (veľké obrázky – pomalšie) * - trhy = trhy akcie; off: true = vypnúť túto akciu * Celé vypnutie: window.agsSkyOff = true (alebo zmazať riadky). * * Zobrazenie podľa šírky okna (voľný okraj vedľa obsahu 1170 px): * okraj ≥ 316 px → 2 mrakodrapy 300 × 600, okraj ≥ 172 px → 2 úzke 160 × 600 * 1 akcia: vľavo aj vpravo tá istá · 2 akcie: vľavo prvá, vpravo druhá · 3+: dvojice sa striedajú každých 12 s * užšie okno (notebooky) → záložky pod sebou na pravom okraji (každá akcia vlastná farba), klik rozbalí kartu * pod 768 px (mobil) → nič * Krížik zbalí mrakodrapy do záložiek (do zatvorenia prehliadača). Len prihlásený partner SK/CZ/HU, * nie v krokoch objednávky. Meranie: dataLayer ags_sky_view / ags_sky_click / ags_sky_close (ags_sky_id = akcia). * Iba zobrazenie – ceny a zľavy určuje Money S5. */ (function () { 'use strict'; if (window.__agsSkyLoaded) return; window.__agsSkyLoaded = true; if (window.agsSkyOff) return; var RAW = window.agsSky; if (!RAW) return; var LIST = Object.prototype.toString.call(RAW) === '[object Array]' ? RAW : [RAW]; var lang = (location.pathname.split('/')[1] || '').toLowerCase(); if (!/^(sk|cz|hu)$/.test(lang)) return; if (!document.querySelector('.header-basic-info h3')) return; // len prihlásený partner if (/(dodacie-udaje|dodaci-udaje|suhrn-objednavky|souhrn-objednavky|szallitas-reszletei|megrendeles-osszesito)/i.test(location.pathname)) return; var NB = String.fromCharCode(160); // nezalomiteľná medzera v dátume function p2(n) { return ('0' + n).slice(-2); } var BASE = { sk: { lab: 'AKCIA ZNAČKY', badge: 'AKCIA', sub: 'na celý sortiment', until: 'Akcia platí do ', cta: 'Pozrieť ponuku', close: 'Zbaliť', last: 'posledný deň akcie', left: function (n) { return n === 1 ? 'zostáva 1 deň' : n < 5 ? 'zostávajú ' + n + ' dni' : 'zostáva ' + n + ' dní'; }, href: '/sk/vysledky-vyhladavania?term=' }, cz: { lab: 'AKCE ZNAČKY', badge: 'AKCE', sub: 'na celý sortiment', until: 'Akce platí do ', cta: 'Zobrazit nabídku', close: 'Sbalit', last: 'poslední den akce', left: function (n) { return n === 1 ? 'zbývá 1 den' : n < 5 ? 'zbývají ' + n + ' dny' : 'zbývá ' + n + ' dní'; }, href: '/cz/vysledky-vyhladavania?term=' }, hu: { lab: 'MÁRKAAKCIÓ', badge: 'AKCIÓ', sub: 'a teljes kínálatra', until: 'Az akció ', cta: 'Megnézem', close: 'Bezárás', last: 'az akció utolsó napja', left: function (n) { return 'még ' + n + ' nap'; }, href: '/hu/keresesi-eredmenyek?term=' } }[lang]; var IMG = 'https://product-images.ags92.com/images/'; // na HU značky skryté pre tohto partnera (skript chicco-hu: window.agsChicco.hide) → akciu nezobraziť function brandHidden(b) { var c = window.agsChicco; return lang === 'hu' && !!c && !!c.on && (c.hide || []).indexOf(b) >= 0; } var now = Date.now(); var CAMPS = []; LIST.forEach(function (C) { if (!C || C.off || !C.id) return; var trhy = C.trhy || ['sk', 'cz', 'hu']; if (trhy.indexOf(lang) < 0) return; var tOd = C.od ? Date.parse(C.od) : 0, tDo = Date.parse(C.do); if (isNaN(tDo) || now > tDo || (tOd && now < tOd)) return; var brand = String(C.znacka || '').toUpperCase(); if (!brand || brandHidden(brand)) return; var END = new Date(tDo); var dEnd = lang === 'hu' ? END.getFullYear() + '.' + NB + p2(END.getMonth() + 1) + '.' + NB + p2(END.getDate()) : END.getDate() + '.' + NB + (END.getMonth() + 1) + '.' + NB + END.getFullYear(); var days = Math.floor((tDo - now) / 86400000); // celé dni do konca (ako odpočet) CAMPS.push({ id: C.id, end: tDo, brand: brand, zlava: C.zlava || '', color: C.farba || '#e2156b', lab: (C.nazov && C.nazov[lang]) || BASE.lab, sub: (C.text && C.text[lang]) || BASE.sub, until: lang === 'hu' ? BASE.until + dEnd + '-ig érvényes' : BASE.until + dEnd, untilHtml: esc(BASE.until) + '' + esc(dEnd + (lang === 'hu' ? '-ig' : '')) + '' + (lang === 'hu' ? ' érvényes' : ''), left: days < 1 ? BASE.last : BASE.left(days), href: (C.odkaz && C.odkaz[lang]) || (BASE.href + encodeURIComponent(C.hladat || brand.toLowerCase())), foto: (C.foto || []).slice(0, 6).map(function (f) { f = String(f); return /^(https?:|[/])/.test(f) ? f : IMG + encodeURIComponent(f) + '.jpg'; }) }); }); if (!CAMPS.length) return; CAMPS.sort(function (a, b) { return a.end - b.end; }); // najskôr končiaca akcia prvá var KEY_MIN = 'agsSky_min'; var ROT_PHOTO = 4000, ROT_CAMP = 12000; function ssGet(k) { try { return sessionStorage.getItem(k); } catch (e) { return null; } } function ssSet(k, v) { try { sessionStorage.setItem(k, v); } catch (e) {} } function esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); } function track(ev, camp, extra) { try { window.dataLayer = window.dataLayer || []; var o = { event: ev, ags_sky_id: camp ? camp.id : '', ags_sky_trh: lang }; for (var k in extra) o[k] = extra[k]; window.dataLayer.push(o); } catch (e) {} } // ---------- vzhľad ---------- var CSS = '' + '.agsky{position:fixed;z-index:900;display:block;text-decoration:none!important;color:#33302d!important;background:#f4ede5;border:1px solid #e6dccf;border-radius:10px;box-shadow:0 6px 22px rgba(40,30,20,.22);overflow:hidden;text-align:center;font-family:inherit;box-sizing:border-box;transform-origin:top center;transition:box-shadow .2s,opacity .35s;cursor:pointer}' + '.agsky *{box-sizing:border-box}' + '.agsky:hover{box-shadow:0 10px 30px rgba(40,30,20,.32)}' + '.agsky.fade{opacity:0}' + '.agsky .k-in{display:flex;flex-direction:column;align-items:center;height:100%}' + '.agsky .k-bar{position:absolute;left:0;right:0;top:0;height:4px;background:var(--agsky-c)}' + '.agsky .k-lab{position:absolute;top:10px;left:10px;font-size:9px;font-weight:600;letter-spacing:.12em;color:#9a9087;line-height:1}' + '.agsky .k-x{position:absolute;top:4px;right:2px;width:26px;height:26px;border:0;background:transparent;color:#8a8078;font:600 17px/26px Arial,sans-serif;cursor:pointer;padding:0;border-radius:50%}' + '.agsky .k-x:hover{background:rgba(0,0,0,.07);color:#33302d}' + '.agsky .k-brand{font-weight:700;letter-spacing:.22em;color:#4a4642;line-height:1;white-space:nowrap}' + '.agsky .k-badge{border-radius:50%;background:var(--agsky-c);color:#fff;display:flex;flex-direction:column;align-items:center;justify-content:center;box-shadow:0 4px 14px rgba(0,0,0,.18);flex:none}' + '.agsky .k-badge small{font-weight:700;letter-spacing:.05em;line-height:1.1}' + '.agsky .k-badge b{white-space:nowrap;font-weight:800;letter-spacing:-.02em;line-height:1}' + '.agsky .k-sub{font-weight:700;line-height:1.25}' + '.agsky .k-ph{position:relative;background:#fff;border-radius:8px;flex:none;overflow:hidden}' + '.agsky .k-ph img{position:absolute;inset:6px;width:calc(100% - 12px);height:calc(100% - 12px);object-fit:contain;opacity:0;transition:opacity .8s}' + '.agsky .k-ph img.on{opacity:1}' + '.agsky .k-until{font-weight:700;line-height:1.3}' + '.agsky .k-cnt{display:inline-block;background:#33302d;color:#fff;border-radius:999px;font-weight:700;line-height:1.2}' + '.agsky .k-cta{display:inline-block;border:2px solid #33302d;border-radius:999px;font-weight:800;color:#33302d;background:#fff;line-height:1.1;white-space:nowrap;transition:background .2s,color .2s}' + '.agsky:hover .k-cta{background:#33302d;color:#fff}' + '.agsky .k-dots{position:absolute;left:0;right:0;bottom:9px;display:flex;justify-content:center;gap:5px}' + '.agsky .k-dots i{width:6px;height:6px;border-radius:50%;background:#d8cdbf}.agsky .k-dots i.on{background:#33302d}' + '.agsky.w300{width:300px;height:600px}' + '.agsky.w300 .k-in{padding:32px 22px 30px}' + '.agsky.w300 .k-brand{font-size:14px;margin-top:4px}' + '.agsky.w300 .k-badge{width:150px;height:150px;margin-top:20px}.agsky.w300 .k-badge small{font-size:13px}.agsky.w300 .k-badge b{font-size:46px;margin-top:2px}' + '.agsky.w300 .k-sub{font-size:19px;margin-top:14px}' + '.agsky.w300 .k-ph{width:226px;height:170px;margin-top:14px}' + '.agsky.w300 .k-until{font-size:15px;margin-top:14px}' + '.agsky.w300 .k-cnt{font-size:12px;padding:5px 12px;margin-top:8px}' + '.agsky.w300 .k-cta{font-size:15px;padding:11px 22px;margin-top:auto}' + '.agsky.w160{width:160px;height:600px}' + '.agsky.w160 .k-in{padding:30px 10px 28px}' + '.agsky.w160 .k-lab{font-size:7.5px;left:8px}' + '.agsky.w160 .k-brand{font-size:11px;letter-spacing:.14em;margin-top:4px}' + '.agsky.w160 .k-badge{width:120px;height:120px;margin-top:20px}.agsky.w160 .k-badge small{font-size:11px}.agsky.w160 .k-badge b{font-size:31px;margin-top:2px}' + '.agsky.w160 .k-sub{font-size:15px;margin-top:14px}' + '.agsky.w160 .k-ph{width:138px;height:176px;margin-top:14px}' + '.agsky.w160 .k-until{font-size:12.5px;margin-top:14px}' + '.agsky.w160 .k-cnt{font-size:11px;padding:4px 10px;margin-top:8px}' + '.agsky.w160 .k-cta{font-size:12.5px;padding:9px 12px;margin-top:auto}' + '.agsky-tab{position:fixed;right:0;z-index:900;width:44px;background:var(--agsky-c);color:#fff;border:0;border-radius:12px 0 0 12px;box-shadow:-3px 3px 14px rgba(0,0,0,.25);cursor:pointer;padding:0;font-family:inherit;transition:width .15s}' + '.agsky-tab:hover,.agsky-tab.act{width:50px}' + '.agsky-tab span{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%) rotate(-90deg);white-space:nowrap;font-weight:800;font-size:13px;letter-spacing:.08em;line-height:1}' + '.agsky.pop{right:58px;transform-origin:top right}' + '@media print{.agsky,.agsky-tab{display:none!important}}' + '@media (prefers-reduced-motion:reduce){.agsky .k-ph img,.agsky,.agsky-tab{transition:none}}'; // obrázky sa načítajú až keď sú na rade (malé náhľady, žiadne zbytočné sťahovanie) function showPhoto(a, k) { var ims = a.querySelectorAll('.k-ph img'); if (!ims.length) return; k = ((k % ims.length) + ims.length) % ims.length; var im = ims[k]; function on() { [].forEach.call(ims, function (x) { x.classList.remove('on'); }); im.classList.add('on'); a.__photo = k; } if (!im.getAttribute('src')) { im.onload = on; im.setAttribute('src', im.getAttribute('data-src')); } else on(); } function card(camp, size, start, dots) { var a = document.createElement('a'); a.className = 'agsky ' + size; a.href = camp.href; a.style.setProperty('--agsky-c', camp.color); a.setAttribute('aria-label', camp.brand + ' ' + camp.zlava + ' ' + camp.sub + ' – ' + camp.until); var imgs = camp.foto.map(function (u) { return ''; }).join(''); var dd = ''; if (dots && dots.n > 1) { for (var i = 0; i < dots.n; i++) dd += ''; dd = '
' + dd + '
'; } a.innerHTML = '
' + esc(camp.lab) + '
' + '
' + esc(camp.brand) + '
' + '
' + esc(BASE.badge) + '' + esc(camp.zlava) + '
' + '
' + esc(camp.sub) + '
' + (camp.foto.length ? '
' + imgs + '
' : '') + '
' + camp.untilHtml + '
' + '
' + esc(camp.left) + '
' + '' + esc(BASE.cta) + ' →
' + dd; a.__camp = camp; a.addEventListener('click', function (e) { if (e.target.closest('.k-x')) { e.preventDefault(); e.stopPropagation(); if (a.classList.contains('pop')) { closePop(); return; } ssSet(KEY_MIN, '1'); track('ags_sky_close', camp, { ags_sky_velkost: size }); layout(true); return; } track('ags_sky_click', camp, { ags_sky_velkost: a.classList.contains('pop') ? 'tab' : size }); }); a.addEventListener('mouseenter', function () { hover = true; }); a.addEventListener('mouseleave', function () { hover = false; }); [].forEach.call(a.querySelectorAll('.k-ph img'), function (im) { im.addEventListener('error', function () { im.parentNode && im.parentNode.removeChild(im); if (!a.querySelector('.k-ph img')) { var ph = a.querySelector('.k-ph'); if (ph) ph.style.display = 'none'; } else showPhoto(a, a.__photo || 0); }); }); if (!camp.foto.length) { var ph0 = a.querySelector('.k-ph'); if (ph0) ph0.style.display = 'none'; } showPhoto(a, start || 0); return a; } // ---------- rozloženie ---------- var els = { L: null, R: null, pop: null }, tabs = [], mode = '', viewed = {}, pair = 0, hover = false; var reduce = window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches; function rm(el) { if (el && el.parentNode) el.parentNode.removeChild(el); } function contW() { var c = document.querySelector('main > .container') || document.querySelector('.container'); return c ? c.getBoundingClientRect().width : 1170; } function topMin() { var nb = document.querySelector('.navbar-fixed-top'); // admin lišta BUXUS return (nb && nb.offsetHeight ? nb.getBoundingClientRect().bottom : 0) + 16; } function pickMode() { var w = document.documentElement.clientWidth || innerWidth; if (w < 768) return 'none'; if (ssGet(KEY_MIN)) return 'tab'; var g = (w - contW()) / 2; if (g >= 316) return 'w300'; if (g >= 172) return 'w160'; return 'tab'; } function scaleFor(h) { return Math.max(0.55, Math.min(1, (innerHeight - topMin() - 16) / h)); } function seen(camp, size) { var k = camp.id + '|' + size; if (!viewed[k]) { viewed[k] = 1; track('ags_sky_view', camp, { ags_sky_velkost: size }); } } function slotCamps() { var n = CAMPS.length; if (n === 1) return [CAMPS[0], CAMPS[0]]; return [CAMPS[pair % n], CAMPS[(pair + 1) % n]]; } function dotsFor(camp) { return CAMPS.length > 2 ? { n: CAMPS.length, k: CAMPS.indexOf(camp) } : null; } function placeSides() { if (mode !== 'w300' && mode !== 'w160') return; var W = mode === 'w300' ? 300 : 160, w = document.documentElement.clientWidth, cw = contW(); var g = (w - cw) / 2, s = scaleFor(600), H = 600 * s; var main = document.querySelector('main') || document.body; var ft = document.querySelector('footer'); var y = Math.max(topMin(), main.getBoundingClientRect().top); if (ft) y = Math.min(y, ft.getBoundingClientRect().top - H - 16); var x = Math.round((g - W) / 2); [['L', x], ['R', w - x - W]].forEach(function (p) { var el = els[p[0]]; if (!el) return; el.style.left = p[1] + 'px'; el.style.top = Math.round(y) + 'px'; el.style.transform = s < 1 ? 'scale(' + s.toFixed(3) + ')' : ''; }); } function buildSides(fadeIn) { var cs = slotCamps(), size = mode; ['L', 'R'].forEach(function (k, i) { var old = els[k]; var nu = card(cs[i], size, cs[0] === cs[1] ? i : 0, dotsFor(cs[i])); if (fadeIn) nu.classList.add('fade'); els[k] = nu; document.body.appendChild(nu); seen(cs[i], size); if (old) { old.classList.add('fade'); setTimeout(function () { rm(old); }, 400); } }); placeSides(); if (fadeIn) setTimeout(function () { ['L', 'R'].forEach(function (k) { if (els[k]) els[k].classList.remove('fade'); }); }, 30); } function placeTabs() { if (!tabs.length) return; var tm = topMin(), gap = 8, fs = 13; function hOf(t) { return Math.round(t.__len * fs * 0.78 + 34); } var total = 0; tabs.forEach(function (t) { total += hOf(t) + gap; }); total -= gap; var avail = innerHeight - tm - 16; if (total > avail) { fs = 11; total = 0; tabs.forEach(function (t) { total += hOf(t) + gap; }); total -= gap; } var y = Math.max(tm, Math.round((innerHeight - total) / 2)); tabs.forEach(function (t) { var h = hOf(t); t.style.top = y + 'px'; t.style.height = h + 'px'; t.firstChild.style.fontSize = fs + 'px'; t.__mid = y + h / 2; y += h + gap; }); if (els.pop) { var s = scaleFor(600), H = 600 * s, t0 = els.pop.__tab; var py = t0 ? t0.__mid - H / 2 : (innerHeight - H) / 2; py = Math.max(tm, Math.min(py, innerHeight - H - 16)); els.pop.style.transform = s < 1 ? 'scale(' + s.toFixed(3) + ')' : ''; els.pop.style.top = Math.round(py) + 'px'; } } function openPop(t) { var same = els.pop && els.pop.__tab === t; closePop(); if (same) return; var p = card(t.__camp, 'w300', 0, null); p.classList.add('pop'); p.__tab = t; els.pop = p; t.classList.add('act'); document.body.appendChild(p); placeTabs(); seen(t.__camp, 'tab'); } function closePop() { if (els.pop) { if (els.pop.__tab) els.pop.__tab.classList.remove('act'); rm(els.pop); els.pop = null; } } function clearAll() { rm(els.L); rm(els.R); els.L = els.R = null; closePop(); tabs.forEach(rm); tabs = []; } function layout(force) { var m = pickMode(); if (m === mode && !force) { placeSides(); placeTabs(); return; } mode = m; clearAll(); if (m === 'none') return; if (m === 'tab') { CAMPS.forEach(function (camp) { var b = document.createElement('button'); var label = camp.brand + ' ' + camp.zlava; b.type = 'button'; b.className = 'agsky-tab'; b.style.setProperty('--agsky-c', camp.color); b.setAttribute('aria-label', label); b.innerHTML = '' + esc(label) + ''; b.__camp = camp; b.__len = label.length; b.addEventListener('click', function (e) { e.stopPropagation(); openPop(b); }); tabs.push(b); document.body.appendChild(b); }); placeTabs(); return; } buildSides(false); } function tickPhotos() { if (reduce || document.hidden || hover) return; [els.L, els.R, els.pop].forEach(function (a) { if (a) showPhoto(a, (a.__photo || 0) + 1); }); } function tickCamps() { if (reduce || document.hidden || hover || CAMPS.length < 3) return; if (mode !== 'w300' && mode !== 'w160') return; pair = (pair + 2) % CAMPS.length; buildSides(true); } function start() { var st = document.createElement('style'); st.id = 'agsky-css'; st.textContent = CSS; document.head.appendChild(st); layout(true); var raf = 0; window.addEventListener('scroll', function () { if (raf) return; raf = requestAnimationFrame(function () { raf = 0; placeSides(); }); }, { passive: true }); var rt = 0; window.addEventListener('resize', function () { clearTimeout(rt); rt = setTimeout(function () { layout(false); }, 120); }); document.addEventListener('click', function (e) { if (els.pop && !e.target.closest('.agsky.pop,.agsky-tab')) closePop(); }); document.addEventListener('keydown', function (e) { if (e.key === 'Escape') closePop(); }); setInterval(tickPhotos, ROT_PHOTO); setInterval(tickCamps, ROT_CAMP); // koniec akcie počas otvorenej stránky → vyradiť ju setInterval(function () { var t = Date.now(), n = CAMPS.length; CAMPS = CAMPS.filter(function (c) { return t <= c.end; }); if (CAMPS.length !== n) { pair = 0; if (CAMPS.length) layout(true); else { mode = 'none'; clearAll(); } } }, 60000); } // štart až po načítaní stránky a v chvíli nečinnosti – nezdrží obsah ani ceny partnera function later() { if (window.requestIdleCallback) requestIdleCallback(start, { timeout: 1500 }); else setTimeout(start, 200); } if (document.readyState === 'complete') later(); else window.addEventListener('load', later); })();