PageSourceSearch

https://mof2h2.eu/wp-content/themes/mof_divi_child/custom-pagination.js

js mof2h2.eu collected 2026-10-09 01:11:37 UTC 2,514 bytes, 66 lines download raw bytes

1
2
3jQuery(document).ready(function ($) {
4    function updateButtonState(container) {
5        let currentPage = parseInt(container.data('current-page'));
6        let maxPages = parseInt(container.data('max-pages'));
7
8        // Disable Prev button on the first page
9        container.find('.pagination-prev').prop('disabled', currentPage <= 1);
10
11        // Disable Next button on the last page
12        container.find('.pagination-next').prop('disabled', currentPage >= maxPages);
13    }
14
15    $('.pagination-container button').on('click', function () {
16        let button = $(this);
17        let container = button.closest('.pagination-container');
18        let category = button.data('category'); // Get the category from the clicked button
19        let page = parseInt(button.data('page')); // Get the page from the clicked button
20        let maxPages = parseInt(container.data('max-pages'));
21
22        if (page < 1 || page > maxPages) {
23            return; // Prevent invalid page requests
24        }
25
26        // Ensure ajaxurl is set correctly
27        if (typeof ajaxurl === 'undefined' || ajaxurl.url === undefined) {
28            console.error('AJAX URL is not defined. Ensure ajaxurl is localized in your PHP.');
29            return;
30        }
31
32        $.ajax({
33            url: ajaxurl.url, // Use the localized AJAX URL
34            type: 'POST',
35            data: {
36                action: 'media_kit_pagination',
37                category: category, // Pass category explicitly
38                page: page, // Pass page explicitly
39            },
40            success: function (response) {
41                // Update the posts in the current category
42                button.closest('.category').find('.post-cards-container').html(response);
43
44                // Update the current page in the container
45                container.data('current-page', page);
46
47                // Update button states
48                updateButtonState(container);
49
50                // Update button data-page attributes
51                container.find('.pagination-prev').data('page', page - 1);
52                container.find('.pagination-next').data('page', page + 1);
53            },
54            error: function (xhr, status, error) {
55                console.error('AJAX Error:', status, error);
56            }
57        });
58    });
59
60    // Initial button state update on load
61    $('.pagination-container').each(function () {
62        updateButtonState($(this));
63    });
64});
65
66

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.