PageSourceSearch

https://investinafrica.com/wp-content/themes/alone/js/posts-loadmore.js?ver=6.8.2

js investinafrica.com collected 2026-10-02 12:58:21 UTC 3,308 bytes, 83 lines download raw bytes

1jQuery(function($){
2	if( $('.posts-list').hasClass('loadmore-button') ) {
3        $('.posts-loadmore .btn-loadmore').click(function(event){
4			event.preventDefault();
5	
6			var button = $(this),
7				data = {
8				'action': 'posts_loadmore',
9				'query': posts_loadmore_params.posts, // that's how we get params from wp_localize_script() function
10				'page' : posts_loadmore_params.current_page
11			};
12	 
13			$.ajax({ // you can also use $.post here
14				url : posts_loadmore_params.ajaxurl, // AJAX handler
15				data : data,
16				type : 'POST',
17				beforeSend : function ( xhr ) {
18					button.text('Loading...'); // change the button text, you can also add a preloader image
19				},
20				success : function( data ){
21					
22					if( data ) { 
23						button.text( 'More Posts' ).parents('.site-main').find('.posts-list').append(data); // insert new posts
24						posts_loadmore_params.current_page++;
25	 
26						if ( posts_loadmore_params.current_page == posts_loadmore_params.max_page ) 
27							button.remove(); // if last page, remove the button
28	 
29						// you can also fire the "post-load" event here if you use a plugin that requires it
30						// $( document.body ).trigger( 'post-load' );
31					} else {
32						button.remove(); // if no data, remove the button as well
33					}
34				}
35			});
36		});
37
38    }
39
40	if( $('.posts-list').hasClass('loadmore-scroll') ) {
41        var canBeLoaded = true, // this param allows to initiate the AJAX call only if necessary
42	        bottomOffset = $('.posts-list').offset().top + $('.posts-list').height(); // the distance (in px) from the page bottom when you want to load more posts
43
44        $(window).scroll(function(){
45            var data = {
46                'action': 'posts_loadmore',
47                'query': posts_loadmore_params.posts, // that's how we get params from wp_localize_script() function
48                'page' : posts_loadmore_params.current_page
49            };
50
51            if( $(document).scrollTop() > ( $(document).height() - bottomOffset ) && canBeLoaded == true ){
52                $.ajax({
53                    url : posts_loadmore_params.ajaxurl,
54                    data:data,
55                    type:'POST',
56                    beforeSend: function( xhr ){
57                        // you can also add your own preloader here
58                        // you see, the AJAX call is in process, we shouldn't run it again until complete
59                        canBeLoaded = false; 
60                        
61                        $('.posts-loadmore').html('Loading...');
62                    },
63                    success:function(data){
64                        if( data ) {
65                            $('.posts-list').append(data); // insert new posts
66                            posts_loadmore_params.current_page++;
67
68                            canBeLoaded = true; 
69
70                            if ( posts_loadmore_params.current_page == posts_loadmore_params.max_page ) 
71                            $('.posts-loadmore').remove(); // if last page, remove the button
72
73                            // you can also fire the "post-load" event here if you use a plugin that requires it
74                            // $( document.body ).trigger( 'post-load' );
75                        }
76                    }
77                });
78            }
79        });
80
81    }
82	
83});

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.