PageSourceSearch

https://demetra.rs/wp-content/themes/cubestheme/frontend/js/main.js?ver=1.0.18

js demetra.rs collected 2026-09-30 21:40:17 UTC 11,728 bytes, 481 lines download raw bytes

1$(document).ready(function () {
2  //---PRELOADER
3  jQuery(".se-pre-con").fadeOut("slow");
4  jQuery(document).on("load", function () {
5    jQuery(".se-pre-con").fadeOut("slow");
6  });
7
8  // BACK TO TOP BUTTON
9
10  if ($(".back-to-top").length) {
11    var scrollTrigger = 100, // px
12      backToTop = function () {
13        var scrollTop = $(window).scrollTop();
14        if (scrollTop > scrollTrigger) {
15          $(".back-to-top").addClass("show");
16        } else {
17          $(".back-to-top").removeClass("show");
18        }
19      };
20    backToTop();
21    $(window).on("scroll", function () {
22      backToTop();
23    });
24    $(".back-to-top").on("click", function (e) {
25      e.preventDefault();
26      $("html,body").animate(
27        {
28          scrollTop: 0,
29        },
30        700
31      );
32    });
33  }
34
35  //MAIN MENU
36
37  $(".toggle-submenu").click(function (e) {
38    e.preventDefault();
39
40    let submenu = $(this).closest(".menu-item").find(".submenu");
41
42    $(".submenu").not(submenu).slideUp();
43    $(".toggle-submenu").not(this).removeClass("active");
44
45    submenu.slideToggle();
46    $(this).toggleClass("active");
47  });
48
49  function setupMenu() {
50    let windowWidth = $(window).width();
51
52    if (windowWidth < 991) {
53      $(".toggle-subsubmenu")
54        .off("click")
55        .on("click", function (e) {
56          e.preventDefault();
57
58          let submenu = $(this).closest(".submenu-item").find(".subsubmenu");
59
60          $(".subsubmenu").not(submenu).slideUp();
61          $(".toggle-subsubmenu").not(this).removeClass("active");
62
63          submenu.slideToggle();
64          $(this).toggleClass("active");
65        });
66    } else {
67      $(".toggle-subsubmenu").off("click");
68      $(".subsubmenu").removeAttr("style");
69      $(".toggle-subsubmenu").removeClass("active");
70    }
71  }
72
73  $(document).ready(setupMenu);
74
75  let resizeTimer;
76  $(window).on("resize", function () {
77    clearTimeout(resizeTimer);
78    resizeTimer = setTimeout(setupMenu, 300);
79  });
80
81  //HEADER SCROLL
82
83  if ($(window).width() > 991) {
84    var headerBottom = $(".header-bottom-wrapper");
85    var headerTopHeight = $(".header-top-wrapper").outerHeight();
86
87    $(window).scroll(function () {
88      if ($(this).scrollTop() > headerTopHeight) {
89        headerBottom.addClass("fixed-header");
90      } else {
91        headerBottom.removeClass("fixed-header");
92      }
93    });
94  }
95
96  //SEARCH AND NAVBAR TOGGLE CODE
97
98  $(".toggle-search").on("click", function (e) {
99    e.stopPropagation();
100    $(".search-form").toggleClass("active");
101    $(".header-bottom").removeClass("active");
102  });
103
104  $(".navbar-toggler").on("click", function () {
105    $(".header-bottom").toggleClass("active");
106    $(".search-form").removeClass("active");
107    $("html").toggleClass("scroll-off");
108  });
109  $(document).on("click", function (e) {
110    if (!$(e.target).closest(".search-form-wrapper").length) {
111      $(".search-form").removeClass("active");
112    }
113    if (!$(e.target).closest(".header-bottom, .navbar-toggler").length) {
114      $(".header-bottom").removeClass("active");
115    }
116  });
117
118  //LEAD SLIDER
119
120  if ($(".lead-slider").length > 0) {
121    $(function () {
122      let leadSliderSwiper = new Swiper(".lead-slider", {
123        slidesPerView: 1,
124        spaceBetween: 0,
125        freeMode: true,
126        allowTouchMove: false,
127        autoplay: {
128          delay: 3500,
129          disableOnInteraction: false,
130        },
131        pagination: {
132          el: ".swiper-pagination",
133          clickable: true,
134        },
135        on: {
136          slideChangeTransitionStart: function () {
137            gsap.to(".lead-slider .news-item .news-item-data", {
138              opacity: 0,
139              y: 50,
140              duration: 0.5,
141              ease: "power2.out",
142            });
143          },
144          slideChangeTransitionEnd: function () {
145            gsap.to(
146              $(".lead-slider .swiper-slide-active .news-item .news-item-data"),
147              {
148                opacity: 1,
149                y: 0,
150                duration: 0.8,
151                ease: "power2.out",
152              }
153            );
154          },
155        },
156      });
157    });
158  }
159
160  //CATEGORY SLIDER
161
162  if ($(".category-slider").length > 0) {
163    $(function () {
164      let categorySliderSwiper = new Swiper(".category-slider", {
165        slidesPerView: "auto",
166        spaceBetween: 5,
167        freeMode: true,
168        navigation: {
169          nextEl: ".swiper-button-next",
170          prevEl: ".swiper-button-prev",
171        },
172        breakpoints: {
173          1265: {
174            spaceBetween: 10,
175          },
176        },
177      });
178    });
179  }
180
181  // CATEGORY SLIDER TABULATOR HOMEPAGE
182
183  $(".category-slider").on("click", ".category-slider-link", function (e) {
184    e.preventDefault();
185    let target = $(this).data("target");
186
187    $(this)
188      .closest(".swiper-slide")
189      .siblings()
190      .find(".category-slider-item")
191      .removeClass("active");
192    $(this).closest(".category-slider-item").addClass("active");
193
194    $(".category-slider-inner").removeClass("active");
195    $(target).addClass("active");
196  });
197
198  $(".category-slider-item").first().addClass("active");
199  $(".category-slider-inner").first().addClass("active");
200
201  //FOUR NEWS TEMP THREE SLIDER
202
203  if ($(".four-news-temp-three").length > 0) {
204    $(function () {
205      let fourNewsTempThreeSwiper = new Swiper(".four-news-temp-three", {
206        slidesPerView: "auto",
207        spaceBetween: 22,
208        freeMode: true,
209        scrollbar: {
210          el: ".swiper-scrollbar",
211          draggable: true,
212        },
213        breakpoints: {
214          1450: {
215            spaceBetween: 24,
216          },
217        },
218      });
219    });
220  }
221
222  //FOUR NEWS TEMP FOUR SLIDER
223if($('.four-news-temp-four').length > 0){
224  const newsSlider4 = window.matchMedia("(min-width: 1449px)");
225  let mySwiperNews4;
226
227  const enableSwiper4 = function () {
228    mySwiperNews4 = new Swiper(".four-news-temp-four", {
229      freeMode: true,
230      slidesPerView: "auto",
231      spaceBetween: 22,
232      breakpoints: {
233        768: {
234          spaceBetween: 24,
235        },
236      },
237    });
238  };
239
240  const breakpointChecker4 = function () {
241    if (newsSlider4.matches) {
242      if (mySwiperNews4) {
243        mySwiperNews4.destroy(true, true);
244        mySwiperNews4 = undefined;
245      }
246    } else {
247      if (!mySwiperNews4) {
248        enableSwiper4();
249      }
250    }
251  };
252
253  newsSlider4.addEventListener("change", breakpointChecker4);
254
255  breakpointChecker4();
256}
257  
258
259  //FOUR NEWS TEMP FIVE SLIDER
260if($('.four-news-temp-five').length >0){
261  const newsSlider5 = window.matchMedia("(min-width: 1449px)");
262  let mySwiperNews5;
263
264  const enableSwiper5 = function () {
265    mySwiperNews5 = new Swiper(".four-news-temp-five", {
266      freeMode: true,
267      slidesPerView: "auto",
268      spaceBetween: 22,
269      breakpoints: {
270        768: {
271          spaceBetween: 24,
272        },
273      },
274    });
275  };
276
277  const breakpointChecker5 = function () {
278    if (newsSlider5.matches) {
279      if (mySwiperNews5) {
280        mySwiperNews5.destroy(true, true);
281        mySwiperNews5 = undefined;
282      }
283    } else {
284      if (!mySwiperNews5) {
285        enableSwiper5();
286      }
287    }
288  };
289
290  newsSlider5.addEventListener("change", breakpointChecker5);
291
292  breakpointChecker5();
293}
294  //NEWSLETTER VALIDATION
295
296  if ($(".mc4wp-form").length > 0) {
297    $(".mc4wp-form").each(function () {
298      $(this).validate({
299        highlight: function (element) {
300          $(element).addClass("is-invalid").removeClass("is-valid");
301          $(element)
302            .closest(".form-group")
303            .addClass("is-invalid")
304            .removeClass("is-valid");
305        },
306        unhighlight: function (element) {
307          $(element).removeClass("is-invalid").addClass("is-valid");
308          $(element)
309            .closest(".form-group")
310            .addClass("is-valid")
311            .removeClass("is-invalid");
312        },
313        rules: {
314          EMAIL: {
315            required: true,
316            email: true,
317          },
318        },
319        messages:{
320          EMAIL: {
321            required: "Obavezno polje",
322            email: 'Molimo unesite validnu Email adresu.',
323          },
324        },
325
326        errorElement: "p",
327        errorPlacement: function (error, element) {
328          error.appendTo(
329            $(element).closest(".form-group-wrapper").find(".error-msg")
330          );
331        },
332      });
333    });
334  }
335
336  //FOOTER MENU
337
338  $(".toogle-footer-submenu").click(function (e) {
339    e.preventDefault();
340
341    let submenu = $(this).closest(".footer-item").find(".footer-submenu");
342
343    $(".footer-submenu").not(submenu).slideUp();
344    $(".toogle-footer-submenu").not(this).removeClass("active");
345
346    submenu.slideToggle();
347    $(this).toggleClass("active");
348  });
349
350  //PAGE CATEGORY STRUCNJAK READ MORE CODE
351
352  $('.info-box-data .read-more').click(function(e){
353    e.preventDefault();
354    let text = $(this).text().trim();
355
356    console.log(text);
357    $(this).prev('.info-box-text').toggleClass('expanded');
358    if(text == 'Pročitaj više'){
359      $(this).text('Pročitaj manje');
360    }else{
361      $(this).text('Pročitaj više');
362    }
363  });
364
365  //ABOUT PAGE READ MORE CODE
366
367  function setupTextToggleAbout() {
368    $(".about-history-text").each(function () {
369      let textBox = $(this);
370      let paragraphs = textBox.find("p");
371      let readMoreButton = textBox.siblings(".read-more-history");
372
373      if (textBox.hasClass("expanded")) {
374        return;
375      }
376
377      paragraphs.slice(3).hide();
378
379      readMoreButton.off("click").on("click", function (e) {
380        e.preventDefault();
381
382        if (textBox.hasClass("expanded")) {
383          paragraphs.slice(3).slideUp();
384          textBox.removeClass("expanded");
385          $(this).text("Pročitaj više");
386        } else {
387          paragraphs.slice(3).slideDown();
388          textBox.addClass("expanded");
389          $(this).text("Pročitaj manje");
390        }
391      });
392    });
393  }
394
395  setupTextToggleAbout();
396
397  //SINGLE NEWS LEAD IMAGE CAPTION
398
399  $(".toggle-caption").click(function () {
400    $(this).closest(".caption-wrapper").toggleClass("active");
401  });
402  $(".caption-wrapper").click(function (e) {
403    e.stopPropagation();
404  });
405
406  //SOCIAL SHARE COPY LINK
407
408  $(".share-wrapper .copy").click(function (e) {
409    e.preventDefault();
410
411    let currentUrl = window.location.href;
412
413    let textarea = document.createElement("textarea");
414    textarea.value = currentUrl;
415    document.body.appendChild(textarea);
416
417    textarea.select();
418    document.execCommand("copy");
419
420    document.body.removeChild(textarea);
421
422    let tooltip = $(this).find(".tooltip");
423    tooltip.removeClass("d-none").fadeIn();
424
425    setTimeout(function () {
426      tooltip.fadeOut(function () {
427        tooltip.addClass("d-none");
428      });
429    }, 3000);
430  });
431
432  //SINGLE NEWS GALLERY SLIDER
433
434  if ($(".gallery-wrapper-slider").length > 0) {
435    $(".gallery-wrapper-slider").owlCarousel({
436      items: 1,
437      margin: 0,
438      dots: true,
439      loop: false,
440      autoplay: false,
441      nav: true,
442    });
443  }
444
445  //ABOUT PAGE TEAM SLIDER
446
447  if ($(".about-team-slider").length > 0) {
448    $(function () {
449      let aboutTeamSwiper = new Swiper(".about-team-slider", {
450        slidesPerView: "auto",
451        spaceBetween: 24,
452        freeMode: true,
453        scrollbar: {
454          el: ".swiper-scrollbar",
455          draggable: true,
456        },
457        breakpoints: {
458          1265: {
459            spaceBetween: 50,
460          },
461        },
462      });
463    });
464  }
465
466  //MODAL
467
468  $("[data-toggle=modal]").click(function (e) {
469    e.preventDefault();
470    $target = $(this).data("target");
471    $($target).fadeIn();
472  });
473
474  $(".modal-close").click(function () {
475    $(this).closest(".modal").fadeOut();
476  });
477
478  $(".modal .modal-inner").click(function (e) {
479    e.stopPropagation();
480  });
481});

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.