From 4dfe12288029c2feb4ac71744a3543606d4abcff Mon Sep 17 00:00:00 2001 From: joomlart Date: Fri, 5 Apr 2013 18:01:26 +0700 Subject: [PATCH] Optimize equalheight code --- .../base/js/jquery.equalheight.js | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/source/plg_system_t3/base/js/jquery.equalheight.js b/source/plg_system_t3/base/js/jquery.equalheight.js index c71b8e85f5..429eee6999 100644 --- a/source/plg_system_t3/base/js/jquery.equalheight.js +++ b/source/plg_system_t3/base/js/jquery.equalheight.js @@ -13,17 +13,25 @@ ;(function ($) { $.fn.equalHeight = function (options){ - var tallest = 0; - $(this).each(function() { - $(this).css({height:"", "min-height":""}); - var thisHeight = $(this).height(); - if(thisHeight > tallest) { - tallest = thisHeight; - } - }); - $(this).each(function() { - $(this).css( "min-height", tallest ); - }); + //only set min-height if we have more than 1 element + if(this.length > 1 || (options && options.force)){ + + var tallest = 0; + this.each(function() { + + var height = $(this).css({height: '', 'min-height': ''}).height(); + + if(height > tallest) { + tallest = height; + } + }); + + this.each(function() { + $(this).css('min-height', tallest); + }); + } + + return this; } })(jQuery); \ No newline at end of file