PageSourceSearch

https://www.seniorlifestyle.com/wp-content/themes/Avada-Child-Them…/dist/js/blog-listing.js?ver=1790925732

js seniorlifestyle.com collected 2026-10-02 07:23:29 UTC 3,106 bytes, 100 lines download raw bytes

1/**
2 * AJAX Blog Listing - JavaScript Logic
3 * Handles filtering (Search, Category, Year) and Pagination.
4 */
5(function($) {
6    'use strict';
7
8    $(document).ready(function() {
9        const $container = $('.slc-blog-listing');
10        if (!$container.length) return;
11
12        const postType = $container.data('posttype');
13        const $results = $('#slc-blog-results');
14        const $searchField = $('#slc-blog-search');
15        const $categoryField = $('#slc-blog-category');
16        const $yearField = $('#slc-blog-year');
17
18        /**
19         * Fetch posts via AJAX.
20         * @param {number} page - The page number to fetch.
21         */
22        function fetchPosts(page = 1) {
23            // Show loading state
24            $results.css('opacity', '0.5').addClass('loading');
25
26            const data = {
27                action: 'slc_blog_filter',
28                nonce: slc_blog_ajax.nonce,
29                posttype: postType,
30                paged: page,
31                search: $searchField.val(),
32                category: $categoryField.val(),
33                year: $yearField.val()
34            };
35
36            $.post(slc_blog_ajax.ajax_url, data, function(response) {
37                if (response.success) {
38                    $results.html(response.data.html);
39                    // Smooth scroll to results
40                    $('html, body').animate({
41                        scrollTop: $container.offset().top - 100
42                    }, 500);
43                } else {
44                    console.error('AJAX Error:', response);
45                }
46                $results.css('opacity', '1').removeClass('loading');
47            });
48        }
49
50        // --- FILTER EVENTS ---
51
52        // Category / Year Change
53        $categoryField.on('change', function() {
54            fetchPosts(1);
55        });
56
57        $yearField.on('change', function() {
58            fetchPosts(1);
59        });
60
61        // Search - Trigger on Button click or Enter key
62        $('.slc-blog-filters__search-btn').on('click', function(e) {
63            e.preventDefault();
64            fetchPosts(1);
65        });
66
67        $searchField.on('keypress', function(e) {
68            if (e.which === 13) { // Enter key
69                e.preventDefault();
70                fetchPosts(1);
71            }
72        });
73
74        // Clear Filters
75        $('#slc-blog-clear').on('click', function(e) {
76            e.preventDefault();
77            $searchField.val('');
78            $categoryField.val('');
79            $yearField.val('');
80            fetchPosts(1);
81        });
82
83        // --- PAGINATION EVENTS ---
84
85        $(document).on('click', '.slc-blog-pagination__link', function(e) {
86            e.preventDefault();
87            const $this = $(this);
88            const parent = $this.parent();
89
90            // Prevent fetching if active or disabled
91            if (parent.hasClass('slc-blog-pagination__item--active') || parent.hasClass('slc-blog-pagination__item--disabled')) {
92                return;
93            }
94
95            const page = $this.data('page');
96            fetchPosts(page);
97        });
98    });
99
100})(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.