Created
March 23, 2015 08:30
-
-
Save Rebolon/fadaf1c67799fb6bc54d to your computer and use it in GitHub Desktop.
Improve lisibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template.registerHelper('setCardHeight',function(tabletCards){ | |
var tabletCount = tabletCards.length; | |
var tabletCardWidth = 450; | |
var screenWidth = $(window).width(); | |
var cardsPerRow = Math.floor(screenWidth / tabletCardWidth); | |
if (cardsPerRow <= 1) { | |
return; | |
} | |
for (var i=0; i<tabletCount; i+=cardsPerRow) { | |
var maxHeight = $(tabletCards[i]).height(); | |
for (var j=0; j<cardsPerRow; j++) { | |
if (j+i >= tabletCount) { | |
continue; | |
} | |
currentCardHeight = $(tabletCards[j+i]).height(); | |
if (currentCardHeight > maxHeight) { | |
maxHeight = currentCardHeight; | |
} | |
} | |
maxHeight = maxHeight + 10; | |
var setHeight = 'height: ' + maxHeight + 'px'; | |
for (var j=0; j<cardsPerRow; j++) { | |
if (j+i < tabletCount) { | |
tabletCards[j+i].setAttribute('style', setHeight); | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment