PageSourceSearch

https://www.foodandwateraction.org/wp-content/plugins/post-grid/assets/frontend/js/scripts.js?ver=7.0.5

js foodandwateraction.org collected 2026-09-24 21:00:22 UTC 6,537 bytes, 270 lines download raw bytes

1jQuery(document).ready(function($)
2	{
3
4
5
6		$(window).resize(function() {
7			
8			//var windowWidth = $(window).width();
9			//var width = $('#post-grid-7 .grid-items').width();
10			
11			//$('.post-grid-debug').html(width+' - '+windowWidth);
12			
13		});
14
15
16
17		$(document).on('keyup', '.post-grid .nav-search .search', function(e)
18			{
19				var keyword = $(this).val();
20				var grid_id = $(this).attr('grid_id');
21                var key = e.which;
22
23                if(key == 13){
24                    // the enter key code
25                    var is_reset = 'yes';
26
27                    $(this).addClass('loading');
28
29                    $('.pagination').fadeOut();
30
31                    $.ajax({
32                        type: 'POST',
33                        context: this,
34                        url:post_grid_ajax.post_grid_ajaxurl,
35                        data: {"action": "post_grid_ajax_search", "grid_id":grid_id,"keyword":keyword,"is_reset":is_reset,},
36                        success: function(data){
37
38                            $('#post-grid-'+grid_id+' .grid-items').html(data);
39                            $(this).removeClass('loading');
40                        }
41                    });
42
43                }
44                else{
45                    var is_reset = 'no';
46                    if(keyword.length>3){
47                        $(this).addClass('loading');
48
49                        $('.pagination').fadeOut();
50
51                        $.ajax({
52                            type: 'POST',
53                            context: this,
54                            url:post_grid_ajax.post_grid_ajaxurl,
55                            data: {"action": "post_grid_ajax_search", "grid_id":grid_id,"keyword":keyword,"is_reset":is_reset,},
56                            success: function(data){
57
58                                $('#post-grid-'+grid_id+' .grid-items').html(data);
59                                $(this).removeClass('loading');
60                            }
61                        });
62                    }
63
64                }
65
66
67
68				// if(keyword.length>3){
69				// 	$(this).addClass('loading');
70				//
71				// 	$('.pagination').fadeOut();
72				//
73				// 	$.ajax(
74				// 		{
75				// 	type: 'POST',
76				// 	context: this,
77				// 	url:post_grid_ajax.post_grid_ajaxurl,
78				// 	data: {"action": "post_grid_ajax_search", "grid_id":grid_id,"keyword":keyword,},
79				// 	success: function(data)
80				// 			{
81				//
82				// 				$('.post-grid .grid-items').html(data);
83				// 				$(this).removeClass('loading');
84                //
85				// 			}
86				// 		});
87                //
88                //
89				//
90				// 	}
91				
92			})
93
94
95
96
97
98		$(document).on('click', '.post-grid .nav-filter .filter', function()
99			{
100				$('.post-grid .nav-filter .filter').removeClass('active');
101				
102				
103				if($(this).hasClass('active'))
104					{
105						//$(this).removeClass('active');
106					}
107				else
108					{
109						$(this).addClass('active');
110					}
111				
112			})
113
114
115
116
117
118
119		$(document).on('click', '.post-grid .paginate-ajax a.page-numbers', function(event)
120			{
121				event.preventDefault();
122				
123				$('.post-grid .paginate-ajax .page-numbers').removeClass('current');
124				
125				$(this).addClass('current');
126				
127				var current_page = parseInt($(this).text());								
128				var paged = parseInt($(this).attr('paged'));
129				var grid_id = parseInt($(this).parent().attr('grid-id'));
130
131				$.ajax(
132					{
133				type: 'POST',
134				context: this,
135				url:post_grid_ajax.post_grid_ajaxurl,
136				data: {"action": "post_grid_paginate_ajax", "grid_id":grid_id,"current_page":current_page},
137				success: function(data)
138						{	
139
140						var response 		= JSON.parse(data)
141						var data 	= response['html'];	
142						var pagination 	= response['pagination'];							
143							
144							if(post_grid_masonry_enable=='yes'){
145								
146									var $grid = $('#post-grid-'+grid_id+' .grid-items').masonry({});
147									$grid.masonry('destroy');
148									$grid.html( data ).masonry();
149
150									$grid.masonry( 'reloadItems' );
151									$grid.masonry( 'layout' );
152
153									$('#post-grid-'+grid_id+' .grid-items').masonry({"isFitWidth": true});
154									$('#paginate-ajax-'+grid_id).html( pagination );
155
156								}
157							else{
158									$('#post-grid-'+grid_id+' .grid-items').html( data );
159									$('#paginate-ajax-'+grid_id).html( pagination );									
160									
161								}
162
163
164							$("#paginate-ajax-"+grid_id).ScrollTo({
165								duration: 1000,
166								easing: 'linear'
167							});
168
169
170
171
172							
173						}
174					});
175
176			})
177
178
179
180
181
182
183
184		$(document).on('click', '.post-grid .load-more', function()
185			{
186				
187				
188				var paged = parseInt($(this).attr('paged'));
189				var per_page = parseInt($(this).attr('per_page'));
190				var grid_id = parseInt($(this).attr('grid_id'));
191				var terms = $('#post-grid-'+grid_id+' .nav-filter .filter.active').attr('terms-id');
192				
193				//alert(terms);
194				
195				if(terms == null || terms == '')
196					{
197						terms = '';
198					}
199						
200				$(this).addClass('loading');
201
202				
203				$.ajax(
204					{
205				type: 'POST',
206				context: this,
207				url:post_grid_ajax.post_grid_ajaxurl,
208				data: {"action": "post_grid_ajax_load_more", "grid_id":grid_id,"per_page":per_page,"paged":paged,"terms":terms,},
209				success: function(data)
210						{	
211
212											
213
214						  // append items to grid
215							
216							// add and lay out newly appended items
217							
218							if(post_grid_masonry_enable=='yes'){
219								
220									var $grid = $('#post-grid-'+grid_id+' .grid-items').masonry({});
221									$grid.masonry('destroy');
222									$grid.append( data ).masonry( 'appended', data, true );
223									
224									
225									$grid.masonry( 'reloadItems' );
226									$grid.masonry( 'layout' );
227									
228		
229									$('#post-grid-'+grid_id+' .grid-items').masonry({"isFitWidth": true});
230								
231								
232								}
233							else{
234									$('#post-grid-'+grid_id+' .grid-items').append( data );
235								}
236
237/*
238
239							 $('html, body').animate({
240									scrollTop: parseInt($("#load-more-"+grid_id).offset().top)
241								}, 1000);
242
243*/
244
245							$("#load-more-"+grid_id).ScrollTo({
246								duration: 2000,
247								easing: 'linear'
248							});
249
250
251							$(this).attr('paged',(paged+1));
252						
253							if($(this).hasClass('loading')){
254								
255									$(this).removeClass('loading');
256								}
257							
258						}
259					});
260
261				//alert(per_page);
262			})
263
264	});	
265
266
267
268
269
270

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.