PageSourceSearch

https://hadassah.moscow/wp-content/themes/hadassah/scripts/filters/news-filter.js?ver=1.1

js hadassah.moscow collected 2026-10-02 06:53:39 UTC 3,955 bytes, 119 lines download raw bytes

1jQuery(document).ready(function($) {
2    let currentPage = 1;
3    let totalPages = 1;
4
5    function getRealDate($input) {
6        const inputEl = $input[0] ? $input[0] : $input;
7        if (!inputEl) return '';
8        let val = inputEl.getAttribute('value') || inputEl.value || '';
9        return val.trim();
10    }
11
12    function getFilterData(paged = 1) {
13        const isModalOpen = $('#filterModalNews').hasClass('--open');
14
15        const fromInput = isModalOpen ? $('#news-modal-date-from') : $('#news-date-from');
16        const toInput   = isModalOpen ? $('#news-modal-date-to')   : $('#news-date-to');
17
18        const from = getRealDate(fromInput);
19        const to   = getRealDate(toInput);
20
21        console.log('date_from:', from, '| date_to:', to);
22
23        return {
24            action: 'filter_news_date',
25            date_from: from,
26            date_to: to,
27            paged: paged,
28            nonce: newsAjax.nonce
29        };
30    }
31
32    function filterNews(paged = 1, append = false) {
33        $.ajax({
34            url: ajaxurl,
35            type: 'POST',
36            data: getFilterData(paged),
37            beforeSend: function() {
38                $('.filter_results').addClass('loading');
39            },
40            success: function(res) {
41                if (res.success) {
42                    if (append) {
43                        $('.filter_results').append(res.data.content);
44                    } else {
45                        $('.filter_results').html(res.data.content);
46                    }
47
48                    totalPages = res.data.max_pages || 1;
49                    currentPage = paged;
50
51                    if (res.data.pagination) {
52                        $('#ajax-pagination').html(res.data.pagination);
53                    } else if (totalPages > 1) {
54                        $('#ajax-pagination').show();
55                    } else {
56                        $('#ajax-pagination').hide();
57                    }
58                } else {
59                    $('.filter_results').html('<p>По выбранному периоду новостей не найдено.</p>');
60                    $('#ajax-pagination').hide();
61                }
62            },
63            complete: function() {
64                $('.filter_results').removeClass('loading');
65            }
66        });
67    }
68
69    if (typeof initDatepickers === 'function') {
70        $('.js-datepicker-input input').each(function () {
71            initDatepickers(this);
72        });
73    } else {
74        console.warn('initDatepickers ещё не загружена. Проверь порядок подключения скриптов.');
75    }
76
77    $('.js-news-filter-search').on('click', function() {
78        currentPage = 1;
79        filterNews(1);
80    });
81
82    $('.js-news-filter-reset').on('click', function() {
83        $('#news-date-from, #news-date-to').val('');
84        currentPage = 1;
85        filterNews(1);
86    });
87
88    $('.js-news-filter-search-modal').on('click', function() {
89        currentPage = 1;
90        filterNews(1);
91        $('#filterModalNews').removeClass('--open _active');
92        $('body').removeClass('lock');
93    });
94
95    $('.js-news-filter-reset-modal').on('click', function() {
96        $('#news-modal-date-from, #news-modal-date-to').val('');
97        currentPage = 1;
98        filterNews(1);
99        $('#filterModalNews').removeClass('--open _active');
100        $('body').removeClass('lock');
101    });
102
103    $('[data-modal="filterModalNews"]').on('click', function() {
104        $('#filterModalNews').addClass('--open');
105        $('body').addClass('lock');
106    });
107
108    $('.js-modal-close').on('click', function() {
109        $('#filterModalNews').removeClass('--open _active');
110        $('body').removeClass('lock');
111    });
112
113    $(document).on('click', '#ajax-pagination a', function(e) {
114        e.preventDefault();
115        const page = parseInt($(this).data('page')) || 1;
116        currentPage = page;
117        filterNews(page);
118    });
119});

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.