1/* global kadenceProInfiniteConfig */ 2/** 3 * File post-infinite-scroll.js. 4 * Gets single post infinite scroll working. 5 */ 6 7(function() { 8 'use strict'; 9 window.kadenceProInfiniteEvents = { 10 // Initiate scroll when the DOM loads. 11 init: function() { 12 var infScrollContainer = document.querySelector( '.content-wrap[data-infinite-scroll]' ); 13 // No point if no container. 14 if ( ! infScrollContainer.dataset || ! infScrollContainer.dataset.infiniteScroll ) { 15 return; 16 } 17 18 // Enable infinite scroll only on the first archive page to prevent confusion. 19 // The presence of a previous page link indicates we're beyond page 1, so we skip activation. 20 const isFirstArchivePage = ! document.body.querySelector( '.prev.page-numbers' ); 21 const hasNextArchivePage = document.body.querySelector( '.next.page-numbers' ); 22 if ( ! isFirstArchivePage && hasNextArchivePage ) { 23 const instance = InfiniteScroll.data( infScrollContainer ); 24 25 if ( instance ) { 26 instance.destroy(); 27 } 28 29 return; 30 } 31 32 let parsedData = JSON.parse( infScrollContainer.dataset.infiniteScroll ); 33 var infScroll = new InfiniteScroll( '.content-wrap[data-infinite-scroll]', { 34 path: parsedData.path, 35 append: parsedData.append, 36 hideNav: parsedData.hideNav, 37 status: parsedData.status, 38 } ); 39 infScroll.on( 'append', function ( body, path, items, response ) { 40 const event = new Event( 'kadenceJSInitReload' ); 41 document.dispatchEvent( event ); 42 } ); 43 } 44 } 45 if ( 'loading' === document.readyState ) { 46 // The DOM has not yet been loaded. 47 document.addEventListener( 'DOMContentLoaded', window.kadenceProInfiniteEvents.init ); 48 } else { 49 // The DOM has already been loaded. 50 window.kadenceProInfiniteEvents.init(); 51 } 52})();
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.