ricardojlp
8/18/2015 - 11:14 AM

Normalize height

Normalize height

var normalizeListItemHeight = function(str_itemListSelector, num_modLineItems, fnc_callback, bol_lineHeight) {

  var num_maxHeight,
      num_itemHeight,
      num_itemIndex;

  $(str_itemListSelector).each(function (i) {
    if ( i % num_modLineItems === 0 ) {
      num_maxHeight = $(this).height() != 0 ? $(this).height("auto").height() : "auto";
      num_itemIndex = i;
      for ( var x = 0 ; x <= num_modLineItems - 1 ; x++ ) {
        num_itemHeight = $(str_itemListSelector).eq(num_itemIndex + x).height();
        if ( num_maxHeight < num_itemHeight ) {
          num_maxHeight = num_itemHeight;
        }
      }
      for ( var y = 0 ; y <= num_modLineItems - 1 ; y++ ) {
        if ( num_maxHeight > 0 ) {
          $(str_itemListSelector).eq(num_itemIndex + y).height(num_maxHeight);
        }
      }
    }
  });
  if ( typeof fnc_callback != 'undefined' ) {
    fnc_callback();
  }
}