1/** 2 * Homepage Hero Block 3 */ 4 5(function () { 6 'use strict'; 7 8 // Responsive text sizing â batch reads then writes to avoid layout thrashing 9 function adjustTextSizing() { 10 var titles = document.querySelectorAll('.hero-title-line-1, .hero-title-line-2'); 11 var measurements = []; 12 13 // Batch READ phase â no writes here 14 titles.forEach(function (title) { 15 var container = title.closest('.hero-container'); 16 if (container) { 17 measurements.push({ 18 el: title, 19 containerWidth: container.offsetWidth, 20 baseFontSize: parseInt(getComputedStyle(title).fontSize), 21 textLength: title.textContent.length 22 }); 23 } 24 }); 25 26 // Batch WRITE phase â no reads here 27 measurements.forEach(function (m) { 28 var scaleFactor = Math.min(m.containerWidth / 800, 1); 29 var lengthFactor = Math.max(0.7, 1 - (m.textLength - 10) * 0.02); 30 var newFontSize = m.baseFontSize * scaleFactor * lengthFactor; 31 m.el.style.fontSize = Math.max(newFontSize, m.baseFontSize * 0.6) + 'px'; 32 }); 33 } 34 35 function init() { 36 adjustTextSizing(); 37 38 var resizeTimeout; 39 window.addEventListener('resize', function () { 40 clearTimeout(resizeTimeout); 41 resizeTimeout = setTimeout(adjustTextSizing, 250); 42 }); 43 } 44 45 if (document.readyState === 'loading') { 46 document.addEventListener('DOMContentLoaded', init); 47 } else { 48 init(); 49 } 50 51 // Re-initialize for block editor updates 52 if (window.wp && window.wp.domReady) { 53 window.wp.domReady(init); 54 } 55 56 window.HomepageHeroBlock = { 57 init: init, 58 adjustTextSizing: adjustTextSizing 59 }; 60 61})();
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.