Skip to content

Commit

Permalink
Optimize equalheight code
Browse files Browse the repository at this point in the history
  • Loading branch information
joomlart committed Apr 5, 2013
1 parent 86b898c commit 4dfe122
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions source/plg_system_t3/base/js/jquery.equalheight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 4dfe122

Please sign in to comment.