1(function(root, $, undefined) { 2 3 // Shared Masonry options generator 4 function getMasonryOptions(widgetId) { 5 return { 6 itemSelector: `.elementor-element-${widgetId} .posts-grid-item`, 7 columnWidth: `.elementor-element-${widgetId} .posts-grid-sizer`, 8 percentPosition: true, 9 gutter: 30, 10 horizontalOrder: true, 11 transitionDuration: 0, 12 }; 13 } 14 15 function initPostsCardGrid($container) { 16 const widgetId = $container.closest('.elementor-widget').data('id'); 17 if (!widgetId) return; 18 19 $container.attr('id', 'posts-card-grid-container-' + widgetId); 20 21 const $widget = $(`.elementor-element-${widgetId}`); 22 const $grid = $widget.find('.posts-grid'); 23 24 if ($grid.data('masonry')) { 25 $grid.masonry('destroy'); 26 } 27 28 $grid.masonry(getMasonryOptions(widgetId)); 29 $grid.addClass('masonry'); 30 31 $container.data('current-page', 1); 32 $widget.find('.load-more').off('click.postsCardGrid').on('click.postsCardGrid', function(e) { 33 e.preventDefault(); 34 35 const $button = $(this); 36 const currentPage = ($container.data('current-page') || 1) + 1; 37 $container.data('current-page', currentPage); 38 $button.prop('disabled', true); 39 40 $.ajax({ 41 type: 'POST', 42 url: ajax_object2.ajax_url2, 43 dataType: 'json', 44 data: { 45 action: 'posts_card_grid_load_more', 46 _ajax_nonce: ajax_object2.nonce, 47 paged: currentPage, 48 postType: $container.data('post-type'), 49 postsPerPage: $container.data('posts-number'), 50 orderBy: $container.data('order-by'), 51 order: $container.data('order'), 52 chooseByCategory: $container.data('choose-by-category'), 53 category: $container.data('category'), 54 showPostInfo: $container.data('show-post-info'), 55 showPostTitle: $container.data('show-post-title'), 56 showPostDescription: $container.data('show-post-description'), 57 showPostDate: $container.data('show-post-date'), 58 showPostTypeBadge: $container.data('show-post-type-badge'), 59 showPostReadingTime: $container.data('show-post-reading-time'), 60 showPostTitleInBadge: $container.data('show-post-title-in-badge'), 61 }, 62 success: function(res) { 63 const $contentToAppend = $(res.html); 64 $grid.append($contentToAppend); 65 66 if ($grid.data('masonry')) { 67 $grid.masonry('appended', $contentToAppend); 68 $grid.imagesLoaded(function() { 69 $grid.masonry('layout'); 70 }); 71 } 72 73 if (currentPage >= res.max) { 74 $button.hide(); 75 } 76 }, 77 error: function(jqXHR, textStatus, errorThrown) { 78 $container.data('current-page', currentPage - 1); 79 alert('Error fetching data! Please refresh the page'); 80 console.log(jqXHR); 81 console.log(textStatus); 82 console.log(errorThrown); 83 }, 84 complete: function() { 85 $button.prop('disabled', false); 86 } 87 }); 88 }); 89 } 90 91 // DOM ready 92 $(function() { 93 $('.posts-card-grid-container').each(function() { 94 initPostsCardGrid($(this)); 95 }); 96 }); 97 98 // Elementor hook 99 $(window).on('elementor/frontend/init', function() { 100 elementorFrontend.hooks.addAction( 101 'frontend/element_ready/posts-card-grid.default', 102 function($scope) { 103 $scope.find('.posts-card-grid-container').each(function() { 104 initPostsCardGrid($(this)); 105 }); 106 } 107 ); 108 }); 109 110}(this, jQuery));
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.