/* * AGS 92 B2B – bočné mrakodrapy (skyscraper) pre akciu značky * Súbor: /buxus/docs/mrakodrap2.js.txt (v2, 9. 10. 2026), načítaný v pätičke (Container 22 → Content after) * v2: fotky sa načítajú hneď (v1 mala loading=lazy – v rozbalenej karte ostal biely rámik) * * Nastavenie (bez zásahu do kódu) – riadok v Container 22 PRED týmto skriptom: * * - od / do = začiatok a koniec akcie; mimo tohto času sa nič nevykreslí (po skončení netreba nič mazať hneď) * - trhy = na ktorých trhoch sa zobrazí (vynechať trh = vypnúť ho); off: true = vypnúť všetko * - foto = kódy produktov (obrázok z product-images.ags92.com), striedajú sa * - hladat = výraz pre vyhľadávanie, kam vedie klik (alebo odkaz: { sk: '/sk/…', cz: …, hu: … }) * - text = (voliteľné) iný podnadpis, napr. text: { sk: 'na vybrané kočíky', cz: '…', hu: '…' } * * Zobrazenie podľa šírky okna (voľný okraj vedľa obsahu 1170 px): * okraj ≥ 316 px → 2 mrakodrapy 300 × 600 vľavo a vpravo * okraj ≥ 172 px → 2 úzke mrakodrapy 160 × 600 * menej (notebooky) → záložka 44 px na pravom okraji, klik rozbalí kartu 300 px * pod 768 px (mobil) → nič * Krížik na mrakodrape ho zbalí do záložky (do zatvorenia prehliadača). Len prihlásený partner SK/CZ/HU, * nie v krokoch objednávky (Dodacie údaje, Súhrn). Meranie: dataLayer udalosti ags_sky_view / ags_sky_click. * Iba zobrazenie – ceny a zľavy určuje Money S5. */ (function () { 'use strict'; if (window.__agsSkyLoaded) return; window.__agsSkyLoaded = true; var C = window.agsSky; if (!C || C.off || !C.id) return; var lang = (location.pathname.split('/')[1] || '').toLowerCase(); var trhy = C.trhy || ['sk', 'cz', 'hu']; if (!/^(sk|cz|hu)$/.test(lang) || trhy.indexOf(lang) < 0) 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 now = Date.now(); var tOd = C.od ? Date.parse(C.od) : 0, tDo = Date.parse(C.do); if (isNaN(tDo) || now > tDo || (tOd && now < tOd)) return; // ---------- texty ---------- var END = new Date(tDo); function p2(n) { return ('0' + n).slice(-2); } var NB = String.fromCharCode(160); // dátum sa nezalomí (nezalomiteľná medzera) var dSkCz = END.getDate() + '.' + NB + (END.getMonth() + 1) + '.' + NB + END.getFullYear(); var dHu = END.getFullYear() + '.' + NB + p2(END.getMonth() + 1) + '.' + NB + p2(END.getDate()); var UI = { sk: { lab: 'AKCIA ZNAČKY', badge: 'AKCIA', sub: 'na celý sortiment', until: 'Akcia platí do ' + dSkCz, 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 ' + dSkCz, 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ó ' + dHu + '-ig érvényes', 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]; if (C.text && C.text[lang]) UI.sub = C.text[lang]; var BRAND = String(C.znacka || '').toUpperCase(); var ZLAVA = C.zlava || ''; var HREF = (C.odkaz && C.odkaz[lang]) || (UI.href + encodeURIComponent(C.hladat || BRAND.toLowerCase())); // zostávajúce kalendárne dni vrátane dneška var t0 = new Date(); t0.setHours(0, 0, 0, 0); var e0 = new Date(END.getTime()); e0.setHours(0, 0, 0, 0); var DAYS = Math.round((e0 - t0) / 86400000) + 1; var LEFT = DAYS <= 1 ? UI.last : UI.left(DAYS); var FOTO = (C.foto || []).slice(0, 6); var IMG = 'https://product-images.ags92.com/images/'; var KEY_MIN = 'agsSky_min_' + C.id; 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, extra) { try { window.dataLayer = window.dataLayer || []; var o = { event: ev, ags_sky_id: C.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 .25s;cursor:pointer}' + '.agsky *{box-sizing:border-box}' + '.agsky:hover{box-shadow:0 10px 30px rgba(40,30,20,.32)}' + '.agsky .k-in{display:flex;flex-direction:column;align-items:center;height:100%}' + '.agsky .k-lab{position:absolute;top:8px;left:10px;font-size:9px;font-weight:600;letter-spacing:.12em;color:#9a9087;line-height:1}' + '.agsky .k-x{position:absolute;top:2px;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:#e2156b;color:#fff;display:flex;flex-direction:column;align-items:center;justify-content:center;box-shadow:0 4px 14px rgba(226,21,107,.35);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.w300{width:300px;height:600px}' + '.agsky.w300 .k-in{padding:32px 22px 26px}' + '.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 22px}' + '.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;height:210px;background:#e2156b;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{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:56px;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}}'; function card(size, start) { var a = document.createElement('a'); a.className = 'agsky ' + size; a.href = HREF; a.setAttribute('aria-label', BRAND + ' ' + ZLAVA + ' ' + UI.sub + ' – ' + UI.until); var imgs = FOTO.map(function (c, i) { return ''; }).join(''); a.innerHTML = '
' + esc(UI.lab) + '
' + '
' + esc(BRAND) + '
' + '
' + esc(UI.badge) + '' + esc(ZLAVA) + '
' + '
' + esc(UI.sub) + '
' + (FOTO.length ? '
' + imgs + '
' : '') + '
' + esc(UI.until) + '
' + '
' + esc(LEFT) + '
' + '' + esc(UI.cta) + ' →
'; a.__start = start || 0; 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', { ags_sky_velkost: size }); layout(true); return; } track('ags_sky_click', { ags_sky_velkost: a.classList.contains('pop') ? 'tab' : size }); }); // obrázky: chybné vyradiť, ostatné striedať [].forEach.call(a.querySelectorAll('.k-ph img'), function (im) { im.addEventListener('error', function () { im.parentNode && im.parentNode.removeChild(im); fixPhoto(a); }); }); fixPhoto(a); return a; } function fixPhoto(a) { var ims = a.querySelectorAll('.k-ph img'); if (!ims.length) { var ph = a.querySelector('.k-ph'); if (ph) ph.style.display = 'none'; return; } var on = a.querySelector('.k-ph img.on'); if (!on) ims[(a.__start || 0) % ims.length].classList.add('on'); } var reduce = window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches; function rotate() { if (reduce || document.hidden) return; [].forEach.call(document.querySelectorAll('.agsky'), function (a) { var ims = a.querySelectorAll('.k-ph img'); if (ims.length < 2) return; var k = 0; for (var i = 0; i < ims.length; i++) if (ims[i].classList.contains('on')) { k = i; ims[i].classList.remove('on'); } ims[(k + 1) % ims.length].classList.add('on'); }); } // ---------- rozloženie ---------- var els = { L: null, R: null, tab: null, pop: null }, mode = '', viewed = {}; function remove(k) { if (els[k]) { els[k].parentNode && els[k].parentNode.removeChild(els[k]); els[k] = null; } } function contW() { var c = document.querySelector('main > .container') || document.querySelector('.container'); return c ? c.getBoundingClientRect().width : 1170; } function topMin() { // admin lišta BUXUS (fixed hore) – mrakodrap pod ňou var nb = document.querySelector('.navbar-fixed-top'); 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) { var avail = innerHeight - topMin() - 16; return Math.max(0.55, Math.min(1, avail / h)); } function place() { 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 top = Math.max(topMin(), main.getBoundingClientRect().top); if (ft) top = Math.min(top, 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(top) + 'px'; el.style.transform = s < 1 ? 'scale(' + s.toFixed(3) + ')' : ''; }); } function placeTab() { if (!els.tab) return; var tm = topMin(); els.tab.style.top = Math.max(tm, Math.round(innerHeight / 2 - 105)) + 'px'; if (els.pop) { var s = scaleFor(600); els.pop.style.transform = s < 1 ? 'scale(' + s.toFixed(3) + ')' : ''; els.pop.style.top = Math.max(tm, Math.round((innerHeight - 600 * s) / 2)) + 'px'; } } function openPop() { if (els.pop) return closePop(); els.pop = card('w300', 0); els.pop.classList.add('pop'); document.body.appendChild(els.pop); placeTab(); track('ags_sky_view', { ags_sky_velkost: 'tab' }); } function closePop() { remove('pop'); } function layout(force) { var m = pickMode(); if (m === mode && !force) { place(); placeTab(); return; } mode = m; remove('L'); remove('R'); remove('tab'); remove('pop'); if (m === 'none') return; if (m === 'tab') { var b = document.createElement('button'); b.type = 'button'; b.className = 'agsky-tab'; b.setAttribute('aria-label', BRAND + ' ' + ZLAVA); b.innerHTML = '' + esc(BRAND + ' ' + ZLAVA) + ''; b.addEventListener('click', function (e) { e.stopPropagation(); openPop(); }); els.tab = b; document.body.appendChild(b); placeTab(); return; } els.L = card(m, 0); els.R = card(m, 1); document.body.appendChild(els.L); document.body.appendChild(els.R); place(); if (!viewed[m]) { viewed[m] = 1; track('ags_sky_view', { ags_sky_velkost: m }); } } function start() { var st = document.createElement('style'); st.id = 'agsky-css'; st.textContent = CSS; document.head.appendChild(st); layout(true); var raf = 0; function onScroll() { if (raf) return; raf = requestAnimationFrame(function () { raf = 0; place(); }); } window.addEventListener('scroll', onScroll, { 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(rotate, 4000); // koniec akcie počas otvorenej stránky → zmiznúť setInterval(function () { if (Date.now() > tDo) { mode = 'none'; remove('L'); remove('R'); remove('tab'); remove('pop'); } }, 60000); } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); else start(); })();