1(function () { 2 var root = document.querySelector('[data-js-nav-tiles]'); 3 if (!root) return; 4 5 var config = {}; 6 try { config = JSON.parse(root.getAttribute('data-js-nav-tiles')); } catch (e) {} 7 var perPage = config.perPage || 8; 8 9 var tiles = root.querySelectorAll('.nav-tiles__tile'); 10 var total = tiles.length; 11 var totalPages = Math.max(1, Math.ceil(total / perPage)); 12 13 var prev = root.querySelector('[data-js-nav-prev]'); 14 var next = root.querySelector('[data-js-nav-next]'); 15 var counter = root.querySelector('[data-js-nav-counter]'); 16 var controls = root.querySelector('.nav-tiles__controls'); 17 var current = 0; 18 19 function show(index) { 20 [].forEach.call(tiles, function (t, i) { 21 var page = Math.floor(i / perPage); 22 t.classList.toggle('nav-tiles__tile--hidden', page !== index); 23 }); 24 if (prev) prev.classList.toggle('nav-tiles__arrow--disabled', index === 0); 25 if (next) next.classList.toggle('nav-tiles__arrow--disabled', index === totalPages - 1); 26 if (counter) counter.textContent = (index + 1) + ' / ' + totalPages; 27 current = index; 28 } 29 30 if (totalPages <= 1) { 31 show(0); 32 if (controls) controls.classList.add('nav-tiles__controls--hidden'); 33 return; 34 } 35 36 if (prev) prev.addEventListener('click', function () { if (current > 0) show(current - 1); }); 37 if (next) next.addEventListener('click', function () { if (current < totalPages - 1) show(current + 1); }); 38 39 show(0); 40})();
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.