1// Js to manage all the related with the continuous navigation. 2(function ($, Drupal, document) { 3 Drupal.behaviors.homesNcManager = { 4 attach() { 5 6 $(once('homes-nc-manager', 'body')) 7 .each(function () { 8 const debug = false; 9 10 11 function loadNext(item){ 12 let nextPageUrl = item.getAttribute('data-request'); 13 if (!nextPageUrl) { 14 item.classList.add('nc-loaded'); 15 item.classList.remove('nc-loading'); 16 return 17 } 18 else { 19 item.classList.add('nc-loaded'); 20 item.classList.remove('nc-loading'); 21 if (debug) {console.log('NEXT PAGE LOADED:' + item.getAttribute('cod'))}; 22 23 Drupal.ajax({ url: nextPageUrl, type: 'GET' }).execute(); 24 } 25 } 26 27 28 // Load next page. 29 document.addEventListener('activeContentScrolled', function () { 30 let element = false; 31 let elementID = false; 32 33 if (document.querySelectorAll('.nc-container:not(.nc-loaded):not(.nc-loading)').length > 0) { 34 // Every loaded noticia renders its own container; pick the 35 // pending one instead of always the first (already used) one, 36 // otherwise the chain stalls after the 2nd article. 37 element = document.querySelector('.views-nav-continua:not(.nc-loaded):not(.nc-loading)'); 38 if (element) { 39 elementID = 'News'; 40 } 41 else { 42 43 let elements = document.querySelectorAll('.mod-nav-continua'); 44 let currentElementID = document.querySelector('.mod-nav-continua.active').getAttribute('cod'); 45 let follow = 0; 46 47 elements.forEach( (item) => { 48 if (follow == 1) { 49 element = item; 50 elementID = element.getAttribute('cod'); 51 follow = 2 52 } 53 else if (item.getAttribute('cod') === currentElementID && follow == 0) { 54 follow = 1; 55 } 56 }); 57 } 58 59 // Prevent load twice a node. 60 if (element && !element.classList.contains('nc-loaded') && !element.classList.contains('nc-loading')) { 61 element.classList.add('nc-loading'); 62 if (debug) {console.log('LOADING PAGE: ' + elementID)} 63 loadNext(element); 64 } 65 } 66 }); 67 68 }); 69 } 70 } 71}(jQuery, Drupal, document));
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.