1(($) => { 2 function processPostsListAJAX(url, formId) { 3 // Store element that will have updated content 4 let $postsListContainer = $("#filter-container-" + formId); 5 let postsListContainer = document.getElementById( 6 "filter-container-" + formId 7 ); 8 9 let $postsListLoader = $(".visc-posts-list__loader"); 10 11 // Get new results using AJAX 12 $.ajax({ 13 url, 14 dataType: "html", 15 beforeSend: function () { 16 // Show the user something is happening 17 $postsListLoader.addClass("visc-posts-list__loader--active"); 18 $postsListContainer.addClass("visc-posts-list--loading"); 19 }, 20 success: function (data) { 21 // Get all the new content inside of the container 22 let updatedContent = $(data).find( 23 "#filter-container-" + formId + " > *" 24 ); 25 26 // Display the new data in the container 27 $postsListContainer.empty(); 28 $postsListContainer.append(updatedContent); 29 30 // Scroll to the top of the list container 31 postsListContainer.scrollIntoView({ 32 behavior: "smooth", 33 block: "start", 34 inline: "nearest", 35 }); 36 // Show the user the request is comlete 37 $postsListLoader.removeClass("visc-posts-list__loader--active"); 38 $postsListContainer.removeClass("visc-posts-list--loading"); 39 40 // Need to re-run this after each complete AJAX too 41 // postsListPaginationAJAXHandler(); 42 history.pushState("", document.title, url); 43 // Create custom JS event to listen to for custom JS after AJAX is complete 44 $(document).trigger("visceralPosts:ajaxSuccess"); 45 }, 46 }); 47 } 48 function postsListAJAX() { 49 let $postsLists = $(".visc-posts-list"); 50 51 if ($postsLists) { 52 $postsLists.each(function () { 53 let filterId; 54 let $postsListPagination = $(this).find(".pagination"); 55 let $postsListPaginationLinks = $postsListPagination.find("a"); 56 let postsListId = $(this).attr("id"); 57 let ajaxPagination = (filterId = false); 58 if (postsListId) { 59 filterId = postsListId.substring(17); 60 let filter = $(`#visc-qf-${filterId}`); 61 62 if (filter.length) { 63 if (filter.hasClass("visc-query-filter__form--ajax")) { 64 ajaxPagination = true; 65 } 66 } else { 67 if ($postsListPagination.length) { 68 if ( 69 "undefined" !== $postsListPagination.data("ajax-pagination") 70 ) { 71 ajaxPagination = true; 72 } 73 } 74 } 75 } 76 77 if ($postsListPaginationLinks && ajaxPagination) { 78 $postsListPaginationLinks.on("click", function (e) { 79 e.preventDefault(); 80 processPostsListAJAX(this.href, filterId); 81 }); 82 } 83 }); 84 } 85 } 86 postsListAJAX(); 87 $(document).on("visceralPosts:ajaxSuccess", function () { 88 postsListAJAX(); 89 }); 90})(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.