PageSourceSearch

https://www.valasskezpravy.cz/wp-content/uploads/custom-css-js/12312.js?v=8278

js valasskezpravy.cz collected 2026-09-25 11:11:33 UTC 7,030 bytes, 226 lines download raw bytes

1/******* Do not edit this file *******
2Simple Custom CSS and JS - by Silkypress.com
3Saved: Feb 16 2026 | 19:08:24 */
4
5(function () {
6  const GALLERY_SELECTOR = '.gallery';
7  const LINK_SELECTOR = '.gallery .gallery-icon a[href]';
8
9  function qs(sel, root = document) { return root.querySelector(sel); }
10  function qsa(sel, root = document) { return Array.from(root.querySelectorAll(sel)); }
11
12  // Remove WP clear <br> that can disturb layout (safe even with CSS hiding)
13  function cleanupGallery(galleryEl) {
14    qsa('br', galleryEl).forEach((br) => {
15      const style = (br.getAttribute('style') || '').toLowerCase();
16      if (style.includes('clear')) br.remove();
17    });
18  }
19
20  // Build lightbox once
21  function createLightbox() {
22    const overlay = document.createElement('div');
23    overlay.className = 'wpglb-overlay';
24    overlay.setAttribute('role', 'dialog');
25    overlay.setAttribute('aria-modal', 'true');
26    overlay.setAttribute('aria-label', 'Image viewer');
27    overlay.tabIndex = -1;
28
29    overlay.innerHTML = `
30      <button class="wpglb-btn wpglb-close" type="button" aria-label="Close (Esc)">×</button>
31      <button class="wpglb-btn wpglb-prev" type="button" aria-label="Previous (Left arrow)">‹</button>
32
33      <figure class="wpglb-figure" aria-live="polite">
34        <img class="wpglb-img" alt="" />
35        <figcaption class="wpglb-caption"></figcaption>
36      </figure>
37
38      <button class="wpglb-btn wpglb-next" type="button" aria-label="Next (Right arrow)">›</button>
39    `;
40
41    const style = document.createElement('style');
42    style.textContent = `
43      .wpglb-overlay {
44        position: fixed;
45        inset: 0;
46        z-index: 999999;
47        background: rgba(0,0,0,0.86);
48        display: none;
49        align-items: center;
50        justify-content: center;
51        padding: 24px;
52      }
53      .wpglb-overlay.is-open { display: flex; }
54      .wpglb-figure {
55        margin: 0;
56        max-width: min(1100px, 100%);
57        max-height: 100%;
58        display: grid;
59        gap: 12px;
60        justify-items: center;
61      }
62      .wpglb-img {
63        max-width: 100%;
64        max-height: calc(100vh - 140px);
65        width: auto;
66        height: auto;
67        border-radius: 12px;
68        box-shadow: 0 20px 60px rgba(0,0,0,0.45);
69        background: rgba(255,255,255,0.06);
70      }
71      .wpglb-caption {
72        color: rgba(255,255,255,0.92);
73        font-size: 14px;
74        line-height: 1.35;
75        text-align: center;
76        max-width: 900px;
77      }
78      .wpglb-caption:empty { display: none; }
79      .wpglb-btn {
80        position: absolute;
81        top: 50%;
82        transform: translateY(-50%);
83        border: 0;
84        background: rgba(255,255,255,0.12);
85        color: #fff;
86        width: 44px;
87        height: 44px;
88        border-radius: 999px;
89        cursor: pointer;
90        display: grid;
91        place-items: center;
92        font-size: 28px;
93        line-height: 1;
94        user-select: none;
95      }
96      .wpglb-btn:hover { background: rgba(255,255,255,0.20); }
97      .wpglb-close {
98        top: 22px;
99        right: 22px;
100        transform: none;
101        font-size: 28px;
102      }
103      .wpglb-prev { left: 18px; }
104      .wpglb-next { right: 18px; }
105      @media (max-width: 700px) {
106        .wpglb-prev, .wpglb-next { top: auto; bottom: 20px; transform: none; }
107        .wpglb-prev { left: 20px; }
108        .wpglb-next { right: 20px; }
109      }
110    `;
111
112    document.head.appendChild(style);
113    document.body.appendChild(overlay);
114
115    return {
116      overlay,
117      img: qs('.wpglb-img', overlay),
118      caption: qs('.wpglb-caption', overlay),
119      btnClose: qs('.wpglb-close', overlay),
120      btnPrev: qs('.wpglb-prev', overlay),
121      btnNext: qs('.wpglb-next', overlay),
122    };
123  }
124
125  const lb = createLightbox();
126
127  let currentGalleryLinks = [];
128  let currentIndex = 0;
129  let lastActiveEl = null;
130
131  function getCaptionFromLink(linkEl) {
132    const img = qs('img', linkEl);
133    if (!img) return '';
134    return (img.getAttribute('alt') || '').trim();
135  }
136
137  function showIndex(idx) {
138    if (!currentGalleryLinks.length) return;
139    currentIndex = (idx + currentGalleryLinks.length) % currentGalleryLinks.length;
140
141    const link = currentGalleryLinks[currentIndex];
142    const href = link.getAttribute('href');
143
144    // set src
145    lb.img.src = href;
146    lb.img.alt = getCaptionFromLink(link);
147
148    // caption
149    lb.caption.textContent = getCaptionFromLink(link);
150
151    // preload neighbours
152    const next = currentGalleryLinks[(currentIndex + 1) % currentGalleryLinks.length]?.getAttribute('href');
153    const prev = currentGalleryLinks[(currentIndex - 1 + currentGalleryLinks.length) % currentGalleryLinks.length]?.getAttribute('href');
154    [next, prev].filter(Boolean).forEach((u) => {
155      const i = new Image();
156      i.src = u;
157    });
158  }
159
160  function openLightbox(fromLinkEl) {
161    lastActiveEl = document.activeElement;
162
163    const gallery = fromLinkEl.closest(GALLERY_SELECTOR);
164    currentGalleryLinks = qsa(LINK_SELECTOR, gallery);
165    currentIndex = Math.max(0, currentGalleryLinks.indexOf(fromLinkEl));
166
167    lb.overlay.classList.add('is-open');
168    document.documentElement.style.overflow = 'hidden';
169
170    showIndex(currentIndex);
171    lb.overlay.focus();
172  }
173
174  function closeLightbox() {
175    lb.overlay.classList.remove('is-open');
176    document.documentElement.style.overflow = '';
177
178    // cleanup image to stop downloading if needed
179    lb.img.src = '';
180    lb.caption.textContent = '';
181
182    if (lastActiveEl && typeof lastActiveEl.focus === 'function') {
183      lastActiveEl.focus();
184    }
185  }
186
187  function onKeyDown(e) {
188    if (!lb.overlay.classList.contains('is-open')) return;
189
190    if (e.key === 'Escape') {
191      e.preventDefault();
192      closeLightbox();
193    } else if (e.key === 'ArrowRight') {
194      e.preventDefault();
195      showIndex(currentIndex + 1);
196    } else if (e.key === 'ArrowLeft') {
197      e.preventDefault();
198      showIndex(currentIndex - 1);
199    }
200  }
201
202  // Delegated click: open only for gallery links
203  document.addEventListener('click', (e) => {
204    const link = e.target.closest(LINK_SELECTOR);
205    if (!link) return;
206
207    e.preventDefault();
208    openLightbox(link);
209  });
210
211  // Overlay click to close (only if background clicked, not figure/buttons)
212  lb.overlay.addEventListener('click', (e) => {
213    const isFigure = e.target.closest('.wpglb-figure');
214    const isButton = e.target.closest('.wpglb-btn');
215    if (!isFigure && !isButton) closeLightbox();
216  });
217
218  lb.btnClose.addEventListener('click', closeLightbox);
219  lb.btnNext.addEventListener('click', () => showIndex(currentIndex + 1));
220  lb.btnPrev.addEventListener('click', () => showIndex(currentIndex - 1));
221
222  document.addEventListener('keydown', onKeyDown);
223
224  // Initial cleanup
225  qsa(GALLERY_SELECTOR).forEach(cleanupGallery);
226})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.