0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | jQuery(document).ready(function($){ /* Put any theme-specific JS here... */ var $components = $('#content > .inner, .fixed-sidebar .fixed-sidebar-inner'); function equalizeHeights($selector) { var heights = new Array(); // Loop to get all element heights $selector.each(function() { var $this = $(this); // Need to let sizes be whatever they want so no overflow on resize $this.css('min-height', '0'); $this.css('max-height', 'none'); $this.css('height', 'auto'); // Then add size (no units) to array heights.push($this.innerHeight()); }); // Find max height of all elements var max = Math.max.apply( Math, heights ); // Set all heights to max height $selector.each(function() { if($(window).width() > 768) { $(this).css('min-height', max + 'px'); } }); } $(window).load(function() { // Fix heights on page load equalizeHeights($components); // Fix heights on window resize var iv = null; $(window).resize(function() { if(iv !== null) { window.clearTimeout(iv); } // Needs to be a timeout function so it doesn't fire every ms of resize iv = setTimeout(function() { equalizeHeights($components); }, 120); }); }); }); |