PageSourceSearch

https://vasab.org/wp-content/themes/wb/assets/js/theme.js?ver=1790277237

js vasab.org collected 2026-09-24 19:14:17 UTC 28,120 bytes, 756 lines download raw bytes

1(function($) {
2
3    const dateFormat = 'dd.mm.yy';
4    let members ='';
5
6    $(document).ready(function() {
7
8        const search = $('.search-popup');
9        const mobile_menu = $('.mobile-menu');
10
11        if($('#members-list').length) {
12            members = JSON.parse($('#members-list').val());
13        }
14        
15        Fancybox.bind("[data-fancybox]", {});
16
17        // let zoom = getCookie('accessibility-zoom');
18
19        $('.text-size').click(function() {
20            let value = parseInt(getCookie('accessibility-zoom'));
21
22            if(!value) {
23                value = 1;
24            }
25
26            if($(this).hasClass('text-size-plus')) {
27                value += 1;
28
29                if(value > 3) value = 3;
30            } else {
31                value -= 1;
32
33                if(value <= 0) value = 1;
34            }
35
36            let date = new Date();
37            date.setMonth(date.getMonth() + 1);
38            document.cookie = "accessibility-zoom=" + value + "; path=/; expires=" + date.toUTCString();
39            $('html').removeClass('zoom-1').removeClass('zoom-2').removeClass('zoom-3');
40            $('html').addClass('zoom-' + value);
41        });
42
43        /**
44         * WYSIWYG accessibility
45         */
46        $('.elementor-widget-text-editor').each(function() {
47            if (!$(this).attr('tabindex')) {
48                $(this).attr('tabindex', '0');
49            }
50        });
51
52        if($('.vasab-old-page-content').length) {
53            $('.vasab-old-page-content p, .vasab-old-page-content a, .vasab-old-page-content h2, .vasab-old-page-content h3, .vasab-old-page-content h4, .vasab-old-page-content h5, .vasab-old-page-content ul, .vasab-old-page-content li').each(function() {
54                if (!$(this).attr('tabindex')) {
55                    $(this).attr('tabindex', '0');
56                }
57            });
58        }
59
60        /**
61         * Trigger forms when pressing enter key
62         */
63        $('form').on('keypress', function (e) {
64            if (e.which === 13) {
65                // e.preventDefault();
66                $(this).submit();
67            }
68        });
69
70        $('#filter-search').on('keypress', function (e) {
71            if (e.which === 13) {
72                $('#text-filter-button').trigger('click');
73            }
74        });
75
76        /**
77         * Mobile footer menu
78         */
79        // $('.footer-column-title').click(function() {
80        //     if($(window).width() <= 768) {
81        //         $('.footer-column-opened').removeClass('footer-column-opened');
82
83        //         $(this).parent().addClass('footer-column-opened');
84
85        //         const content = $(this).parent().find('.footer-column-content');
86        //         $('.footer-column-content').not(content).slideUp();
87        //         content.stop(true, true).slideToggle();
88        //     }
89        // });
90
91        /**
92         * Mobile menu
93         */
94        $('.header-mobile-menu-btn').click(function() {
95            if(!$(this).hasClass('mobile-menu-opened')) {
96                $(this).addClass('mobile-menu-opened');
97                $(mobile_menu).removeClass('fade-out').addClass('fade-in').css('display', 'flex');
98                $('html').css('overflow-y', 'hidden');
99            } else {
100                $(this).removeClass('mobile-menu-opened');
101                $(mobile_menu).removeClass('fade-in').addClass('fade-out');
102                $('html').css('overflow-y', 'auto');
103
104                setTimeout(function() {
105                    $(mobile_menu).hide();
106                }, 400);
107            }
108        });
109
110        $('.mobile-nav .nav__item > a').click(function(e) {
111
112            if ($(e.target).closest('.mobile-menu-back').length) {
113                e.preventDefault();
114                $(this).parent().removeClass('mobile-submenu-opened');
115                $('.mobile-nav .nav__item').show();
116                $('.mobile-header-text-size').show();
117                $('.mobile-menu-socials').show();
118            } else {
119                if(!$(this).parent().hasClass('mobile-submenu-opened')) {
120                    e.preventDefault();
121                    $(this).parent().addClass('mobile-submenu-opened');
122
123                    $('.mobile-nav .nav__item:not(.mobile-submenu-opened)').hide();
124                    $('.mobile-header-text-size').hide();
125                    $('.mobile-menu-socials').hide();
126                }
127            }
128
129            // if($(this).parent().find('.mobile-submenu').length) {
130            //     e.preventDefault();
131
132            //     if(!$(this).parent().hasClass('mobile-submenu-opened')) {
133            //         $(this).parent().addClass('mobile-submenu-opened');
134
135            //         $('.mobile-nav .nav__item:not(.mobile-submenu-opened)').hide();
136            //         $('.mobile-header-text-size').hide();
137            //         $('.mobile-menu-socials').hide();
138            //     } else {
139            //         $(this).parent().removeClass('mobile-submenu-opened');
140
141            //         $('.mobile-nav .nav__item').show();
142            //         $('.mobile-header-text-size').show();
143            //         $('.mobile-menu-socials').show();
144            //     }
145
146            // }
147        });
148
149        /**
150         * Init select2 dropdowns
151         */
152        if($('.init-select2').length) {
153            $('.init-select2').each(function() {
154                if($(this).hasClass('select2-no-search') && $(this).hasClass('select-2-multiple')) {
155                    $(this).select2({
156                        minimumResultsForSearch: Infinity,
157                        multiple: true
158                    });
159                } else if($(this).hasClass('select2-no-search')) {
160                     $(this).select2({
161                        minimumResultsForSearch: Infinity
162                    });
163                } else {
164                    $(this).select2({
165                        minimumResultsForSearch: Infinity,
166                    });
167                }
168            });
169        }
170
171        /** 
172         * Search
173         */
174        $('.header-search, .header-mobile-search-btn').click(function() {
175            $(search).removeClass('fade-out').addClass('fade-in').css('display', 'flex');
176        });
177
178        $('.header-search').on('keydown', function(e) {
179            if (e.key === 'Enter') {
180                $(search).removeClass('fade-out').addClass('fade-in').css('display', 'flex');
181            }
182        });
183
184        $('.search-close').click(function() {
185            $(search).removeClass('fade-in').addClass('fade-out');
186            setTimeout(function() {
187                $(search).hide();
188            }, 400);
189        });
190
191        $('.search-close').on('keydown', function(e) {
192            if (e.key === 'Enter') {
193                $('.search-close').trigger('click');
194            }
195        });
196
197        $('.search-results-post-changer').click(function() {
198            let type = $(this).data('type');
199
200            $('.active-changer').removeClass('active-changer');
201            $(this).addClass('active-changer');
202
203            $('.active-results').removeClass('active-results');
204            $('.search-result-list[data-type="' + type + '"]').addClass('active-results');
205
206        });
207
208        /**
209         * Init datepicker filters
210         */
211        if($('.filter-dates').length) {
212
213            let _format = 'dd.mm';
214
215            let year = 2000;
216
217            if($('#filter-year').length) {
218                year = $('#filter-year option:selected').val();
219            }
220
221            if(!year) year = 2000;
222
223            let filter_from = getUrlParameter('date_from');
224            let filter_to = getUrlParameter('date_to');
225
226            const today = new Date();
227            const fromDateObj = filter_from ? parseDateFromString(filter_from, year) : null;
228            const toDateObj = filter_to ? parseDateFromString(filter_to, year) : null;
229
230            // console.log(fromDateObj, toDateObj);
231
232            let fromOptions = {
233                dateFormat: _format,
234                minDate: new Date(year, 0, 1),
235                maxDate: new Date(year, 11, 31),
236                onSelect: function(selectedDate) {
237                    var date = $(this).datepicker('getDate');
238                    $('#date-to').datepicker("option", "minDate", date);
239                    triggerPostFilter();
240                }
241            };
242
243            if (toDateObj) {
244                fromOptions.maxDate = toDateObj;
245            }
246
247            let from = $('#date-from').datepicker(fromOptions).datepicker('setDate', (fromDateObj !== null ? fromDateObj : ''));
248
249            let to = $('#date-to').datepicker({
250                dateFormat: _format,
251                minDate: fromDateObj || today,
252                maxDate: new Date(year, 11, 31),
253                onSelect: function(selectedDate) {
254                    var date = $(this).datepicker('getDate');
255                    triggerPostFilter();
256                }
257            }).datepicker('setDate', (toDateObj !== null ? toDateObj : ''));
258        }
259
260        /**
261         * Parses dd.mm.yy string to Date object
262         * @param {*} dateStr 
263         * @returns 
264         */
265        function parseDateFromString(dateStr, year = 2000) {
266            console.log('test1');
267            const parts = dateStr.split('.');
268            if (parts.length !== 3) return null;
269
270            const day = parseInt(parts[0], 10);
271            const month = parseInt(parts[1], 10) - 1;
272            // let year = parseInt(parts[2], 10);
273
274            let date = new Date(year, month, day);
275        
276            return date;
277        }
278
279        /**
280         * Init map popups
281         */
282        $(document).on('click', '.map-selectable', function() {
283            let country = $(this).data('country');
284            let popup = $('.hero-popup');
285            let html = '';
286            let results = 0;
287
288            console.log('click on country');
289
290            if(members) {
291                $.each(members, function(index, value) {
292                    if(value.country == country) {
293
294                        results++;
295
296                        let description = '';
297                        let phone = '';
298                        let email = '';
299                        let location = '';
300                        let website = '';
301                        let buttons = '';
302
303                        console.log(value);
304
305                        if(value.description) {
306                            description = '<div class="hero-member-description">' + value.description + '</div>';
307                        }
308
309                        if(value.phone) {
310                            phone = '<div class="hero-member-meta">\
311                                <img src="/wp-content/themes/wb/assets/images/vasab-phone-blue.svg" onload="SVGInject(this)">\
312                                <a href="tel:' + value.phone + '">' + value.phone + '</a>\
313                            </div>';
314                        }
315
316                        if(value.email) {
317                            email = '<div class="hero-member-meta">\
318                                <img src="/wp-content/themes/wb/assets/images/vasab-mail-blue.svg" onload="SVGInject(this)">\
319                                <a href="mailto:' + value.email + '">' + value.email + '</a>\
320                            </div>';
321                        }
322
323                        if(value.location) {
324                            location = '<div class="hero-member-meta">\
325                                <img src="/wp-content/themes/wb/assets/images/vasab-location-blue.svg" onload="SVGInject(this)">\
326                                ' + value.location + '\
327                            </div>';
328                        }
329
330                        if(value.website) {
331                            website = '<div class="hero-member-meta">\
332                                <img src="/wp-content/themes/wb/assets/images/vasab-website-blue.svg" onload="SVGInject(this)">\
333                                <a href="' + value.website + '" target="_blank">' + value.website + '</a>\
334                            </div>';
335                        }
336
337                        if(value.btn_1_text && value.btn_1_url) {
338                            buttons += '<a href="' + value.btn_1_url + '" class="btn btn-blue btn-single-member">' + value.btn_1_text + '</a>';
339                        }
340
341                        if(value.btn_2_text && value.btn_2_url) {
342                            buttons += '<a href="' + value.btn_2_url + '" class="btn btn-blue btn-single-member">' + value.btn_2_text + '</a>';
343                        }
344
345                        html += '\
346                            <div class="hero-member">\
347                                <div class="hero-member-close">\
348                                    <img\
349                                        src="/wp-content/themes/wb/assets/images/vasab-mobile-close.svg"\
350                                        alt="Close member popup"\
351                                        onload="SVGInject(this)">\
352                                </div>\
353                                <div class="hero-member-header" style="background-image:url(' + value.image + ')">\
354                                    <div class="hero-member-country">\
355                                        ' + value.country_label + '\
356                                    </div>\
357                                </div>\
358                                <div class="hero-member-content">\
359                                    <div class="hero-member-arrows">\
360                                        <button class="hero-arrow arrow-prev">\
361                                            <img src="/wp-content/themes/wb/assets/images/arrow-left.svg" onload="SVGInject(this)">\
362                                        </button>\
363                                        <div class="hero-member-title">\
364                                            ' + value.name + '\
365                                        </div>\
366                                        <button class="hero-arrow arrow-next">\
367                                            <img src="/wp-content/themes/wb/assets/images/arrow-right.svg" onload="SVGInject(this)">\
368                                        </button>\
369                                    </div>\
370                                    <div class="hero-member-person">\
371                                        ' + value.contact + '\
372                                    </div>\
373                                    ' + description + '\
374                                    ' + phone + '\
375                                    ' + email + '\
376                                    ' + location + '\
377                                    ' + website + '\
378                                    <div class="hero-member-btns">' + buttons + '</div>\
379                                </div>\
380                            </div>\
381                        ';
382                    }
383                });
384
385                if($('.hero-popup-list').hasClass('slick-initialized')) {
386                    $('.hero-popup-list').slick('unslick');
387                }
388
389                $(popup).find('.hero-popup-list').html(html);
390
391                $(popup).removeClass('fade-out').addClass('fade-in').show();
392                
393                if(results == 1) {
394                    $('.hero-member-arrows').addClass('hide-arrows');
395                }
396
397                if(results > 1) {
398                    $('.hero-member-arrows').removeClass('hide-arrows');
399
400                    $('.hero-popup-list').slick({
401                        slidesToShow: 1,
402                        slidesToScroll: 1,
403                        arrows: false,
404                        dots: false,
405                        infinite: true
406                    });
407                }
408            }
409        });
410
411        /**
412         * Close hero popup
413         */
414        $(document).on('click', '.hero-member-close', function () {
415            $('.hero-popup').removeClass('fade-in').addClass('fade-out');
416
417            setTimeout(function() {
418                $('.hero-popup').hide();
419            }, 400);
420        });
421
422        $(document).on('click', '.vasab-home-hero', function(e) {
423            if($('.hero-popup').is(':visible')) {
424                console.log($(e.target));
425                if(!$(e.target).hasClass('hero-popup') && !$(e.target).closest('.hero-popup').length && !$(e.target).hasClass('map-selectable')) {
426                    $('.hero-popup').removeClass('fade-in').addClass('fade-out');
427
428                    setTimeout(function() {
429                        $('.hero-popup').hide();
430                    }, 400);
431                }
432            }
433        });
434
435        $(document).on('click', '.hero-arrow', function() {
436            if($(this).hasClass('arrow-next')) {
437                $('.hero-popup-list').slick('slickNext');
438            } else {
439                $('.hero-popup-list').slick('slickPrev');
440            }
441        });
442
443        if($('.vasab-latest-news-slider').length) {
444            $('.vasab-latest-news-slider').slick({
445                slidesToShow: 4,
446                slidesToScroll: 1,
447                arrows: true,
448                infinite: true,
449                prevArrow: '<button type="button" class="slick-prev"><img src="/wp-content/themes/wb/assets/images/arrow-left.svg" onload="SVGInject(this)"></button>',
450                nextArrow: '<button type="button" class="slick-next"><img src="/wp-content/themes/wb/assets/images/arrow-right.svg" onload="SVGInject(this)"></button>',
451                responsive: [
452                    {
453                        breakpoint: 1000,
454                        settings: {
455                            slidesToShow: 3
456                        }
457                    },
458                    {
459                        breakpoint: 768,
460                        settings: {
461                            slidesToShow: 2
462                        }
463                    },
464                    {
465                        breakpoint: 550,
466                        settings: {
467                            slidesToShow: 1
468                        }
469                    }
470                ]
471            });
472        }
473
474        if($('.vasab-upcoming-events-slider').length) {
475            $('.vasab-upcoming-events-slider').slick({
476                slidesToShow: 3,
477                slidesToScroll: 1,
478                arrows: true,
479                infinite: false,
480                prevArrow: '<button type="button" class="slick-prev"><img src="/wp-content/themes/wb/assets/images/arrow-left.svg" onload="SVGInject(this)"></button>',
481                nextArrow: '<button type="button" class="slick-next"><img src="/wp-content/themes/wb/assets/images/arrow-right.svg" onload="SVGInject(this)"></button>',
482                responsive: [
483                    {
484                        breakpoint: 1000,
485                        settings: {
486                            slidesToShow: 3
487                        }
488                    },
489                    {
490                        breakpoint: 768,
491                        settings: {
492                            slidesToShow: 2
493                        }
494                    },
495                    {
496                        breakpoint: 550,
497                        settings: {
498                            slidesToShow: 1
499                        }
500                    }
501                ]
502            });
503        }
504
505        if($('.vasab-image-slider').length) {
506            $('.vasab-image-slider').each(function() {
507                $(this).slick({
508                    slidesToShow: 2,
509                    slidesToScroll: 1,
510                    arrows: true,
511                    infinite: true,
512                    autoplay: true,
513                    autoplaySpeed: 5000,
514                    prevArrow: '<button type="button" class="slick-prev"><img src="/wp-content/themes/wb/assets/images/arrow-left.svg" onload="SVGInject(this)"></button>',
515                    nextArrow: '<button type="button" class="slick-next"><img src="/wp-content/themes/wb/assets/images/arrow-right.svg" onload="SVGInject(this)"></button>',
516                    responsive: [
517                    {
518                        breakpoint: 1000,
519                        settings: {
520                            slidesToShow: 1,
521                            centerMode: true,
522                            centerPadding: '40px',
523                        }
524                    }
525                ]
526                });
527            });
528        }
529
530        if($('.post-gallery-list').length) {
531            $('.post-gallery-list').each(function() {
532                $(this).slick({
533                    slidesToShow: 3,
534                    slidesToScroll: 1,
535                    arrows: true,
536                    infinite: true,
537                    prevArrow: '<button type="button" class="slick-prev"><img src="/wp-content/themes/wb/assets/images/arrow-left.svg" onload="SVGInject(this)"></button>',
538                    nextArrow: '<button type="button" class="slick-next"><img src="/wp-content/themes/wb/assets/images/arrow-right.svg" onload="SVGInject(this)"></button>',
539                    responsive: [
540                        {
541                            breakpoint: 1000,
542                            settings: {
543                                slidesToShow: 3,
544                                centerMode: true,
545                                centerPadding: '40px',
546                            }
547                        },
548                        {
549                            breakpoint: 650,
550                            settings: {
551                                slidesToShow: 2,
552                                centerMode: true,
553                                centerPadding: '40px',
554                            }
555                        },
556                        {
557                            breakpoint: 430,
558                            settings: {
559                                slidesToShow: 1,
560                                centerMode: true,
561                                centerPadding: '40px',
562                            }
563                        }
564                    ]
565                });
566            });
567        }
568
569        $('.page-accordion-title').on('click', function () {
570            let index = $(this).parent().data('index');
571
572            $('.page-accordion-opened').removeClass('page-accordion-opened');
573
574            let visible = $(this).parent().find('.page-accordion-text').is(':visible');
575
576            const content = $(this).parent().find('.page-accordion-text');
577            $('.page-accordion-text').not(content).slideUp();
578            content.stop(true, true).slideToggle();
579
580            if(!visible) {
581                $(this).parent().addClass('page-accordion-opened');
582            } else {
583                $(this).parent().removeClass('page-accordion-opened');
584            }
585
586            $('.page-accordion-image').removeClass('fade-in').addClass('fade-out');
587            setTimeout(function() {
588                $('.page-accordion-image').hide();
589                $('.page-accordion-image[data-index="' + index + '"]').removeClass('fade-out').addClass('fade-in').show();
590            }, 400);
591
592        });
593
594        $('#filter-sort, #filter-year, #filter-tag').select2()
595            .on('select2:select', triggerPostFilter)
596            .on('select2:clear', triggerPostFilter);
597
598        $(document).on('change', '#date-to, #date-from', function(e) {
599            triggerPostFilter();
600        });
601
602        $(document).on('click', '#text-filter-button', function() {
603            triggerPostFilter();
604        });
605
606        function triggerPostFilter() {
607            let text, dateFrom, dateTo, sort, baseUrl, first, year, tag;
608
609            first = true;
610
611            baseUrl = $('#filter_base_url').val();
612
613            console.log(baseUrl);
614
615            if($('#filter-search').length) {
616                text = $('#filter-search').val();
617            }
618
619            if($('#filter-year').length) {
620                year = $('#filter-year').val();
621            }
622
623            if($('#filter-tag').length) {
624                tag = $('#filter-tag').val();
625            }
626
627            if($('#date-from').length) {
628                dateFrom = $('#date-from').val();
629            }
630
631            if($('#date-to').length) {
632                dateTo = $('#date-to').val();
633            }
634
635            if($('#filter-sort').length) {
636                sort = $('#filter-sort option:selected').val();
637            }
638
639            if(text) {
640                if(first) {
641                    baseUrl = baseUrl + '?text=' + text;
642                    first = false;
643                } else {
644                    baseUrl = baseUrl + '&text=' + text;
645                }
646            }
647            if(year) {
648                if(first) {
649                    baseUrl = baseUrl + '?years=' + year;
650                    first = false;
651                } else {
652                    baseUrl = baseUrl + '&years=' + year;
653                }
654            }
655            if(tag) {
656                if(first) {
657                    baseUrl = baseUrl + '?tags=' + tag;
658                    first = false;
659                } else {
660                    baseUrl = baseUrl + '&tags=' + tag;
661                }
662            }
663            if(dateFrom) {
664                if(first) {
665                    baseUrl = baseUrl + '?date_from=' + dateFrom;
666                    first = false;
667                } else {
668                    baseUrl = baseUrl + '&date_from=' + dateFrom;
669                }
670            }
671            if(dateTo) {
672                if(first) {
673                    baseUrl = baseUrl + '?date_to=' + dateTo;
674                    first = false;
675                } else {
676                    baseUrl = baseUrl + '&date_to=' + dateTo;
677                }
678            }
679            if(sort) {
680                if(first) {
681                    baseUrl = baseUrl + '?sort=' + sort;
682                    first = false;
683                } else {
684                    baseUrl = baseUrl + '&sort=' + sort;
685                }
686            }
687    
688            window.location.href = baseUrl;
689        }
690
691        function getCookie(name) {
692            let value = "; " + document.cookie;
693            let parts = value.split("; " + name + "=");
694            if (parts.length === 2) return parts.pop().split(";").shift();
695        }
696
697        /**
698         * Get URL parameter value
699         * @param {*} sParam 
700         * @returns 
701         */
702        function getUrlParameter(sParam) {
703            var sPageURL = window.location.search.substring(1),
704                sURLVariables = sPageURL.split('&'),
705                sParameterName,
706                i;
707    
708            for (i = 0; i < sURLVariables.length; i++) {
709                sParameterName = sURLVariables[i].split('=');
710    
711                if (sParameterName[0] === sParam) {
712                    return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
713                }
714            }
715            return false;
716        };
717
718        /**
719         * Parses dd.mm.yy string to Date object
720         * @param {*} dateStr 
721         * @returns 
722         */
723        function parseDateFromString(dateStr, year = 2000) {
724            console.log('test2');
725            const parts = dateStr.split('.');
726            // if (parts.length !== 3) return null;
727
728            const day = parseInt(parts[0], 10);
729            const month = parseInt(parts[1], 10) - 1;
730            // let year = parseInt(parts[2], 10);
731
732            let date = new Date(year, month, day);
733            console.log(date);
734        
735            return date;
736        }
737
738        // jQuery.ajax({
739        //     type: "post",
740        //     dataType: "json",
741        //     url: ajax_object.ajaxurl,
742        //     data: {
743        //         action: "php_function_name",
744        //         param1: param1
745        //     },
746        //     success: function(response) {
747        //         alert('Success!');
748        //     },
749        //     error: function(xhr, status, error) {
750        //         console.log(xhr.responseText);
751        //     }
752        // });
753
754    });
755
756})(jQuery);

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.