1/** 2 * Archive events: progressive "load more". 3 * 4 * Every row is already in the page â the archive is bounded by the block's own 5 * limit, so there is nothing to fetch. This only collapses the overflow and 6 * gives the visitor a way back. 7 * 8 * Order matters: the rows are visible and the button is hidden in the markup, 9 * and this script swaps that round. Do it the other way and a visitor without 10 * scripting gets a truncated list and a button that does nothing. 11 */ 12( function () { 13 'use strict'; 14 15 var lists = document.querySelectorAll( '.sin-archive-events' ); 16 17 Array.prototype.forEach.call( lists, function ( list ) { 18 var button = list.querySelector( '.sin-archive-more' ); 19 20 if ( ! button ) { 21 return; 22 } 23 24 list.classList.add( 'is-collapsed' ); 25 button.hidden = false; 26 button.setAttribute( 'aria-expanded', 'false' ); 27 28 button.addEventListener( 'click', function () { 29 var expanded = list.classList.toggle( 'is-expanded' ); 30 31 list.classList.toggle( 'is-collapsed', ! expanded ); 32 button.setAttribute( 'aria-expanded', expanded ? 'true' : 'false' ); 33 button.textContent = expanded ? button.dataset.less : button.dataset.more; 34 35 /* 36 * Collapsing from the bottom of a long list would otherwise leave 37 * the viewport somewhere below the whole block. Only scroll when 38 * the top has actually gone past. 39 */ 40 if ( ! expanded && list.getBoundingClientRect().top < 0 ) { 41 list.scrollIntoView( { behavior: 'smooth', block: 'start' } ); 42 } 43 } ); 44 } ); 45}() );
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.