PluginProbe
WP Ultimate Post Grid / 1.6
WP Ultimate Post Grid v1.6
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
← All changes | js/grid.js +118 -369 2.7.01.6 View file →
@@ -7,16 +7,16 @@
7 7
8 8 var args = {
9 9 itemSelector: '.wpupg-item',
10 10 transitionDuration: wpupg_public.animationSpeed,
11 - hiddenStyle: wpupg_public.animationHide,
12 - visibleStyle: wpupg_public.animationShow
11 + hiddenStyle: {
12 + opacity: 0
13 + },
14 + visibleStyle: {
15 + opacity: 1
16 + }
13 17 };
14 18
15 - if(wpupg_public.rtl) {
16 - args.isOriginLeft = false;
17 - }
18 -
19 19 var layout_mode = container.data('layout-mode');
20 20 if(layout_mode) {
21 21 args.layoutMode = layout_mode;
22 22 }
@@ -26,194 +26,65 @@
26 26 isFitWidth: true
27 27 };
28 28 }
29 29
30 - container.isotopewpupg(args);
30 + container.isotope(args);
31 31
32 32 container.imagesLoaded( function() {
33 - container.isotopewpupg('layout');
33 + container.isotope('layout');
34 34 });
35 35
36 36 WPUltimatePostGrid.grids[grid_id] = {
37 - args: args,
38 37 container: container,
39 38 centered: container.data('centered'),
40 - data: window['wpupg_grid_' + container.data('grid-id')],
41 - id: container.data('grid-id'),
42 39 pages: [0],
43 40 page: 0,
44 - filter: '',
45 - filters: {},
46 - filter_text: false,
47 - filter_text_search: '',
48 - filter_text_posts: []
41 + filters: {}
49 42 };
50 43
51 44 WPUltimatePostGrid.checkLinks(grid_id);
52 - WPUltimatePostGrid.updatePosts(grid_id);
53 -
54 - jQuery(container).on('hover', '.wpupg-item', function(e) {
55 - var hovering = e.type == 'mouseenter';
56 - WPUltimatePostGrid.hoverGridItem(jQuery(this), hovering);
57 - });
58 -
59 - // Check for empty grid
60 - if(0 === container.find('.wpupg-item').length) {
61 - WPUltimatePostGrid.checkEmpty(container);
62 - } else {
63 - container.on('arrangeComplete', function() {
64 - WPUltimatePostGrid.checkEmpty(container);
65 - });
66 - }
67 45 };
68 46
69 -WPUltimatePostGrid.hoverGridItem = function(grid_item, hovering) {
70 - if(hovering) {
71 - grid_item.addClass('wpupg-hovering');
72 -
73 - grid_item.find('.wpupg-show-on-hover').each(function() {
74 - var item = jQuery(this),
75 - effect = item.data('hover-in'),
76 - duration = parseInt(item.data('hover-in-duration'));
77 -
78 - if(effect == 'fade') {
79 - item.fadeIn(duration);
80 - } else if(effect == 'slide') {
81 - item.slideDown(duration);
82 - } else {
83 - item.show();
84 - }
85 - });
86 -
87 - grid_item.find('.wpupg-hide-on-hover').each(function() {
88 - var item = jQuery(this),
89 - effect = item.data('hover-out'),
90 - duration = parseInt(item.data('hover-out-duration'));
91 -
92 - if(effect == 'fade') {
93 - item.fadeOut(duration);
94 - } else if(effect == 'slide') {
95 - item.slideUp(duration);
96 - } else {
97 - item.hide();
98 - }
99 - });
100 - } else {
101 - grid_item.removeClass('wpupg-hovering');
102 -
103 - grid_item.find('.wpupg-show-on-hover').each(function() {
104 - var item = jQuery(this),
105 - effect = item.data('hover-out'),
106 - duration = parseInt(item.data('hover-out-duration'));
107 -
108 - if(effect == 'fade') {
109 - item.fadeOut(duration);
110 - } else if(effect == 'slide') {
111 - item.slideUp(duration);
112 - } else {
113 - item.hide();
114 - }
115 - });
116 -
117 - grid_item.find('.wpupg-hide-on-hover').each(function() {
118 - var item = jQuery(this),
119 - effect = item.data('hover-in'),
120 - duration = parseInt(item.data('hover-in-duration'));
121 -
122 - if(effect == 'fade') {
123 - item.fadeIn(duration);
124 - } else if(effect == 'slide') {
125 - item.slideDown(duration);
126 - } else {
127 - item.show();
128 - }
129 - });
130 - }
131 -};
132 -
133 -WPUltimatePostGrid.updatePosts = function(grid_id) {
134 - var grid = WPUltimatePostGrid.grids[grid_id];
135 -
136 - var posts = [];
137 -
138 - grid.container.find('.wpupg-item').each(function() {
139 - var post_id = jQuery(this).data('id');
140 - posts.push(post_id);
141 - });
142 -
143 - WPUltimatePostGrid.grids[grid_id].posts = posts;
144 -};
145 -
146 47 WPUltimatePostGrid.filterGrid = function(grid_id) {
147 48 var grid = WPUltimatePostGrid.grids[grid_id];
148 49 var filters = [];
149 50
150 - if(grid.filter_text) {
151 - grid.filter = '';
152 - var posts = [];
51 + // Page filter
52 + if(grid.pagination_type != 'load_more') {
53 + var page = grid.page || 0;
54 + filters.push(['.wpupg-page-' + page]);
55 + }
153 56
154 - for(var i=0; i < grid.filter_text_posts.length; i++) {
155 - posts.push('#wpupg-container-post-' + grid.filter_text_posts[i]);
156 - posts.push('#wpurp-container-recipe-' + grid.filter_text_posts[i]);
157 - }
57 + // Taxonomy filters
58 + for(var taxonomy in grid.filters) {
59 + if(grid.filters.hasOwnProperty(taxonomy)) {
60 + var taxonomy_filters = grid.filters[taxonomy];
158 61
159 - if(posts.length == 0) {
160 - posts.push('no-result');
161 - }
62 + var match_one_filters = [];
63 + var match_all_filter = '';
162 64
163 - WPUltimatePostGrid.getFilterString(grid_id, '', [posts], 0);
164 - } else {
165 - // Page filter
166 - if(grid.pagination_type == 'pages') {
167 - var page = grid.page || 0;
168 - filters.push(['.wpupg-page-' + page]);
169 - }
170 -
171 - // Taxonomy filters
172 - for(var taxonomy in grid.filters) {
173 - if(grid.filters.hasOwnProperty(taxonomy)) {
174 - var taxonomy_filters = grid.filters[taxonomy];
175 -
176 - var match_one_filters = [];
177 - var match_all_filter = '';
178 - var filter = '';
179 -
180 - if(taxonomy_filters) {
181 - for(var i = 0; i < taxonomy_filters.length; i++) {
182 - filter = '.wpupg-tax-' + taxonomy + '-' + taxonomy_filters[i];
183 -
184 - if(grid.multiselect_type == 'match_one') {
185 - match_one_filters.push(filter);
186 - } else {
187 - match_all_filter += filter;
188 - }
65 + if(taxonomy_filters) {
66 + for(var i = 0; i < taxonomy_filters.length; i++) {
67 + if(grid.multiselect_type == 'match_one') {
68 + match_one_filters.push('.wpupg-tax-' + taxonomy + '-' + taxonomy_filters[i]);
69 + } else {
70 + match_all_filter += '.wpupg-tax-' + taxonomy + '-' + taxonomy_filters[i];
189 71 }
190 72 }
191 -
192 - if(grid.multiselect_type == 'match_one') {
193 - if(match_one_filters.length > 0) filters.push(match_one_filters);
194 - } else {
195 - if(match_all_filter !== '') filters.push([match_all_filter]);
196 - }
197 73 }
198 - }
199 74
200 - grid.filter = '';
201 - WPUltimatePostGrid.getFilterString(grid_id, '', filters, 0);
202 - if(grid.inverse) {
203 - if(grid.pagination_type == 'pages') {
204 - var page = grid.page || 0;
205 - var filter_without_page = grid.filter.replace('.wpupg-page-' + page, '');
206 -
207 - grid.filter = '.wpupg-page-' + page + ':not(' + filter_without_page + ')';
75 + if(grid.multiselect_type == 'match_one') {
76 + if(match_one_filters.length > 0) filters.push(match_one_filters);
208 77 } else {
209 - grid.filter = ':not(' + grid.filter + ')';
78 + if(match_all_filter !== '') filters.push([match_all_filter]);
210 79 }
211 80 }
212 81 }
213 82
214 - jQuery('#wpupg-grid-' + grid_id + '-empty').hide();
215 - grid.container.isotopewpupg({ filter: grid.filter });
83 + grid.filter = '';
84 + WPUltimatePostGrid.getFilterString(grid_id, '', filters, 0);
85 +
86 + grid.container.isotope({ filter: grid.filter });
216 87 grid.container.trigger('wpupgFiltered');
217 88 WPUltimatePostGrid.updateDeeplink();
218 89 };
219 90
@@ -227,18 +98,8 @@
227 98 }
228 99 }
229 100 };
230 101
231 -WPUltimatePostGrid.checkEmpty = function(container) {
232 - var grid_id = container.data('grid'),
233 - filter = WPUltimatePostGrid.grids[grid_id].filter || '.wpupg-item',
234 - visible_items = container.find(filter);
235 -
236 - if(filter !== '' && visible_items.length == 0) {
237 - jQuery('#wpupg-grid-' + grid_id + '-empty').slideDown(300);
238 - }
239 -};
240 -
241 102 WPUltimatePostGrid.updateDeeplink = function() {
242 103 var link = '';
243 104
244 105 for(var grid_id in WPUltimatePostGrid.grids) {
@@ -245,23 +106,18 @@
245 106 if(WPUltimatePostGrid.grids.hasOwnProperty(grid_id)) {
246 107 var grid = WPUltimatePostGrid.grids[grid_id];
247 108 var grid_link = '';
248 109
110 + // Page filter
111 + if(grid.page != 0) grid_link += '|p:' + (grid.page+1);
249 112
250 - if(grid.filter_text) {
251 - grid_link += '+s:' + grid.filter_text_search;
252 - } else {
253 - // Page filter
254 - if(grid.page != 0) grid_link += '+p:' + (grid.page+1);
113 + // Taxonomy filters
114 + for(var taxonomy in grid.filters) {
115 + if(grid.filters.hasOwnProperty(taxonomy)) {
116 + var taxonomy_filter = grid.filters[taxonomy];
255 117
256 - // Taxonomy filters
257 - for(var taxonomy in grid.filters) {
258 - if(grid.filters.hasOwnProperty(taxonomy)) {
259 - var taxonomy_filter = grid.filters[taxonomy];
260 -
261 - if(taxonomy_filter.length > 0) {
262 - grid_link += '+' + taxonomy + ':' + taxonomy_filter.join(',');
263 - }
118 + if(taxonomy_filter.length > 0) {
119 + grid_link += '|' + taxonomy + ':' + taxonomy_filter.join(',');
264 120 }
265 121 }
266 122 }
267 123
@@ -272,90 +128,27 @@
272 128 }
273 129 }
274 130 }
275 131
276 - WPUltimatePostGrid.replaceDeeplink(link);
132 + if(link == '') link = '*';
133 + document.location.hash = link;
277 134 };
278 135
279 -/**
280 - * Source: http://stackoverflow.com/questions/1397329/how-to-remove-the-hash-from-window-location-with-javascript-without-page-refresh/5298684#5298684
281 - */
282 -WPUltimatePostGrid.replaceDeeplink = function(link) {
283 - var scrollV, scrollH, loc = window.location;
284 - if ("replaceState" in history) {
285 - var hash = link == '' ? '' : '#' + link;
286 - history.replaceState("", document.title, loc.pathname + hash + loc.search);
287 - } else {
288 - // Prevent scrolling by storing the page's current scroll offset
289 - scrollV = document.documentElement.scrollTop || document.body.scrollTop;
290 - scrollH = document.documentElement.scrollLeft || document.body.scrollLeft;
291 -
292 - loc.hash = link;
293 -
294 - // Restore the scroll offset, should be flicker free
295 - document.documentElement.scrollTop = document.body.scrollTop = scrollV;
296 - document.documentElement.scrollLeft = document.body.scrollLeft = scrollH;
297 - }
298 -};
299 -
300 -WPUltimatePostGrid.preFilterGrid = function() {
301 - var link = document.location.hash;
302 - link = link.substr(1);
303 -
304 - if(!link) {
305 - var link = '';
306 -
307 - for(var grid_id in WPUltimatePostGrid.grids) {
308 - if(WPUltimatePostGrid.grids.hasOwnProperty(grid_id)) {
309 - var grid = WPUltimatePostGrid.grids[grid_id];
310 - var grid_link = '';
311 -
312 - if(grid.filter_data) {
313 - var pre_filter = grid.filter_data['pre_filter'];
314 -
315 - // Taxonomy filters
316 - for(var taxonomy in pre_filter) {
317 - if(pre_filter.hasOwnProperty(taxonomy)) {
318 - var taxonomy_filter = pre_filter[taxonomy];
319 -
320 - if(taxonomy_filter.length > 0) {
321 - grid_link += '+' + taxonomy + ':' + taxonomy_filter.join(',');
322 - }
323 - }
324 - }
325 - }
326 -
327 - if(grid_link != '') {
328 - if(link != '') link += '#';
329 - link += grid_id;
330 - link += grid_link;
331 - }
332 - }
333 - }
334 -
335 - WPUltimatePostGrid.replaceDeeplink(link);
336 - }
337 -};
338 -
339 136 WPUltimatePostGrid.restoreDeeplink = function() {
340 137 var link = document.location.hash;
341 138 link = link.substr(1);
342 139
343 - if(link) {
140 + if(link && link != '*') {
344 141 // Make sure characters are not URL encoded
345 142 link = link.replace('%23', '#');
346 143 link = link.replace('%7C', '|');
347 - link = link.replace('%2B', '+');
348 144 link = link.replace('%3A', ':');
349 145 link = link.replace('%2C', ',');
350 146
351 - // Backwards compatibility
352 - link = link.replace('|', '+');
353 -
354 147 var grids = link.split('#');
355 148
356 149 for(var i=0; i < grids.length; i++) {
357 - var parts = grids[i].split('+');
150 + var parts = grids[i].split('|');
358 151 var grid_id = parts[0];
359 152
360 153 for(var j=1; j < parts.length; j++) {
361 154 var filter = parts[j].split(':');
@@ -362,13 +155,11 @@
362 155
363 156 if(filter[0] == 'p') {
364 157 var page = parseInt(filter[1]) - 1;
365 158 WPUltimatePostGrid.updatePagination(jQuery('#wpupg-grid-' + grid_id + '-pagination'), page);
366 - } else if(filter[0] == 's') {
367 - WPUltimatePostGrid.updateFilter(jQuery('#wpupg-grid-' + grid_id + '-filter'), filter[0], 'text', filter[1]);
368 159 } else {
369 160 var terms = filter[1].split(',');
370 - WPUltimatePostGrid.updateFilter(jQuery('#wpupg-grid-' + grid_id + '-filter'), filter[0], 'terms', terms);
161 + WPUltimatePostGrid.updateFilter(jQuery('#wpupg-grid-' + grid_id + '-filter'), filter[0], terms);
371 162 }
372 163 }
373 164 }
374 165 }
@@ -375,18 +166,17 @@
375 166 };
376 167
377 168 WPUltimatePostGrid.checkLinks = function(grid_id) {
378 169 var grid = WPUltimatePostGrid.grids[grid_id];
379 - var default_link_type = grid.container.data('link-type');
170 + var link_type = grid.container.data('link-type');
380 171 var link_target = grid.container.data('link-target');
381 - var link_rel = link_target == 'post' ? '' : ' rel="lightbox"';
382 172
383 - if(default_link_type != 'none') {
173 + if(link_type != 'none') {
384 174 grid.container.find('.wpupg-item').each(function() {
385 175 var item = jQuery(this);
386 176
387 177 // Remove links from item
388 - item.find('a:not(.wpupg-keep-link, .wpurp-recipe-favorite, .wpurp-recipe-add-to-shopping-list, .wpurp-recipe-add-to-meal-plan, .wpurp-recipe-print-button, .wpurp-recipe-grid-link)').each(function() {
178 + item.find('a:not(.wpupg-keep-link, .wpurp-recipe-favorite, .wpurp-recipe-add-to-shopping-list, .wpurp-recipe-print-button, .wpurp-recipe-grid-link)').each(function() {
389 179 var link = jQuery(this);
390 180 if(link.parents('.sharrre').length == 0) {
391 181 link.replaceWith(function() { return link.contents(); });
392 182 }
@@ -391,30 +181,28 @@
391 181 link.replaceWith(function() { return link.contents(); });
392 182 }
393 183 });
394 184
395 - var link = item.data('custom-link') ? item.data('custom-link') : ( link_target == 'post' ? item.data('permalink') : item.data('image') );
396 - var link_behaviour = item.data('custom-link-behaviour');
185 + var link = link_target == 'post' ? item.data('permalink') : item.data('image');
186 + var rel = link_target == 'post' ? '' : ' rel="lightbox"';
397 187
398 - var link_type = link_behaviour == '_blank' || link_behaviour == '_self' ? link_behaviour : default_link_type;
399 -
400 188 // Add link around item
401 - if (link_behaviour !== 'none' && link && item.parent('a').length == 0) {
402 - item.wrap('<a href="' + link + '" target="' + link_type + '"' + link_rel + ' class="' + wpupg_public.link_class + '"></a>');
189 + if (link && item.parent('a').length == 0) {
190 + item.wrap('<a href="' + link + '" target="' + link_type + '"' + rel + '></a>');
403 191 }
404 192 });
405 193 }
406 194 };
407 195
408 -WPUltimatePostGrid.updateFilter = function(container, taxonomy, type, terms) {
409 - var filter_type = container.data('type');
410 - var func = 'updateFilter' + filter_type.charAt(0).toUpperCase() + filter_type.slice(1);
196 +WPUltimatePostGrid.updateFilter = function(container, taxonomy, terms) {
197 + var type = container.data('type');
198 + var func = 'updateFilter' + type.charAt(0).toUpperCase() + type.slice(1);
411 199 if(typeof WPUltimatePostGrid[func] == 'function') {
412 - WPUltimatePostGrid[func](container, taxonomy, type, terms);
200 + WPUltimatePostGrid[func](container, taxonomy, terms);
413 201 }
414 202 };
415 203
416 -WPUltimatePostGrid.updateFilterIsotope = function(container, taxonomy, type, terms) {
204 +WPUltimatePostGrid.updateFilterIsotope = function(container, taxonomy, terms) {
417 205 for(var i = 0; i < terms.length; i++) {
418 206 container.find('.wpupg-filter-tag-' + terms[i]).click();
419 207 }
420 208 };
@@ -423,73 +211,69 @@
423 211 var grid_id = container.data('grid');
424 212
425 213 WPUltimatePostGrid.grids[grid_id].multiselect = container.data('multiselect');
426 214 WPUltimatePostGrid.grids[grid_id].multiselect_type = container.data('multiselect-type');
427 - WPUltimatePostGrid.grids[grid_id].inverse = container.data('inverse');
428 215
429 - container.find('.wpupg-filter-isotope-term').on('click keydown', function(e) {
430 - // On click, space or enter.
431 - if(e.isTrigger || e.which === 1 || e.which === 13 || e.which === 32) {
432 - var filter_item = jQuery(this);
433 - var taxonomy = filter_item.data('taxonomy');
434 - var filter_all = filter_item.data('filter') == undefined;
435 - var filter_term = filter_item.data('filter');
436 -
437 - var filters = [];
438 -
439 - if(WPUltimatePostGrid.grids[grid_id].multiselect && !filter_all) {
440 - // Make sure "All" is not selected
441 - filter_item.parents('.wpupg-filter-isotope').find('.wpupg-filter-tag-').removeClass('active').trigger('checkActiveFilter');
442 -
443 - filters = WPUltimatePostGrid.grids[grid_id].filters || [];
444 -
445 - if(filters[taxonomy] == undefined) filters[taxonomy] = [];
446 -
447 - var term_index = filters[taxonomy].indexOf(filter_term);
448 - if(term_index == -1) {
449 - // Term was not select before, add
450 - filter_item.addClass('active').trigger('checkActiveFilter');
451 - filters[taxonomy].push(filter_term);
452 - } else {
453 - // Term was already selected, remove
454 - filter_item.removeClass('active').trigger('checkActiveFilter');
455 - filters[taxonomy].splice(term_index, 1);
456 -
457 - // Set "All" active if no terms left
458 - var nbr_terms = 0;
459 -
460 - for(var filter_taxonomy in filters) {
461 - if(filters.hasOwnProperty(filter_taxonomy)) {
462 - var filter_taxonomy_terms = filters[filter_taxonomy];
463 -
464 - if(filter_taxonomy_terms) {
465 - nbr_terms += filter_taxonomy_terms.length;
466 - }
216 + container.find('.wpupg-filter-isotope-term').click(function() {
217 + var filter_item = jQuery(this);
218 + var taxonomy = filter_item.data('taxonomy');
219 + var filter_all = filter_item.data('filter') == undefined;
220 + var filter_term = filter_item.data('filter');
221 +
222 + var filters = [];
223 +
224 + if(WPUltimatePostGrid.grids[grid_id].multiselect && !filter_all) {
225 + // Make sure "All" is not selected
226 + filter_item.siblings('.wpupg-filter-tag-').removeClass('active').trigger('checkActiveFilter');
227 +
228 + filters = WPUltimatePostGrid.grids[grid_id].filters || [];
229 +
230 + if(filters[taxonomy] == undefined) filters[taxonomy] = [];
231 +
232 + var term_index = filters[taxonomy].indexOf(filter_term);
233 + if(term_index == -1) {
234 + // Term was not select before, add
235 + filter_item.addClass('active').trigger('checkActiveFilter');
236 + filters[taxonomy].push(filter_term);
237 + } else {
238 + // Term was already selected, remove
239 + filter_item.removeClass('active').trigger('checkActiveFilter');
240 + filters[taxonomy].splice(term_index, 1);
241 +
242 + // Set "All" active if no terms left
243 + var nbr_terms = 0;
244 +
245 + for(var filter_taxonomy in filters) {
246 + if(filters.hasOwnProperty(filter_taxonomy)) {
247 + var filter_taxonomy_terms = filters[filter_taxonomy];
248 +
249 + if(filter_taxonomy_terms) {
250 + nbr_terms += filter_taxonomy_terms.length;
467 251 }
468 252 }
469 -
470 - if(nbr_terms == 0) {
471 - filter_item.parents('.wpupg-filter-isotope').find('.wpupg-filter-tag-').addClass('active').trigger('checkActiveFilter');
472 - }
473 253 }
474 - } else {
475 - filter_item.parents('.wpupg-filter-isotope').find('.wpupg-filter-isotope-term').removeClass('active').trigger('checkActiveFilter');
476 - filter_item.addClass('active').trigger('checkActiveFilter');
477 -
478 - if(!filter_all) {
479 - filters[taxonomy] = [filter_term];
480 - }
254 +
255 + if(nbr_terms == 0) {
256 + filter_item.siblings('.wpupg-filter-tag-').addClass('active').trigger('checkActiveFilter');
257 + }
481 258 }
482 -
483 - WPUltimatePostGrid.grids[grid_id].filters = filters;
484 - WPUltimatePostGrid.filterGrid(grid_id);
259 + } else {
260 + filter_item.siblings('.wpupg-filter-isotope-term').removeClass('active').trigger('checkActiveFilter');
261 + filter_item.addClass('active').trigger('checkActiveFilter');
262 +
263 + if(!filter_all) {
264 + filters[taxonomy] = [filter_term];
265 + }
485 266 }
267 +
268 + WPUltimatePostGrid.grids[grid_id].filters = filters;
269 + WPUltimatePostGrid.filterGrid(grid_id);
486 270 });
487 271
488 272 var filter_type = container.data('filter-type');
489 273 var filter_items = container.find('.wpupg-filter-item');
490 274
491 - if(filter_type == 'isotope' || filter_type == 'text_isotope') {
275 + if(filter_type == 'isotope') {
492 276 var margin = container.data('margin-vertical') + 'px ' + container.data('margin-horizontal') + 'px';
493 277 var padding = container.data('padding-vertical') + 'px ' + container.data('padding-horizontal') + 'px';
494 278 var border = container.data('border-width') + 'px solid ' + container.data('border-color');
495 279 var background_color = container.data('background-color');
@@ -545,14 +329,11 @@
545 329 };
546 330
547 331 WPUltimatePostGrid.updatePagination = function(container, page) {
548 332 var type = container.data('type');
549 -
550 - if(type) {
551 - var func = 'updatePagination' + type.charAt(0).toUpperCase() + type.slice(1);
552 - if(typeof WPUltimatePostGrid[func] == 'function') {
553 - WPUltimatePostGrid[func](container, page);
554 - }
333 + var func = 'updatePagination' + type.charAt(0).toUpperCase() + type.slice(1);
334 + if(typeof WPUltimatePostGrid[func] == 'function') {
335 + WPUltimatePostGrid[func](container, page);
555 336 }
556 337 };
557 338
558 339 WPUltimatePostGrid.updatePaginationPages = function(container, page) {
@@ -567,10 +348,8 @@
567 348 pagination_item.siblings('.wpupg-pagination-term').removeClass('active').trigger('checkActiveFilter');
568 349
569 350 var page = parseInt(pagination_item.addClass('active').trigger('checkActiveFilter').data('page'));
570 351
571 - WPUltimatePostGrid.scrollTo(WPUltimatePostGrid.grids[grid_id].container);
572 -
573 352 if(WPUltimatePostGrid.grids[grid_id].pages.indexOf(page) !== -1) {
574 353 WPUltimatePostGrid.grids[grid_id].page = page;
575 354 WPUltimatePostGrid.filterGrid(grid_id);
576 355 } else {
@@ -587,17 +366,21 @@
587 366
588 367 // Get recipes through AJAX
589 368 jQuery.post(wpupg_public.ajax_url, data, function(html) {
590 369 var posts = jQuery(html).toArray();
370 + WPUltimatePostGrid.grids[grid_id].container.isotope('insert', posts);
371 + WPUltimatePostGrid.grids[grid_id].page = page;
372 + WPUltimatePostGrid.filterGrid(grid_id);
373 + WPUltimatePostGrid.checkLinks(grid_id);
591 374
592 - WPUltimatePostGrid.grids[grid_id].page = page;
593 - WPUltimatePostGrid.insertPosts(grid_id, posts);
375 + WPUltimatePostGrid.grids[grid_id].container.imagesLoaded( function() {
376 + WPUltimatePostGrid.grids[grid_id].container.isotope('layout');
377 + });
594 378
595 379 pagination_item.removeClass('wpupg-spinner');
596 380 pagination_item.css('color', WPUltimatePostGrid.grids[grid_id].pagination_style.active_text_color);
597 381
598 382 WPUltimatePostGrid.grids[grid_id].pages.push(page);
599 - WPUltimatePostGrid.updatePosts(grid_id);
600 383 });
601 384 }
602 385 });
603 386
@@ -670,40 +453,8 @@
670 453 }).trigger('checkActiveFilter');
671 454 });
672 455 };
673 456
674 -WPUltimatePostGrid.insertPosts = function(grid_id, posts) {
675 - var scrollV = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0,
676 - scrollH = document.documentElement.scrollLeft || document.body.scrollLeft;
677 -
678 - WPUltimatePostGrid.grids[grid_id].container.isotopewpupg('destroy');
679 -
680 - WPUltimatePostGrid.grids[grid_id].container.append(posts);
681 - WPUltimatePostGrid.grids[grid_id].container.isotopewpupg(WPUltimatePostGrid.grids[grid_id].args);
682 -
683 - // Restore the scroll offset, should be flicker free
684 - jQuery(window).scrollTop(scrollV);
685 - document.documentElement.scrollLeft = document.body.scrollLeft = scrollH;
686 -
687 - WPUltimatePostGrid.updatePosts(grid_id);
688 - WPUltimatePostGrid.checkLinks(grid_id);
689 - WPUltimatePostGrid.filterGrid(grid_id);
690 -
691 - WPUltimatePostGrid.grids[grid_id].container.imagesLoaded( function() {
692 - WPUltimatePostGrid.grids[grid_id].container.isotopewpupg('layout');
693 - WPUltimatePostGrid.grids[grid_id].loading = false;
694 - });
695 -};
696 -
697 -WPUltimatePostGrid.scrollTo = function(target) {
698 - var scroll_to = target.offset().top - 50;
699 - scroll_to = scroll_to < 0 ? 0 : scroll_to;
700 -
701 - jQuery('html,body').animate({
702 - scrollTop: scroll_to
703 - }, 500);
704 -};
705 -
706 457 jQuery(document).ready(function($) {
707 458 $('.wpupg-grid').each(function() {
708 459 WPUltimatePostGrid.initGrid($(this));
709 460 });
@@ -713,9 +464,8 @@
713 464 var grid_id = container.data('grid');
714 465 var type = container.data('type');
715 466
716 467 WPUltimatePostGrid.grids[grid_id].filter_type = type;
717 - WPUltimatePostGrid.grids[grid_id].filter_data = window['wpupg_filter_' + WPUltimatePostGrid.grids[grid_id].id];
718 468
719 469 var func = 'initFilter' + type.charAt(0).toUpperCase() + type.slice(1);
720 470 if(typeof WPUltimatePostGrid[func] == 'function') {
721 471 WPUltimatePostGrid[func](container);
@@ -733,7 +483,6 @@
733 483 if(typeof WPUltimatePostGrid[func] == 'function') {
734 484 WPUltimatePostGrid[func](container);
735 485 }
736 486 });
737 - WPUltimatePostGrid.preFilterGrid();
738 487 WPUltimatePostGrid.restoreDeeplink();
739 488 });