Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Equal height: Eliminated the use of jQuery each().
  • Loading branch information
thomasgohard committed Dec 11, 2013
1 parent ed71bbc commit 204211c
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/plugins/equalheight/equalheight.js
Expand Up @@ -49,21 +49,21 @@ var selector = ".wb-eqht",
* @method onResize
*/
onResize = function() {
var $elms = $( selector );

$elms.each( function() {
var currentChild, childCSS, minHeight, i,
row = [ ],
rowTop = -1,
currentChildTop = -1,
currentChildHeight = -1,
tallestHeight = -1,
$this = $( this ),
$children = $this.children(),
$anchor = detachElement( $this );

for ( i = $children.length - 1; i !== -1; i -= 1 ) {
currentChild = $children[ i ];
var $elm, $children, $anchor, currentChild, childCSS, minHeight, i, j,
$elms = $( selector ),
row = [],
rowTop = -1,
currentChildTop = -1,
currentChildHeight = -1,
tallestHeight = -1;

for ( i = $elms.length; i !== -1; i -= 1 ) {
$elm = $elms.eq( i );
$children = $elm.children();

$anchor = detachElement( $elm );
for ( j = $children.length - 1; j !== -1; j -= 1 ) {
currentChild = $children[ j ];
childCSS = currentChild.style.cssText;

// Ensure all children that are on the same baseline have the same 'top' value.
Expand All @@ -82,10 +82,10 @@ var selector = ".wb-eqht",

currentChild.style.cssText = childCSS;
}
$this = reattachElement( $anchor );
$elm = reattachElement( $anchor );

for ( i = $children.length - 1; i !== -1; i -= 1 ) {
currentChild = $children[ i ];
for ( j = $children.length - 1; j !== -1; j -= 1 ) {
currentChild = $children[ j ];

currentChildTop = currentChild.offsetTop;
currentChildHeight = currentChild.offsetHeight;
Expand All @@ -99,20 +99,20 @@ var selector = ".wb-eqht",
tallestHeight = ( currentChildHeight > tallestHeight ) ? currentChildHeight : tallestHeight;
}

row.push( $children.eq( i ) );
row.push( $children.eq( j ) );
}
recordRowHeight( row, tallestHeight );

$anchor = detachElement( $this );
for ( i = $children.length - 1; i !== -1; i -= 1 ) {
minHeight = $children.eq( i ).data( "min-height" );
$anchor = detachElement( $elm );
for ( j = $children.length - 1; j !== -1; j -= 1 ) {
minHeight = $children.eq( j ).data( "min-height" );

if ( minHeight ) {
$children[ i ].style.minHeight = minHeight;
$children[ j ].style.minHeight = minHeight;
}
}
$this = reattachElement( $anchor );
} );
$elm = reattachElement( $anchor );
}
},

/**
Expand Down

0 comments on commit 204211c

Please sign in to comment.