1(function () { 2 3 var pagination = astra.pagination || '', 4 masonryEnabled = astra.masonryEnabled || false, 5 revealEffectEnable = astra.revealEffectEnable || false, 6 loadStatus = true, 7 infinite_event = astra.infinite_scroll_event || ''; 8 9 // Is 'infinite' pagination? 10 if ( typeof pagination === 'string' && pagination == 'infinite' ) { 11 12 var in_customizer = false; 13 14 // check for wp.customize return boolean 15 if ( typeof wp !== 'undefined' ) { 16 17 in_customizer = typeof wp.customize !== 'undefined' ? true : false; 18 19 if ( in_customizer ) { 20 return; 21 } 22 } 23 24 if ( typeof infinite_event === 'string' ) { 25 switch( infinite_event ) { 26 case 'click': 27 // Accessibility improvement for load more button. 28 document.addEventListener('DOMContentLoaded', function() { 29 var loadMoreLinks = document.querySelectorAll('.ast-load-more.active'); 30 loadMoreLinks.forEach(function(link) { 31 link.setAttribute('tabindex', '0'); 32 link.setAttribute('role', 'button'); 33 link.addEventListener('keydown', function(e) { 34 if (e.key === 'Enter' || e.keyCode === 13) { 35 e.preventDefault(); 36 var infinitePagination = document.querySelector('.ast-pagination-infinite'); 37 if( infinitePagination ) { 38 var total = parseInt( infinitePagination.getAttribute('data-total') ) || ''; 39 var count = parseInt( infinitePagination.getAttribute('data-page') ) || ''; 40 if( count != 'undefined' && count != ''&& total != 'undefined' && total != '' ) { 41 if ( count <= total ) { 42 NextloadArticles(count); 43 infinitePagination.setAttribute('data-page', count + 1 ); 44 } 45 } 46 } 47 } 48 }); 49 }); 50 }); 51 52 document.addEventListener('click',function(event) { 53 if( event.target.classList.contains('ast-load-more') ) { 54 event.preventDefault(); // prevent the jump 55 // For Click 56 const infinitePagination = document.querySelector('.ast-pagination-infinite'); 57 if( infinitePagination ) { 58 let total = parseInt( document.querySelector('.ast-pagination-infinite').getAttribute('data-total') ) || ''; 59 let count = parseInt( document.querySelector('.ast-pagination-infinite').getAttribute('data-page') ) || ''; 60 if( count != 'undefined' && count != ''&& total != 'undefined' && total != '' ) { 61 if ( count <= total ) { 62 NextloadArticles(count); 63 document.querySelector('.ast-pagination-infinite').setAttribute('data-page', count + 1 ); 64 } 65 } 66 } 67 } 68 }); 69 break; 70 case 'scroll': 71 const astLoadMore = document.querySelector('.ast-load-more'); 72 var mainSelector = document.getElementById('main'); 73 if ( ! mainSelector ) { 74 break; 75 } 76 var rect = mainSelector.getBoundingClientRect(); 77 var offset = { 78 top: rect.top + window.scrollY, 79 left: rect.left + window.scrollX, 80 }; 81 if( astLoadMore ){ 82 astLoadMore.classList.remove('active'); 83 } 84 if( mainSelector.querySelectorAll('article:last-child').length > 0 ) { 85 86 var windowHeight50 = window.outerHeight / 1.25; 87 window.addEventListener('scroll', function() { 88 89 if( (window.scrollY + windowHeight50 ) >= ( offset.top ) ) { 90 const infinitePagination = document.querySelector('.ast-pagination-infinite'); 91 if( infinitePagination ) { 92 const total = parseInt( infinitePagination.getAttribute('data-total') ) || ''; 93 let count = parseInt( infinitePagination.getAttribute('data-page') ) || ''; 94 95 if (count <= total) { 96 // Pause for the moment ( execute if post loaded ) 97 if( loadStatus == true ) { 98 NextloadArticles(count); 99 infinitePagination.setAttribute('data-page', count + 1 ); 100 loadStatus = false; 101 } 102 } 103 } 104 } 105 }); 106 } 107 break; 108 } 109 } 110 111 /** 112 * Append Posts via AJAX 113 * 114 * Perform masonry operations. 115 */ 116 const NextloadArticles = (pageNumber) => { 117 const loader = document.querySelector('.ast-pagination-infinite .ast-loader'); 118 const astLoadMore = document.querySelector('.ast-load-more'); 119 if( astLoadMore ){ 120 astLoadMore.classList.remove('active'); 121 } 122 var pageUrlSelector = document.querySelector('a.next.page-numbers'); 123 var nextDestUrl = pageUrlSelector.getAttribute('href'); 124 loader.style.display = 'block'; 125 126 var request = new XMLHttpRequest(); 127 request.open('GET', nextDestUrl, true); 128 request.send(); 129 request.onload = function() { 130 var string = request.response; 131 var data = new DOMParser().parseFromString(string, 'text/html'); 132 var boxes = data.querySelectorAll( 'article.ast-article-post' ); 133 134 // Disable loader 135 loader.style.display = 'none'; 136 if( astLoadMore ){ 137 astLoadMore.classList.add( 'active'); 138 astLoadMore.setAttribute('tabindex', '0'); 139 astLoadMore.setAttribute('role', 'button'); 140 } 141 // Append articles 142 for (var boxCount = 0; boxCount < boxes.length; boxCount++) { 143 document.querySelector('#main > .ast-row').append(boxes[boxCount]); 144 } 145 146 const gridLayout = astra.grid_layout; 147 148 // Append articles 149 if( 1 == masonryEnabled && ( gridLayout.desktop > 1 || gridLayout.tablet > 1 || gridLayout.mobile > 1 ) ) { 150 var grid = document.querySelector('#main > .ast-row'); 151 var msnry = new Masonry( grid, {}); 152 153 imagesLoaded( document.querySelector('#main > .ast-row'), function() { 154 msnry.appended( boxes ); 155 msnry.reloadItems(); 156 msnry.layout(); 157 }); 158 } 159 160 // Add grid classes 161 var msg = astra.no_more_post_message || ''; 162 // Show no more post message 163 const infinitePagination = document.querySelector('.ast-pagination-infinite'); 164 if( infinitePagination ) { 165 const total = parseInt( infinitePagination.getAttribute('data-total') ) || '';
166 let count = parseInt( infinitePagination.getAttribute('data-page') ) || ''; 167 if( count > total ) { 168 infinitePagination.innerHTML = '<span class="ast-load-more no-more active" style="display: inline-block;">' + msg + "</span>"; 169 } else { 170 var newNextTargetUrl = nextDestUrl.replace(/\/page\/[0-9]+/, '/page/' + (pageNumber + 1)); 171 pageUrlSelector.setAttribute('href', newNextTargetUrl); 172 } 173 } 174 175 if( revealEffectEnable ) { 176 fadin('.ast-fade-up', { delay: 200 }); 177 } 178 179 // Complete the process 'loadStatus' 180 loadStatus = true; 181 } 182 } 183 } 184 185})();
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.