PageSourceSearch

https://jaunimolinija.lt/wp-content/themes/jaunimo/assets/js/scripts.js?ver=1788962011

js jaunimolinija.lt collected 2026-10-01 12:35:29 UTC 11,051 bytes, 356 lines download raw bytes

1jQuery(function($) {
2
3    $(document).ready(function() {
4        toggleHeaderBehavior($(window).width() > 1239);
5    
6        $(window).resize(function() {
7            toggleHeaderBehavior($(window).width() > 1239);
8        });
9    });
10
11    var $checkbox = $("#woo_ml_subscribe");
12    $checkbox.parent().contents().filter(function() {
13        return this !== $checkbox[0];
14    }).wrapAll("<span class='additional-wrapper'></span>");
15    
16    function toggleHeaderBehavior(applyBehavior) {
17        if (applyBehavior) {
18            // Your existing header behavior code here
19            var didScroll;
20            var lastScrollTop = 0;
21            var delta = 5;
22            var navbarHeight = $('header').outerHeight();
23    
24            $(window).scroll(function(event) {
25                didScroll = true;
26            });
27    
28            setInterval(function() {
29                if (didScroll) {
30                    hasScrolled();
31                    didScroll = false;
32                }
33            }, 500);
34    
35            function hasScrolled() {
36                var st = $(window).scrollTop();
37    
38                if (Math.abs(lastScrollTop - st) <= delta)
39                    return;
40    
41                if (st > lastScrollTop && st > navbarHeight) {
42                    // Scroll Down
43                    $('header').removeClass('header-down').addClass('header-up');
44                } else {
45                    // Scroll Up
46                    if (st + $(window).height() < $(document).height()) {
47                        $('header').removeClass('header-up').addClass('header-down');
48                    }
49                }
50    
51                lastScrollTop = st;
52            }
53        } else {
54            $(window).off("scroll");
55            $('header').removeClass('header-up header-down').css('top', '');
56        }
57    }
58
59    AOS.init({
60        once: true,
61        offset: 200,
62        duration: 1500,
63        easing: 'ease-in-out',
64        delay: 0,
65    });
66
67    $('#mob-main-nav').hcOffcanvasNav({
68        disableAt: 1240,
69        customToggle: $('#mob-menu-trigger'),
70        navTitle: '',
71        levelTitles: true,
72        levelTitleAsBack: true,
73        width: 415,
74        position: 'right',
75        swipeGestures: false,
76        ariaLabels: {
77            open:     'Open Menu',
78            close:    'Close Menu',
79            submenu:  'Submenu',
80            back: ''
81        }
82    });
83
84    // Handle change event of dropdown
85    $('.mobile-filter-dropdown select').on('change', function () {
86        var selectedValue = $(this).val();
87        window.location.href = selectedValue;
88    });
89
90    // Pretty dropdowns
91    $('select').prettyDropdown({
92        height: 50
93    });
94
95    $(document).ready(function () {
96        $('.lang-toggle').click(function () {
97            $('.lang-dropdown').show();
98            $(this).css('border-radius', '15px 15px 5px 5px');
99        });
100    
101        // Close dropdown when clicking outside
102        $(document).on('click', function (e) {
103            if (!$(e.target).closest('.custom-dropdown').length) {
104                $('.lang-dropdown').hide();
105                $('.lang-toggle').css('border-radius', '50px');
106            }
107        });
108    });
109
110    // Wrap table to div
111    $('table').wrap('<div class="table-responsive"></div>');
112
113    var hoverTimeout;
114    $('.menu-item-has-children').hover(
115        function() {
116            clearTimeout(hoverTimeout);
117            $('.sub-menu').not($(this).find('.sub-menu')).hide();
118            $(this).find('.sub-menu').fadeIn('fast');
119        },
120        function() {
121            var $submenu = $(this).find('.sub-menu');
122            hoverTimeout = setTimeout(function() {
123                $submenu.hide();
124            }, 200);
125        }
126    );
127
128    // Cancel the hover out event if moving from menu item to submenu
129    $('.sub-menu').hover(
130        function() {
131            clearTimeout(hoverTimeout);
132        },
133        function() {
134            var $submenu = $(this);
135            hoverTimeout = setTimeout(function() {
136                $submenu.hide();
137            }, 200);
138        }
139    );
140
141    // Mobile menu
142    $('.navbar-toggler-mob').on('click', function () {
143        $('#navbar-collapse-mob').toggleClass('show');
144        $('#navbar-collapse-mob').css({'z-index': '100', 'opacity': '1' });
145    });
146
147    // For mobile menu first click open menu, second page
148    // if (jQuery( window ).width() < 1239) {
149    //     $('.menu-item-has-children').on("click", function(e) {
150    //         if ($('.dropdown-menu').css('display') == 'block') {
151    //             $(this).next('.dropdown-menu').css('display', 'none');
152    //         } else {
153    //             e.preventDefault();
154    //             $(this).next('.dropdown-menu').css('display', 'block');
155    //         }
156    //     });
157    // }
158
159    // Lang switcher
160    $( ".lang-toggle" ).click(function() {
161        $( ".lang-dropdown" ).toggle();
162    });
163
164    $(document).mouseup(function(e){
165        var langContainer = $(".lang-dropdown");
166        if(!langContainer.is(e.target) && langContainer.has(e.target).length === 0){
167            langContainer.hide();
168        }
169    });
170
171    var heroSwiperEl = document.querySelector(".heroSwiper");
172    if (heroSwiperEl) {
173        var heroAutoplay = parseInt(heroSwiperEl.getAttribute("data-autoplay"), 10) || 0;
174        var heroConfig = {
175            slidesPerView: 1,
176            loop: heroSwiperEl.querySelectorAll(".swiper-slide").length > 1,
177            pagination: {
178                el: ".hero-swiper-pagination",
179                clickable: true,
180            },
181        };
182        if (heroAutoplay > 0) {
183            heroConfig.autoplay = {
184                delay: heroAutoplay * 1000,
185            };
186        }
187        new Swiper(".heroSwiper", heroConfig);
188    }
189
190    new Swiper(".newsSwiper", {
191        slidesPerView: 1.1,
192        spaceBetween: 20,
193        navigation: {
194            nextEl: ".swiper-news-button-next",
195            prevEl: ".swiper-news-button-prev",
196        },
197        breakpoints: {
198            600: {
199                slidesPerView: 2.1,
200                spaceBetween: 20,
201            },
202            1000: {
203                slidesPerView: 3,
204                spaceBetween: 25,
205            }
206        },
207    });
208
209    new Swiper(".sponsorsSwiper", {
210        slidesPerView: 2.2,
211        spaceBetween: 20,
212        navigation: {
213            nextEl: ".swiper-sponsors-button-next",
214            prevEl: ".swiper-sponsors-button-prev",
215        },
216        breakpoints: {
217            700: {
218                slidesPerView: 4.5,
219                spaceBetween: 20,
220            },
221            1000: {
222                slidesPerView: 6,
223                spaceBetween: 27,
224            }
225        },
226    });
227
228    new Swiper(".reviewsSwiper", {
229        slidesPerView: 1.2,
230        spaceBetween: 18,
231        navigation: {
232            nextEl: ".swiper-reviews-button-next",
233            prevEl: ".swiper-reviews-button-prev",
234        },
235        breakpoints: {
236            600: {
237                slidesPerView: 2.25,
238                spaceBetween: 18,
239            },
240            1000: {
241                slidesPerView: 2,
242                spaceBetween: 35,
243            }
244        },
245    });
246
247    new Swiper(".ambasadorReviewsSwiper", {
248        slidesPerView: 1.1,
249        spaceBetween: 20,
250        navigation: {
251            nextEl: ".swiper-ambasador-reviews-button-next",
252            prevEl: ".swiper-ambasador-reviews-button-prev",
253        },
254        breakpoints: {
255            720: {
256                slidesPerView: 2.1,
257                spaceBetween: 20,
258            },
259            1000: {
260                slidesPerView: 2,
261                spaceBetween: 27,
262            }
263        },
264    });
265
266    // for class .mobile-filter in mobile make on clicking .filter-title expand .filter-content like accordion
267    $('.mobile-filter .filter-title').on('click', function() {
268        $(this).next('.filter-content').slideToggle('fast');
269        $(this).toggleClass('active');
270    });
271
272    $('#showcompany').on('change', function (event) {
273
274        var checked = $(this).is(":checked");
275    
276        if (checked == true) {
277            $('#billing_company_name_field, #billing_company_code_field, #billing_pvm_field, #billing_company_address_field').fadeIn();
278        } else {
279            $('#billing_company_name_field, #billing_company_code_field, #billing_pvm_field, #billing_company_address_field').fadeOut();
280        }
281    
282        event.preventDefault();
283    });
284});
285
286document.addEventListener("DOMContentLoaded", function() {
287    const inputFields = document.querySelectorAll(".input-text");
288    const minusBtns = document.querySelectorAll(".arrow-down");
289    const plusBtns = document.querySelectorAll(".arrow-up");
290
291    inputFields.forEach((inputField, index) => {
292        const minusBtn = minusBtns[index];
293        const plusBtn = plusBtns[index];
294
295        if (!minusBtn || !plusBtn) {
296            console.error("Button element missing for index", index);
297            return;
298        }
299
300        // Determine the step size based on the presence of the `.custom-donation` class
301        const step = inputField.closest('.custom-donation') ? 10 : 1;
302
303        minusBtn.addEventListener("click", function () {
304            let newValue = parseInt(inputField.value) - step;
305            if (newValue >= 0) {
306                inputField.value = newValue;
307                jQuery(inputField).trigger('change');
308            }
309        });
310
311        plusBtn.addEventListener("click", function () {
312            inputField.value = parseInt(inputField.value) + step;
313            jQuery(inputField).trigger('change');
314        });
315    });
316});
317
318
319// Set default value for custom_price input field after page load
320document.addEventListener('DOMContentLoaded', function() {
321    var customPriceInput = document.getElementById('custom_price');
322    if (customPriceInput) {
323        customPriceInput.value = '10';
324    }
325});
326
327document.addEventListener('DOMContentLoaded', function() {
328    if (window.location.href.includes("/rasyti-atsiliepima/")) {
329        document.getElementById('form-id').value = customFormScript.formId;
330    }
331});
332
333
334document.querySelectorAll(".btn-donate-green").forEach(button => {
335    button.addEventListener("click", () => {
336        const formData = new FormData(button.closest("form"));
337        const selectedOption = formData.get("option");
338        const customAmount = formData.get("custom-amount");
339        const amountInCents = customAmount ? Math.round(customAmount * 100) : Math.round(selectedOption * 100);
340
341        PayHere.launch({
342            embedURL: "https://app.payhere.co/jaunimo-linija/periodinis-aukojimas",
343            amountInCents: amountInCents,
344            hideAmount: "yes",
345            onSuccess: function ({ customerName, customerEmail }) {
346                console.log("onSuccess", customerName, customerEmail)
347            },
348            onFailure: function (error) {
349                console.log("onFailure", error)
350            },
351            onClose: function () {
352                console.log("onClose")
353            }
354        })
355    });
356});

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.