PageSourceSearch

https://www.kirmus.ee/themes/ekm/js/app.js?tlru2n

js kirmus.ee collected 2026-10-01 10:36:23 UTC 13,782 bytes, 470 lines download raw bytes

1(function ($) {
2  var App = (function () {
3    function headerFixedScroll() {
4      var $header = $(".layout__header__container");
5      var loggedIn = $('.user-logged-in').length;
6
7      if ($header.scrollTop() > 0) {
8        if (!$header.hasClass("u-fixed")) {
9          $header.addClass("u-fixed");
10        }
11      }
12
13      $(window).on("scroll", function () {
14        if ($(this).scrollTop() > 0) {
15          if (!$header.hasClass("u-fixed")) {
16            $header.addClass("u-fixed");
17          }
18        } else {
19          if ($header.hasClass("u-fixed")) {
20            $header.removeClass("u-fixed");
21          }
22        }
23      });
24    }
25
26    function menuSidebarScroll() {
27      $(".menu--sidebar a").on("click", function (e) {
28        scrollToContent(e.target);
29      });
30
31      $('.view-employees a[href^="#"]').on("click", function (e) {
32        scrollToContent(e.target);
33      });
34
35      // $('.view-exhibitions a[href^="#"]').on('click', function(e) {
36      //   scrollToContent(e.target);
37      // });
38
39      function scrollToContent(obj) {
40        if (
41          location.pathname.replace(/^\//, "") ==
42          obj.pathname.replace(/^\//, "") &&
43          location.hostname == obj.hostname
44        ) {
45          var target = $(obj.hash);
46          target = target.length
47            ? target
48            : $("[id=" + encodeURIComponent(obj.hash.slice(1)) + "]");
49
50          var userLoggedIn = $('.user-logged-in').length;
51          var offset = userLoggedIn ? 210 : 130;
52
53          if (target.length) {
54            event.preventDefault();
55            $("html, body").animate(
56              {
57                scrollTop: target.offset().top - offset
58              },
59              500,
60              function () {
61                var $target = $(target);
62
63                if ($target.is(":focus")) {
64                  return false;
65                } else {
66                  $target.attr("tabindex", "-1");
67                }
68              }
69            );
70
71            if (target.offsetTop <= target.scrollY && target.offsetTop + target.offsetHeight > target.scrollY) {
72              $(obj).addClass("current");
73            } else {
74              $(obj).removeClass("current");
75            }
76          }
77        }
78      }
79    }
80
81    function initEmployeesAnchors() {
82      if ($('.view-employees').length) {
83        var $anchors = $('.view-employees h3');
84        $.each($anchors, function () {
85          $(this).attr('id', $(this).text().trim().replace(/\s/g, '-'));
86        });
87      }
88    }
89
90    function initExhibitionsAnchors() {
91      if ($('.view-exhibitions').length) {
92        var $anchors = $('.view-exhibitions .node--type-exhibition > h2');
93        $.each($anchors, function () {
94          $(this).attr('id', $(this).text().trim()
95            .replace(/"/g, '')
96            .replace(/\s/g, '-')
97            .replace(/,/g, ''));
98        });
99      }
100    }
101
102    function departmentsSlider() {
103      $(document).ready(function () {
104        if ($('.departments-slider').length) {
105          $('.departments-slider .view-content').flexslider({
106            animation: 'slide',
107            selector: '.slides > .views-row',
108            slideshowSpeed: 4000
109          });
110        }
111      });
112    }
113
114    function closeAccessibilityPanel() {
115      $('.u-accessibility-drop').slideUp(200);
116
117      if ($(window).width() <= 768) {
118        $('.block-we-accessibility').removeClass('u-visible');
119      }
120    }
121
122    function initAccessibilityClose() {
123
124      // close button
125      $('.u-accessibility-close').on('click', function () {
126        closeAccessibilityPanel();
127      });
128
129      // outside click
130      $(document).on('click', function (e) {
131        if (
132          $('.u-accessibility-drop').is(':visible') &&
133          !$(e.target).closest('.u-accessibility-drop, [data-accessibility-toggle]').length
134        ) {
135          closeAccessibilityPanel();
136        }
137      });
138
139      // ESC key
140      $(document).on('keydown', function (e) {
141        if (
142          e.key === 'Escape' &&
143          $('.u-accessibility-drop').is(':visible')
144        ) {
145          closeAccessibilityPanel();
146        }
147      });
148
149    }
150
151    function initMobileMenu() {
152      moveMenus();
153      moveFrontpageSearch();
154
155      $(window).on('resize', function () {
156        moveMenus();
157        moveFrontpageSearch();
158      });
159    }
160
161    function moveMenus() {
162      var $mainMenu = $('#block-pohinavigatsioon');
163      var $langMenu = $('.language-switcher-language-url');
164      var $mobileMenu = $('.menu--mobile');
165      var $pageHead = $('.layout__pagehead');
166      var $accessibility = $('#block-accessibilityblock');
167      var windowWidth = window.innerWidth || $(window).width();
168
169      var $anchor = $('#main-menu-anchor');
170
171      if (!$anchor.length) {
172        $mainMenu.before('<div id="main-menu-anchor"></div>');
173        $anchor = $('#main-menu-anchor');
174      }
175
176      if (windowWidth <= 1150) {
177
178        if (!$mainMenu.parent().is('.menu--mobile')) {
179          $mobileMenu.append($mainMenu);
180        }
181
182      } else {
183
184        // Reset mobile menu state
185        $mobileMenu.removeAttr('style');
186
187        $('body').removeClass('u-mobile-menu-open');
188
189        $('.u-toggle-menu i')
190          .removeClass('fa-times')
191          .addClass('fa-bars');
192
193        // Move menu back to desktop
194        if ($mainMenu.parent().is('.menu--mobile')) {
195          $anchor.after($mainMenu);
196        }
197      }
198    }
199
200    function moveFrontpageSearch() {
201      var $accessibility = $('#block-accessibilityblock');
202      var $search = $('.block-we-search-block');
203      var $pageHead = $('.layout__pagehead--front');
204      var $header = $('.layout__header--front');
205      var windowWidth = window.innerWidth || $(window).width();
206    }
207
208    function toggleMobileMenu() {
209      var $mobileMenu = $('.menu--mobile');
210      var $menuToggle = $('.u-toggle-menu');
211      var windowWidth = window.innerWidth || $(window).width();
212
213      $menuToggle.on('click', function () {
214        $mobileMenu.slideToggle('fast');
215        $(this).children('i').toggleClass('icon-menu fal fa-times');
216        $('body').toggleClass('u-mobile-menu-open');
217      });
218
219      $(document).on('click', function (e) {
220        if (
221          $('body').hasClass('u-mobile-menu-open') &&
222          !$(e.target).closest('.menu--mobile, .u-toggle-menu').length
223        ) {
224          $('body').removeClass('u-mobile-menu-open');
225          $('.menu--mobile').slideUp('fast');
226
227          $('.u-toggle-menu i')
228            .removeClass('fa-times')
229            .addClass('fa-bars');
230        }
231      });
232
233      $(document).on('keydown', function (e) {
234        if (
235          e.key === 'Escape' &&
236          $('body').hasClass('u-mobile-menu-open')
237        ) {
238          $('body').removeClass('u-mobile-menu-open');
239          $('.menu--mobile').slideUp('fast');
240
241          $('.u-toggle-menu i')
242            .removeClass('fa-times')
243            .addClass('fa-bars');
244        }
245      });
246    }
247
248    function toggleSubMenu() {
249      $('.u-submenu-toggle').on('click', function (e) {
250        $(this).next('.menu').slideToggle('fast');
251        $(this).children('i').toggleClass('fa-chevron-down fa-chevron-up');
252      });
253    }
254
255    function printServices() {
256      $('.print-list').on('click', function (e) {
257        e.preventDefault();
258        var cssPath = drupalSettings.path.baseUrl + 'themes/ekm/css/main.css';
259        $('.view-services .view-content').printThis({
260          loadCSS: cssPath,
261          header: '<h1>Ekskursioonid</h1>',
262          printDelay: 1000
263        });
264      });
265    }
266
267    function setSearchKeysToInput() {
268      if ($('.path-search').length) {
269        var url = new URL(window.location.href);
270        var params = url.searchParams.get('keys');
271        var $search = $('.form-search#edit-keys');
272
273        $search.val(params);
274      }
275    }
276
277    return {
278      init: function () {
279        headerFixedScroll();
280        menuSidebarScroll();
281        departmentsSlider();
282        initEmployeesAnchors();
283        initExhibitionsAnchors();
284        closeAccessibilityPanel();
285        initAccessibilityClose();
286        initMobileMenu();
287        toggleMobileMenu();
288        toggleSubMenu();
289        printServices();
290        setSearchKeysToInput();
291      }
292    };
293  })();
294
295  App.init();
296})(jQuery);
297
298/* Mine üles nupp - Ilona */
299window.onscroll = function () {
300  scrollFunction();
301  scrollFunction2();
302};
303/* SCROLL UP BUTTON */
304function scrollFunction2() {
305  if (document.body.scrollTop > 750 || document.documentElement.scrollTop > 750) {
306    document.getElementById("myBtn").style.display = "block";
307  } else {
308    document.getElementById("myBtn").style.display = "none";
309  }
310}
311// When the user clicks on the button, scroll to the top of the document
312function topFunction() {
313  document.body.scrollTop = 0; // For Safari
314  document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
315}
316/* SCROLL DOWN BUTTON */
317function scrollFunction() {
318  if (document.body.scrollTop > 750 || document.documentElement.scrollTop > 750) {
319    document.getElementById("myBtn2").style.display = "block";
320  } else {
321    document.getElementById("myBtn2").style.display = "none";
322  }
323}
324// When the user clicks on the button, scroll to the top of the document
325function botFunction() {
326  document.body.scrollTop = 500000; // For Safari
327  document.documentElement.scrollTop = 500000; // For Chrome, Firefox, IE and Opera
328}
329/*Mine üles nupu lõpp - Ilona*/
330/**/
331/* News Archive Menu active button*/
332// Function to get URL parameters
333function getParameterByName(name, url) {
334  if (!url) url = window.location.href;
335  name = name.replace(/[\[\]]/g, '\\$&');
336  var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
337    results = regex.exec(url);
338  if (!results) return null;
339  if (!results[2]) return '';
340  return decodeURIComponent(results[2].replace(/\+/g, ' '));
341}
342
343// Get the value of the 'param' URL parameter
344var paramValue = getParameterByName('y');
345
346// Function to set the active class on the appropriate link
347function setActiveLink(paramValue) {
348  var links = document.querySelectorAll('.attachment-news a');
349  links.forEach(function (link) {
350    var href = link.getAttribute('href');
351    if (href && href.includes(paramValue)) {
352      link.classList.add('active-param');
353    }
354  });
355}
356
357// Call the setActiveLink function with the paramValue
358setActiveLink(paramValue);
359
360/* COOKIE CONSENT */
361// Function to set a cookie
362function setCookie(name, value, days) {
363  var expires = "";
364  if (days) {
365    var date = new Date();
366    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
367    expires = "; expires=" + date.toUTCString();
368  }
369  document.cookie = name + "=" + (value || "") + expires + "; path=/";
370}
371
372// Function to get a cookie
373function getCookie(name) {
374  var nameEQ = name + "=";
375  var ca = document.cookie.split(';');
376  for (var i = 0; i < ca.length; i++) {
377    var c = ca[i];
378    while (c.charAt(0) == ' ') {
379      c = c.substring(1, c.length);
380    }
381    if (c.indexOf(nameEQ) == 0) {
382      return c.substring(nameEQ.length, c.length);
383    }
384  }
385  return null;
386}
387
388// Function to check if user has accepted cookies
389function checkCookie() {
390  var cookieAccepted = getCookie("cookieConsent");
391  if (!cookieAccepted) {
392    document.getElementById("cookieConsent").style.display = "block";
393  }
394}
395
396// Function to accept cookies
397function acceptCookies() {
398  setCookie("cookieConsent", true, 90); // Set the cookie to expire in 90 days
399  document.getElementById("cookieConsent").style.display = "none";
400}
401
402// Check if the user has already accepted cookies
403checkCookie();
404
405/* avalehe kalender */
406document.addEventListener("DOMContentLoaded", function () {
407  function addClassToRows() {
408    var trElements = document.querySelectorAll(".fc-content-skeleton table tr");
409    for (var i = 0; i < trElements.length - 1; i++) {
410      var currentTr = trElements[i];
411      var nextTr = trElements[i + 1];
412      if (nextTr && currentTr.parentNode === nextTr.parentNode) {
413        currentTr.classList.add("at-least-two-tr");
414        nextTr.classList.add("at-least-two-tr");
415      }
416    }
417  }
418
419  addClassToRows(); // Initial run for elements present at load
420
421  var observer = new MutationObserver(addClassToRows);
422
423  var config = { childList: true, subtree: true };
424  observer.observe(document.body, config);
425});
426
427/* Add expanded class for search */
428const form = document.querySelector('#we-search-block-form');
429const searchContainer = document.querySelector('.search-block-form');
430const searchInput = form?.querySelector('input[type="search"]');
431const submitButton = form?.querySelector('input[type="submit"]');
432
433// create the 'x' icon
434const xIcon = document.createElement('i');
435xIcon.classList.add('fa', 'fa-times');
436
437if (form && submitButton) {
438  // insert the 'x' icon after the submit button
439  submitButton.insertAdjacentElement('afterend', xIcon);
440}
441
442// toggle class 'expanded'
443const toggleExpand = (element, container, shouldExpand) => {
444  if (!element || !container) return;
445  element.classList.toggle('expanded', shouldExpand);
446  container.classList.toggle('expanded', shouldExpand);
447};
448
449// expand search on first click (preventing form submission if not expanded)
450if (submitButton && form) {
451  submitButton.addEventListener('click', (e) => {
452    if (!form.classList.contains('expanded')) {
453      e.preventDefault();
454      toggleExpand(form, searchContainer, true);
455      if (searchInput) searchInput.focus();
456    }
457  });
458}
459
460// Close search when clicking on 'x' icon 
461xIcon.addEventListener('click', (e) => {
462  e.stopPropagation();
463  toggleExpand(form, searchContainer, false);
464  if (searchInput) searchInput.value = '';
465});
466
467// listener for clicks outside the search form and main menu
468document.addEventListener('click', (e) => {
469  if (form && !form.contains(e.target)) toggleExpand(form, searchContainer, false);
470});

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.