1/** 2 * CM Tiles - Layout 1 JavaScript 3 * Equalizes text content heights for uniform grid appearance 4 * Only runs on page load and window resize 5 */ 6 7(function($) { 8 'use strict'; 9 10 /** 11 * Equalize heights of text content areas in Layout 1 12 */ 13 function equalizeTextHeights() { 14 // Process each Layout 1 group separately 15 document.querySelectorAll('.cm-tile-group.layout_1').forEach(function(group) { 16 console.log('equalizing text heights for group', group); 17 // Reset heights to auto 18 group.querySelectorAll('.text-top-content').forEach(el => el.style.height = 'auto'); 19 group.querySelectorAll('.text-bottom-content').forEach(el => el.style.height = 'auto'); 20 21 // Get all top content heights for this group 22 var topHeights = Array.from(group.querySelectorAll('.text-top-content')).map(el => $(el).outerHeight()); 23 var maxTopHeight = topHeights.length ? Math.max.apply(Math, topHeights) : 0; 24 25 // Get all bottom content heights for this group 26 var bottomHeights = Array.from(group.querySelectorAll('.text-bottom-content')).map(el => $(el).outerHeight()); 27 var maxBottomHeight = bottomHeights.length ? Math.max.apply(Math, bottomHeights) : 0; 28 29 // Apply maximum heights to this group only 30 if (maxTopHeight > 0) { 31 group.querySelectorAll('.text-top-content').forEach(el => el.style.height = maxTopHeight + 'px'); 32 } 33 34 if (maxBottomHeight > 0) { 35 group.querySelectorAll('.text-bottom-content').forEach(el => el.style.height = maxBottomHeight + 'px'); 36 } 37 }); 38 } 39 40 /** 41 * Simple debounce function 42 */ 43 function debounce(func, wait) { 44 var timeout; 45 return function() { 46 clearTimeout(timeout); 47 timeout = setTimeout(func, wait); 48 }; 49 } 50 51 // Run on page load 52 $(window).on('load', function() { 53 equalizeTextHeights(); 54 }); 55 56 // Run on window resize with debouncing 57 $(window).on('resize', debounce(equalizeTextHeights, 250)); 58 59})(jQuery);
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.