| @@ -7,14 +7,10 @@ | ||
| 7 | 7 | |
| 8 | 8 | var args = { |
| 9 | 9 | itemSelector: '.wpupg-item', |
| 10 | 10 | transitionDuration: wpupg_public.animationSpeed, |
| 11 | - hiddenStyle: { | |
| 12 | - opacity: 0 | |
| 13 | - }, | |
| 14 | - visibleStyle: { | |
| 15 | - opacity: 1 | |
| 16 | - } | |
| 11 | + hiddenStyle: wpupg_public.animationHide, | |
| 12 | + visibleStyle: wpupg_public.animationShow | |
| 17 | 13 | }; |
| 18 | 14 | |
| 19 | 15 | if(wpupg_public.rtl) { |
| 20 | 16 | args.isOriginLeft = false; |
| @@ -37,8 +33,9 @@ | ||
| 37 | 33 | container.isotope('layout'); |
| 38 | 34 | }); |
| 39 | 35 | |
| 40 | 36 | WPUltimatePostGrid.grids[grid_id] = { |
| 37 | + args: args, | |
| 41 | 38 | container: container, |
| 42 | 39 | centered: container.data('centered'), |
| 43 | 40 | data: window['wpupg_grid_' + container.data('grid-id')], |
| 44 | 41 | id: container.data('grid-id'), |
| @@ -43,9 +40,13 @@ | ||
| 43 | 40 | data: window['wpupg_grid_' + container.data('grid-id')], |
| 44 | 41 | id: container.data('grid-id'), |
| 45 | 42 | pages: [0], |
| 46 | 43 | page: 0, |
| 47 | - filters: {} | |
| 44 | + filter: '', | |
| 45 | + filters: {}, | |
| 46 | + filter_text: false, | |
| 47 | + filter_text_search: '', | |
| 48 | + filter_text_posts: [] | |
| 48 | 49 | }; |
| 49 | 50 | |
| 50 | 51 | WPUltimatePostGrid.checkLinks(grid_id); |
| 51 | 52 | WPUltimatePostGrid.updatePosts(grid_id); |
| @@ -53,8 +54,13 @@ | ||
| 53 | 54 | jQuery(container).on('hover', '.wpupg-item', function(e) { |
| 54 | 55 | var hovering = e.type == 'mouseenter'; |
| 55 | 56 | WPUltimatePostGrid.hoverGridItem(jQuery(this), hovering); |
| 56 | 57 | }); |
| 58 | + | |
| 59 | + // Check for empty grid | |
| 60 | + container.on('arrangeComplete', function() { | |
| 61 | + WPUltimatePostGrid.checkEmpty(container); | |
| 62 | + }); | |
| 57 | 63 | }; |
| 58 | 64 | |
| 59 | 65 | WPUltimatePostGrid.hoverGridItem = function(grid_item, hovering) { |
| 60 | 66 | if(hovering) { |
| @@ -136,56 +142,72 @@ | ||
| 136 | 142 | WPUltimatePostGrid.filterGrid = function(grid_id) { |
| 137 | 143 | var grid = WPUltimatePostGrid.grids[grid_id]; |
| 138 | 144 | var filters = []; |
| 139 | 145 | |
| 140 | - // Page filter | |
| 141 | - if(grid.pagination_type == 'pages') { | |
| 142 | - var page = grid.page || 0; | |
| 143 | - filters.push(['.wpupg-page-' + page]); | |
| 144 | - } | |
| 146 | + if(grid.filter_text) { | |
| 147 | + grid.filter = ''; | |
| 148 | + var posts = []; | |
| 145 | 149 | |
| 146 | - // Taxonomy filters | |
| 147 | - for(var taxonomy in grid.filters) { | |
| 148 | - if(grid.filters.hasOwnProperty(taxonomy)) { | |
| 149 | - var taxonomy_filters = grid.filters[taxonomy]; | |
| 150 | + for(var i=0; i < grid.filter_text_posts.length; i++) { | |
| 151 | + posts.push('#wpupg-container-post-' + grid.filter_text_posts[i]); | |
| 152 | + } | |
| 150 | 153 | |
| 151 | - var match_one_filters = []; | |
| 152 | - var match_all_filter = ''; | |
| 153 | - var filter = ''; | |
| 154 | + if(posts.length == 0) { | |
| 155 | + posts.push('no-result'); | |
| 156 | + } | |
| 154 | 157 | |
| 155 | - if(taxonomy_filters) { | |
| 156 | - for(var i = 0; i < taxonomy_filters.length; i++) { | |
| 157 | - filter = '.wpupg-tax-' + taxonomy + '-' + taxonomy_filters[i]; | |
| 158 | + WPUltimatePostGrid.getFilterString(grid_id, '', [posts], 0); | |
| 159 | + } else { | |
| 160 | + // Page filter | |
| 161 | + if(grid.pagination_type == 'pages') { | |
| 162 | + var page = grid.page || 0; | |
| 163 | + filters.push(['.wpupg-page-' + page]); | |
| 164 | + } | |
| 158 | 165 | |
| 159 | - if(grid.multiselect_type == 'match_one') { | |
| 160 | - match_one_filters.push(filter); | |
| 161 | - } else { | |
| 162 | - match_all_filter += filter; | |
| 166 | + // Taxonomy filters | |
| 167 | + for(var taxonomy in grid.filters) { | |
| 168 | + if(grid.filters.hasOwnProperty(taxonomy)) { | |
| 169 | + var taxonomy_filters = grid.filters[taxonomy]; | |
| 170 | + | |
| 171 | + var match_one_filters = []; | |
| 172 | + var match_all_filter = ''; | |
| 173 | + var filter = ''; | |
| 174 | + | |
| 175 | + if(taxonomy_filters) { | |
| 176 | + for(var i = 0; i < taxonomy_filters.length; i++) { | |
| 177 | + filter = '.wpupg-tax-' + taxonomy + '-' + taxonomy_filters[i]; | |
| 178 | + | |
| 179 | + if(grid.multiselect_type == 'match_one') { | |
| 180 | + match_one_filters.push(filter); | |
| 181 | + } else { | |
| 182 | + match_all_filter += filter; | |
| 183 | + } | |
| 163 | 184 | } |
| 164 | 185 | } |
| 165 | - } | |
| 166 | 186 | |
| 167 | - if(grid.multiselect_type == 'match_one') { | |
| 168 | - if(match_one_filters.length > 0) filters.push(match_one_filters); | |
| 169 | - } else { | |
| 170 | - if(match_all_filter !== '') filters.push([match_all_filter]); | |
| 187 | + if(grid.multiselect_type == 'match_one') { | |
| 188 | + if(match_one_filters.length > 0) filters.push(match_one_filters); | |
| 189 | + } else { | |
| 190 | + if(match_all_filter !== '') filters.push([match_all_filter]); | |
| 191 | + } | |
| 171 | 192 | } |
| 172 | 193 | } |
| 173 | - } | |
| 174 | 194 | |
| 175 | - grid.filter = ''; | |
| 176 | - WPUltimatePostGrid.getFilterString(grid_id, '', filters, 0); | |
| 177 | - if(grid.inverse) { | |
| 178 | - if(grid.pagination_type == 'pages') { | |
| 179 | - var page = grid.page || 0; | |
| 180 | - var filter_without_page = grid.filter.replace('.wpupg-page-' + page, ''); | |
| 195 | + grid.filter = ''; | |
| 196 | + WPUltimatePostGrid.getFilterString(grid_id, '', filters, 0); | |
| 197 | + if(grid.inverse) { | |
| 198 | + if(grid.pagination_type == 'pages') { | |
| 199 | + var page = grid.page || 0; | |
| 200 | + var filter_without_page = grid.filter.replace('.wpupg-page-' + page, ''); | |
| 181 | 201 | |
| 182 | - grid.filter = '.wpupg-page-' + page + ':not(' + filter_without_page + ')'; | |
| 183 | - } else { | |
| 184 | - grid.filter = ':not(' + grid.filter + ')'; | |
| 202 | + grid.filter = '.wpupg-page-' + page + ':not(' + filter_without_page + ')'; | |
| 203 | + } else { | |
| 204 | + grid.filter = ':not(' + grid.filter + ')'; | |
| 205 | + } | |
| 185 | 206 | } |
| 186 | 207 | } |
| 187 | 208 | |
| 209 | + jQuery('#wpupg-grid-' + grid_id + '-empty').hide(); | |
| 188 | 210 | grid.container.isotope({ filter: grid.filter }); |
| 189 | 211 | grid.container.trigger('wpupgFiltered'); |
| 190 | 212 | WPUltimatePostGrid.updateDeeplink(); |
| 191 | 213 | }; |
| @@ -200,8 +222,18 @@ | ||
| 200 | 222 | } |
| 201 | 223 | } |
| 202 | 224 | }; |
| 203 | 225 | |
| 226 | +WPUltimatePostGrid.checkEmpty = function(container) { | |
| 227 | + var grid_id = container.data('grid'), | |
| 228 | + filter = WPUltimatePostGrid.grids[grid_id].filter, | |
| 229 | + visible_items = container.find(filter); | |
| 230 | + | |
| 231 | + if(filter !== '' && visible_items.length == 0) { | |
| 232 | + jQuery('#wpupg-grid-' + grid_id + '-empty').slideDown(300); | |
| 233 | + } | |
| 234 | +}; | |
| 235 | + | |
| 204 | 236 | WPUltimatePostGrid.updateDeeplink = function() { |
| 205 | 237 | var link = ''; |
| 206 | 238 | |
| 207 | 239 | for(var grid_id in WPUltimatePostGrid.grids) { |
| @@ -208,18 +240,23 @@ | ||
| 208 | 240 | if(WPUltimatePostGrid.grids.hasOwnProperty(grid_id)) { |
| 209 | 241 | var grid = WPUltimatePostGrid.grids[grid_id]; |
| 210 | 242 | var grid_link = ''; |
| 211 | 243 | |
| 212 | - // Page filter | |
| 213 | - if(grid.page != 0) grid_link += '|p:' + (grid.page+1); | |
| 214 | 244 | |
| 215 | - // Taxonomy filters | |
| 216 | - for(var taxonomy in grid.filters) { | |
| 217 | - if(grid.filters.hasOwnProperty(taxonomy)) { | |
| 218 | - var taxonomy_filter = grid.filters[taxonomy]; | |
| 245 | + if(grid.filter_text) { | |
| 246 | + grid_link += '+s:' + grid.filter_text_search; | |
| 247 | + } else { | |
| 248 | + // Page filter | |
| 249 | + if(grid.page != 0) grid_link += '+p:' + (grid.page+1); | |
| 219 | 250 | |
| 220 | - if(taxonomy_filter.length > 0) { | |
| 221 | - grid_link += '|' + taxonomy + ':' + taxonomy_filter.join(','); | |
| 251 | + // Taxonomy filters | |
| 252 | + for(var taxonomy in grid.filters) { | |
| 253 | + if(grid.filters.hasOwnProperty(taxonomy)) { | |
| 254 | + var taxonomy_filter = grid.filters[taxonomy]; | |
| 255 | + | |
| 256 | + if(taxonomy_filter.length > 0) { | |
| 257 | + grid_link += '+' + taxonomy + ':' + taxonomy_filter.join(','); | |
| 258 | + } | |
| 222 | 259 | } |
| 223 | 260 | } |
| 224 | 261 | } |
| 225 | 262 | |
| @@ -230,27 +267,90 @@ | ||
| 230 | 267 | } |
| 231 | 268 | } |
| 232 | 269 | } |
| 233 | 270 | |
| 234 | - if(link == '') link = '*'; | |
| 235 | - document.location.hash = link; | |
| 271 | + WPUltimatePostGrid.replaceDeeplink(link); | |
| 236 | 272 | }; |
| 237 | 273 | |
| 274 | +/** | |
| 275 | + * Source: http://stackoverflow.com/questions/1397329/how-to-remove-the-hash-from-window-location-with-javascript-without-page-refresh/5298684#5298684 | |
| 276 | + */ | |
| 277 | +WPUltimatePostGrid.replaceDeeplink = function(link) { | |
| 278 | + var scrollV, scrollH, loc = window.location; | |
| 279 | + if ("replaceState" in history) { | |
| 280 | + var hash = link == '' ? '' : '#' + link; | |
| 281 | + history.replaceState("", document.title, loc.pathname + hash + loc.search); | |
| 282 | + } else { | |
| 283 | + // Prevent scrolling by storing the page's current scroll offset | |
| 284 | + scrollV = document.documentElement.scrollTop || document.body.scrollTop; | |
| 285 | + scrollH = document.documentElement.scrollLeft || document.body.scrollLeft; | |
| 286 | + | |
| 287 | + loc.hash = link; | |
| 288 | + | |
| 289 | + // Restore the scroll offset, should be flicker free | |
| 290 | + document.documentElement.scrollTop = document.body.scrollTop = scrollV; | |
| 291 | + document.documentElement.scrollLeft = document.body.scrollLeft = scrollH; | |
| 292 | + } | |
| 293 | +}; | |
| 294 | + | |
| 295 | +WPUltimatePostGrid.preFilterGrid = function() { | |
| 296 | + var link = document.location.hash; | |
| 297 | + link = link.substr(1); | |
| 298 | + | |
| 299 | + if(!link) { | |
| 300 | + var link = ''; | |
| 301 | + | |
| 302 | + for(var grid_id in WPUltimatePostGrid.grids) { | |
| 303 | + if(WPUltimatePostGrid.grids.hasOwnProperty(grid_id)) { | |
| 304 | + var grid = WPUltimatePostGrid.grids[grid_id]; | |
| 305 | + var grid_link = ''; | |
| 306 | + | |
| 307 | + if(grid.filter_data) { | |
| 308 | + var pre_filter = grid.filter_data['pre_filter']; | |
| 309 | + | |
| 310 | + // Taxonomy filters | |
| 311 | + for(var taxonomy in pre_filter) { | |
| 312 | + if(pre_filter.hasOwnProperty(taxonomy)) { | |
| 313 | + var taxonomy_filter = pre_filter[taxonomy]; | |
| 314 | + | |
| 315 | + if(taxonomy_filter.length > 0) { | |
| 316 | + grid_link += '+' + taxonomy + ':' + taxonomy_filter.join(','); | |
| 317 | + } | |
| 318 | + } | |
| 319 | + } | |
| 320 | + } | |
| 321 | + | |
| 322 | + if(grid_link != '') { | |
| 323 | + if(link != '') link += '#'; | |
| 324 | + link += grid_id; | |
| 325 | + link += grid_link; | |
| 326 | + } | |
| 327 | + } | |
| 328 | + } | |
| 329 | + | |
| 330 | + WPUltimatePostGrid.replaceDeeplink(link); | |
| 331 | + } | |
| 332 | +}; | |
| 333 | + | |
| 238 | 334 | WPUltimatePostGrid.restoreDeeplink = function() { |
| 239 | 335 | var link = document.location.hash; |
| 240 | 336 | link = link.substr(1); |
| 241 | 337 | |
| 242 | - if(link && link != '*') { | |
| 338 | + if(link) { | |
| 243 | 339 | // Make sure characters are not URL encoded |
| 244 | 340 | link = link.replace('%23', '#'); |
| 245 | 341 | link = link.replace('%7C', '|'); |
| 342 | + link = link.replace('%2B', '+'); | |
| 246 | 343 | link = link.replace('%3A', ':'); |
| 247 | 344 | link = link.replace('%2C', ','); |
| 248 | 345 | |
| 346 | + // Backwards compatibility | |
| 347 | + link = link.replace('|', '+'); | |
| 348 | + | |
| 249 | 349 | var grids = link.split('#'); |
| 250 | 350 | |
| 251 | 351 | for(var i=0; i < grids.length; i++) { |
| 252 | - var parts = grids[i].split('|'); | |
| 352 | + var parts = grids[i].split('+'); | |
| 253 | 353 | var grid_id = parts[0]; |
| 254 | 354 | |
| 255 | 355 | for(var j=1; j < parts.length; j++) { |
| 256 | 356 | var filter = parts[j].split(':'); |
| @@ -257,8 +357,10 @@ | ||
| 257 | 357 | |
| 258 | 358 | if(filter[0] == 'p') { |
| 259 | 359 | var page = parseInt(filter[1]) - 1; |
| 260 | 360 | WPUltimatePostGrid.updatePagination(jQuery('#wpupg-grid-' + grid_id + '-pagination'), page); |
| 361 | + } else if(filter[0] == 's') { | |
| 362 | + WPUltimatePostGrid.updateFilter(jQuery('#wpupg-grid-' + grid_id + '-filter'), filter[0], filter[1]); | |
| 261 | 363 | } else { |
| 262 | 364 | var terms = filter[1].split(','); |
| 263 | 365 | WPUltimatePostGrid.updateFilter(jQuery('#wpupg-grid-' + grid_id + '-filter'), filter[0], terms); |
| 264 | 366 | } |
| @@ -268,17 +370,18 @@ | ||
| 268 | 370 | }; |
| 269 | 371 | |
| 270 | 372 | WPUltimatePostGrid.checkLinks = function(grid_id) { |
| 271 | 373 | var grid = WPUltimatePostGrid.grids[grid_id]; |
| 272 | - var link_type = grid.container.data('link-type'); | |
| 374 | + var default_link_type = grid.container.data('link-type'); | |
| 273 | 375 | var link_target = grid.container.data('link-target'); |
| 376 | + var link_rel = link_target == 'post' ? '' : ' rel="lightbox"'; | |
| 274 | 377 | |
| 275 | - if(link_type != 'none') { | |
| 378 | + if(default_link_type != 'none') { | |
| 276 | 379 | grid.container.find('.wpupg-item').each(function() { |
| 277 | 380 | var item = jQuery(this); |
| 278 | 381 | |
| 279 | 382 | // Remove links from item |
| 280 | - 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() { | |
| 383 | + 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() { | |
| 281 | 384 | var link = jQuery(this); |
| 282 | 385 | if(link.parents('.sharrre').length == 0) { |
| 283 | 386 | link.replaceWith(function() { return link.contents(); }); |
| 284 | 387 | } |
| @@ -284,13 +387,15 @@ | ||
| 284 | 387 | } |
| 285 | 388 | }); |
| 286 | 389 | |
| 287 | 390 | var link = item.data('custom-link') ? item.data('custom-link') : ( link_target == 'post' ? item.data('permalink') : item.data('image') ); |
| 288 | - var rel = link_target == 'post' ? '' : ' rel="lightbox"'; | |
| 391 | + var link_behaviour = item.data('custom-link-behaviour'); | |
| 289 | 392 | |
| 393 | + var link_type = link_behaviour == '_blank' || link_behaviour == '_self' ? link_behaviour : default_link_type; | |
| 394 | + | |
| 290 | 395 | // Add link around item |
| 291 | - if (link && item.parent('a').length == 0) { | |
| 292 | - item.wrap('<a href="' + link + '" target="' + link_type + '"' + rel + '></a>'); | |
| 396 | + if (link_behaviour !== 'none' && link && item.parent('a').length == 0) { | |
| 397 | + item.wrap('<a href="' + link + '" target="' + link_type + '"' + link_rel + ' class="' + wpupg_public.link_class + '"></a>'); | |
| 293 | 398 | } |
| 294 | 399 | }); |
| 295 | 400 | } |
| 296 | 401 | }; |
| @@ -374,9 +479,9 @@ | ||
| 374 | 479 | |
| 375 | 480 | var filter_type = container.data('filter-type'); |
| 376 | 481 | var filter_items = container.find('.wpupg-filter-item'); |
| 377 | 482 | |
| 378 | - if(filter_type == 'isotope') { | |
| 483 | + if(filter_type == 'isotope' || filter_type == 'text_isotope') { | |
| 379 | 484 | var margin = container.data('margin-vertical') + 'px ' + container.data('margin-horizontal') + 'px'; |
| 380 | 485 | var padding = container.data('padding-vertical') + 'px ' + container.data('padding-horizontal') + 'px'; |
| 381 | 486 | var border = container.data('border-width') + 'px solid ' + container.data('border-color'); |
| 382 | 487 | var background_color = container.data('background-color'); |
| @@ -432,11 +537,14 @@ | ||
| 432 | 537 | }; |
| 433 | 538 | |
| 434 | 539 | WPUltimatePostGrid.updatePagination = function(container, page) { |
| 435 | 540 | var type = container.data('type'); |
| 436 | - var func = 'updatePagination' + type.charAt(0).toUpperCase() + type.slice(1); | |
| 437 | - if(typeof WPUltimatePostGrid[func] == 'function') { | |
| 438 | - WPUltimatePostGrid[func](container, page); | |
| 541 | + | |
| 542 | + if(type) { | |
| 543 | + var func = 'updatePagination' + type.charAt(0).toUpperCase() + type.slice(1); | |
| 544 | + if(typeof WPUltimatePostGrid[func] == 'function') { | |
| 545 | + WPUltimatePostGrid[func](container, page); | |
| 546 | + } | |
| 439 | 547 | } |
| 440 | 548 | }; |
| 441 | 549 | |
| 442 | 550 | WPUltimatePostGrid.updatePaginationPages = function(container, page) { |
| @@ -451,8 +559,10 @@ | ||
| 451 | 559 | pagination_item.siblings('.wpupg-pagination-term').removeClass('active').trigger('checkActiveFilter'); |
| 452 | 560 | |
| 453 | 561 | var page = parseInt(pagination_item.addClass('active').trigger('checkActiveFilter').data('page')); |
| 454 | 562 | |
| 563 | + WPUltimatePostGrid.scrollTo(WPUltimatePostGrid.grids[grid_id].container); | |
| 564 | + | |
| 455 | 565 | if(WPUltimatePostGrid.grids[grid_id].pages.indexOf(page) !== -1) { |
| 456 | 566 | WPUltimatePostGrid.grids[grid_id].page = page; |
| 457 | 567 | WPUltimatePostGrid.filterGrid(grid_id); |
| 458 | 568 | } else { |
| @@ -469,17 +579,12 @@ | ||
| 469 | 579 | |
| 470 | 580 | // Get recipes through AJAX |
| 471 | 581 | jQuery.post(wpupg_public.ajax_url, data, function(html) { |
| 472 | 582 | var posts = jQuery(html).toArray(); |
| 473 | - WPUltimatePostGrid.grids[grid_id].container.isotope('insert', posts); | |
| 583 | + | |
| 474 | 584 | WPUltimatePostGrid.grids[grid_id].page = page; |
| 475 | - WPUltimatePostGrid.filterGrid(grid_id); | |
| 476 | - WPUltimatePostGrid.checkLinks(grid_id); | |
| 585 | + WPUltimatePostGrid.insertPosts(grid_id, posts); | |
| 477 | 586 | |
| 478 | - WPUltimatePostGrid.grids[grid_id].container.imagesLoaded( function() { | |
| 479 | - WPUltimatePostGrid.grids[grid_id].container.isotope('layout'); | |
| 480 | - }); | |
| 481 | - | |
| 482 | 587 | pagination_item.removeClass('wpupg-spinner'); |
| 483 | 588 | pagination_item.css('color', WPUltimatePostGrid.grids[grid_id].pagination_style.active_text_color); |
| 484 | 589 | |
| 485 | 590 | WPUltimatePostGrid.grids[grid_id].pages.push(page); |
| @@ -557,8 +662,40 @@ | ||
| 557 | 662 | }).trigger('checkActiveFilter'); |
| 558 | 663 | }); |
| 559 | 664 | }; |
| 560 | 665 | |
| 666 | +WPUltimatePostGrid.insertPosts = function(grid_id, posts) { | |
| 667 | + var scrollV = document.documentElement.scrollTop || document.body.scrollTop, | |
| 668 | + scrollH = document.documentElement.scrollLeft || document.body.scrollLeft; | |
| 669 | + | |
| 670 | + WPUltimatePostGrid.grids[grid_id].container.isotope('destroy'); | |
| 671 | + | |
| 672 | + WPUltimatePostGrid.grids[grid_id].container.append(posts); | |
| 673 | + WPUltimatePostGrid.grids[grid_id].container.isotope(WPUltimatePostGrid.grids[grid_id].args); | |
| 674 | + | |
| 675 | + // Restore the scroll offset, should be flicker free | |
| 676 | + document.documentElement.scrollTop = document.body.scrollTop = scrollV; | |
| 677 | + document.documentElement.scrollLeft = document.body.scrollLeft = scrollH; | |
| 678 | + | |
| 679 | + WPUltimatePostGrid.updatePosts(grid_id); | |
| 680 | + WPUltimatePostGrid.checkLinks(grid_id); | |
| 681 | + WPUltimatePostGrid.filterGrid(grid_id); | |
| 682 | + | |
| 683 | + WPUltimatePostGrid.grids[grid_id].container.imagesLoaded( function() { | |
| 684 | + WPUltimatePostGrid.grids[grid_id].container.isotope('layout'); | |
| 685 | + WPUltimatePostGrid.grids[grid_id].loading = false; | |
| 686 | + }); | |
| 687 | +}; | |
| 688 | + | |
| 689 | +WPUltimatePostGrid.scrollTo = function(target) { | |
| 690 | + var scroll_to = target.offset().top - 50; | |
| 691 | + scroll_to = scroll_to < 0 ? 0 : scroll_to; | |
| 692 | + | |
| 693 | + jQuery('html,body').animate({ | |
| 694 | + scrollTop: scroll_to | |
| 695 | + }, 500); | |
| 696 | +}; | |
| 697 | + | |
| 561 | 698 | jQuery(document).ready(function($) { |
| 562 | 699 | $('.wpupg-grid').each(function() { |
| 563 | 700 | WPUltimatePostGrid.initGrid($(this)); |
| 564 | 701 | }); |
| @@ -568,8 +705,9 @@ | ||
| 568 | 705 | var grid_id = container.data('grid'); |
| 569 | 706 | var type = container.data('type'); |
| 570 | 707 | |
| 571 | 708 | WPUltimatePostGrid.grids[grid_id].filter_type = type; |
| 709 | + WPUltimatePostGrid.grids[grid_id].filter_data = window['wpupg_filter_' + WPUltimatePostGrid.grids[grid_id].id]; | |
| 572 | 710 | |
| 573 | 711 | var func = 'initFilter' + type.charAt(0).toUpperCase() + type.slice(1); |
| 574 | 712 | if(typeof WPUltimatePostGrid[func] == 'function') { |
| 575 | 713 | WPUltimatePostGrid[func](container); |
| @@ -587,6 +725,7 @@ | ||
| 587 | 725 | if(typeof WPUltimatePostGrid[func] == 'function') { |
| 588 | 726 | WPUltimatePostGrid[func](container); |
| 589 | 727 | } |
| 590 | 728 | }); |
| 729 | + WPUltimatePostGrid.preFilterGrid(); | |
| 591 | 730 | WPUltimatePostGrid.restoreDeeplink(); |
| 592 | 731 | }); |