PageSourceSearch

https://islawynter.com/wp-content/plugins/author-website-templates…/posts-shortcode/posts-shortcode.js?ver=1.2

js islawynter.com collected 2026-10-04 05:07:18 UTC 8,586 bytes, 204 lines download raw bytes

1jQuery(document).ready(function($) {
2    // Function to load posts
3    function loadPosts(container, page, search = '', category = '', author = '', sortOrder = '') {
4        var $container = $('#' + container);
5        var $postsList = $container.find('.rswpthemes-awt-posts-list');
6        var postsPerPage = $postsList.data('posts-per-page');
7        var categories = $postsList.data('categories');
8        var postsPerRow = $postsList.data('posts-per-row');
9        var layout = $postsList.data('layout');
10
11        $.ajax({
12            url: rswpthemes_awt_filerable_posts_vars.ajax_url,
13            type: 'POST',
14            data: {
15                action: 'rswpthemes_awt_filerable_posts_load',
16                page: page,
17                search: search,
18                posts_per_page: postsPerPage,
19                categories: categories,
20                posts_per_row: postsPerRow,
21                category: category,
22                author: author,
23                sort_order: sortOrder,
24                layout: layout,
25                container: container
26            },
27            success: function(response) {
28                if (response.success) {
29                    if (page === 1) {
30                        $postsList.html(response.data.html);
31                    } else {
32                        $postsList.append(response.data.html);
33                    }
34
35                    var $loadMore = $container.find('.rswpthemes-awt-load-more-posts');
36                    if (page >= response.data.max_pages) {
37                        $loadMore.hide();
38                    } else {
39                        $loadMore.show().data('page', page + 1);
40                    }
41                } else {
42                    console.error('Failed to load posts:', response.data);
43                }
44            },
45            error: function(xhr, status, error) {
46                console.error('AJAX error loading posts:', error);
47            }
48        });
49    }
50
51    // Function to load a post in the popup
52    function loadPostInPopup($container, postId) {
53        var $popup = $container.find('.rswpthemes-awt-post-popup');
54        var $popupBody = $popup.find('.rswpthemes-awt-post-popup-body');
55        var $form = $container.find('.rswpthemes-awt-posts-search-form');
56        var search = $form.find('input[name="s"]').val();
57        var category = $form.find('select[name="category"]').val();
58        var author = $form.find('select[name="author"]').val();
59        var sortOrder = $form.find('select[name="sort_order"]').val();
60
61        $popupBody.html('<p>Loading...</p>');
62        $popup.addClass('active');
63
64        $.ajax({
65            url: rswpthemes_awt_filerable_posts_vars.ajax_url,
66            type: 'POST',
67            data: {
68                action: 'rswpthemes_awt_fetch_full_post',
69                post_id: postId,
70                search: search,
71                category: category,
72                author: author,
73                sort_order: sortOrder
74            },
75            success: function(response) {
76                if (response.success) {
77                    $popupBody.html(response.data.html);
78                    repositionPopupNavigation();
79                } else {
80                    $popupBody.html('<p>Error loading post: ' + response.data.message + '</p>');
81                }
82            },
83            error: function(xhr, status, error) {
84                $popupBody.html('<p>Error loading post: ' + error + '</p>');
85            }
86        });
87    }
88
89    // Initial load for all containers
90    $('.rswpthemes-awt-filterable-posts-container').each(function() {
91        loadPosts($(this).attr('id'), 1);
92        console.log('Initialized container:', $(this).attr('id'));
93    });
94
95    // Load more button click
96    $('.rswpthemes-awt-load-more-posts').on('click', function() {
97        var $this = $(this);
98        var container = $this.data('container');
99        var page = $this.data('page');
100        var $form = $('#' + container).find('.rswpthemes-awt-posts-search-form');
101        var search = $form.find('input[name="s"]').val();
102        var category = $form.find('select[name="category"]').val();
103        var author = $form.find('select[name="author"]').val();
104        var sortOrder = $form.find('select[name="sort_order"]').val();
105        loadPosts(container, page, search, category, author, sortOrder);
106    });
107
108    // Search form submit
109    $('.rswpthemes-awt-posts-search-form').on('submit', function(e) {
110        e.preventDefault();
111        var $this = $(this);
112        var container = $this.data('container');
113        var search = $this.find('input[name="s"]').val();
114        var category = $this.find('select[name="category"]').val();
115        var author = $this.find('select[name="author"]').val();
116        var sortOrder = $this.find('select[name="sort_order"]').val();
117        loadPosts(container, 1, search, category, author, sortOrder);
118    });
119
120    // Handle post title click to show popup
121    $(document).on('click', '.post-title-link', function(e) {
122        e.preventDefault();
123        var $this = $(this);
124        var postId = $this.data('post-id');
125        var $container = $this.closest('.rswpthemes-awt-filterable-posts-container');
126        loadPostInPopup($container, postId);
127    });
128
129    // Handle next/previous post navigation
130    $(document).on('click', '.rswpthemes-awt-post-popup-prev, .rswpthemes-awt-post-popup-next', function() {
131        var $this = $(this);
132        if ($this.hasClass('disabled')) return; // Do nothing if disabled
133
134        var postId = $this.data('post-id');
135        var $container = $this.closest('.rswpthemes-awt-filterable-posts-container');
136        loadPostInPopup($container, postId);
137    });
138
139    // Handle related post click
140    $(document).on('click', '.related-post-link', function(e) {
141        e.preventDefault();
142        var $this = $(this);
143        var postId = $this.data('post-id');
144        var $container = $this.closest('.rswpthemes-awt-filterable-posts-container');
145        loadPostInPopup($container, postId);
146    });
147
148    // Close the popup when the close button is clicked
149    $(document).on('click', '.rswpthemes-awt-post-popup-close', function() {
150        var $popup = $(this).closest('.rswpthemes-awt-post-popup');
151        $popup.removeClass('active');
152    });
153
154    // Close the popup when the overlay is clicked
155    $(document).on('click', '.rswpthemes-awt-post-popup-overlay', function() {
156        var $popup = $(this).closest('.rswpthemes-awt-post-popup');
157        $popup.removeClass('active');
158    });
159
160    // Handle category click to filter posts
161    $(document).on('click', '.filter-category', function() {
162        var $this = $(this);
163        var categoryId = $this.data('category-id');
164        var $container = $this.closest('.rswpthemes-awt-filterable-posts-container');
165        var $form = $container.find('.rswpthemes-awt-posts-search-form');
166
167        $form.find('input[name="s"]').val('');
168        $form.find('select[name="author"]').val('');
169        $form.find('select[name="category"]').val(categoryId);
170        $form.trigger('submit');
171
172        $container.find('.rswpthemes-awt-post-popup').removeClass('active');
173    });
174
175    // Handle author click to filter posts
176    $(document).on('click', '.filter-author', function() {
177        var $this = $(this);
178        var authorId = $this.data('author-id');
179        var $container = $this.closest('.rswpthemes-awt-filterable-posts-container');
180        var $form = $container.find('.rswpthemes-awt-posts-search-form');
181
182        $form.find('input[name="s"]').val('');
183        $form.find('select[name="category"]').val('');
184        $form.find('select[name="author"]').val(authorId);
185        $form.trigger('submit');
186
187        $container.find('.rswpthemes-awt-post-popup').removeClass('active');
188    });
189    $(document).on('keydown', function(e) {
190        if ($('.rswpthemes-awt-post-popup.active').length) {
191            if (e.key === 'ArrowLeft') {
192                $('.rswpthemes-awt-post-popup-prev:not(.disabled)').trigger('click');
193            } else if (e.key === 'ArrowRight') {
194                $('.rswpthemes-awt-post-popup-next:not(.disabled)').trigger('click');
195            }
196        }
197    });
198    // Close the popup with the "Esc" key
199    $(document).on('keydown', function(e) {
200        if (e.key === 'Escape') {
201            $('.rswpthemes-awt-post-popup.active').removeClass('active');
202        }
203    });
204});

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.