PageSourceSearch

https://cglobal.imn.ac.cr/wp-content/themes/imn-cglobal-modern/assets/js/theme.js?ver=1.0.3.1780167345

js imn.ac.cr collected 2026-10-02 04:01:28 UTC 2,556 bytes, 80 lines download raw bytes

1(function () {
2  document.documentElement.classList.add('js');
3
4  function isGalleryImageLink(link) {
5    if (!link || !link.closest('.entry-content')) {
6      return false;
7    }
8
9    return /\.(jpe?g|png|gif|webp)(\?.*)?$/i.test(link.getAttribute('href') || '');
10  }
11
12  function ensureLightbox() {
13    var existing = document.querySelector('.cglobal-lightbox');
14    if (existing) {
15      return existing;
16    }
17
18    var lightbox = document.createElement('div');
19    lightbox.className = 'cglobal-lightbox';
20    lightbox.setAttribute('role', 'dialog');
21    lightbox.setAttribute('aria-modal', 'true');
22    lightbox.setAttribute('aria-label', 'Imagen ampliada');
23    lightbox.innerHTML = '<button class="cglobal-lightbox-close" type="button" aria-label="Cerrar imagen">&times;</button><img alt="">';
24    document.body.appendChild(lightbox);
25    return lightbox;
26  }
27
28  function closeLightbox() {
29    var lightbox = document.querySelector('.cglobal-lightbox.is-open');
30    if (!lightbox) {
31      return;
32    }
33
34    lightbox.classList.remove('is-open');
35    document.body.classList.remove('cglobal-lightbox-open');
36    var image = lightbox.querySelector('img');
37    image.removeAttribute('src');
38    image.removeAttribute('style');
39  }
40
41  function fitLightboxImage(image) {
42    var maxWidth = window.innerWidth - 72;
43    var maxHeight = window.innerHeight - 92;
44    var naturalWidth = image.naturalWidth || maxWidth;
45    var naturalHeight = image.naturalHeight || maxHeight;
46    var scale = Math.min(maxWidth / naturalWidth, maxHeight / naturalHeight, 2.2);
47
48    image.style.width = Math.max(1, Math.round(naturalWidth * scale)) + 'px';
49    image.style.height = 'auto';
50  }
51
52  document.addEventListener('click', function (event) {
53    var imageLink = event.target.closest('a');
54
55    if (isGalleryImageLink(imageLink)) {
56      event.preventDefault();
57      var lightbox = ensureLightbox();
58      var image = lightbox.querySelector('img');
59      image.src = imageLink.href;
60      image.alt = imageLink.querySelector('img') ? imageLink.querySelector('img').alt : '';
61      image.onload = function () {
62        fitLightboxImage(image);
63      };
64      lightbox.classList.add('is-open');
65      document.body.classList.add('cglobal-lightbox-open');
66      lightbox.querySelector('button').focus();
67      return;
68    }
69
70    if (event.target.matches('.cglobal-lightbox, .cglobal-lightbox-close')) {
71      closeLightbox();
72    }
73  });
74
75  document.addEventListener('keydown', function (event) {
76    if (event.key === 'Escape') {
77      closeLightbox();
78    }
79  });
80}());

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.