data.boxes.forEach(function (box) { var $box = $container[(update) ? 'children' : 'filter'](BOX.box2Selector(box)), $header = $box.children('header'), $content = $box.children('article'), header = BOX.isBoxSmall(box) ? boxHeader.small : boxHeader.normal, headerFontSize = Math.round(scaleFactor * header.fontSize), contentFontSize = Math.max(Math.min(boxContent.fontScale * headerFontSize, boxContent.fontMax), boxContent.fontMin), place = grid.place(box, columnsCount, margin, gap, maxBoxSize), // position translate = 'translate(' + place.left + 'px, ' + place.top + 'px) scale(1) translateZ(0)', boxCSS = { '-webkit-transform': translate, '-moz-transform' : translate, '-o-transform' : translate, 'transform' : translate, 'width' : place.width, 'height': place.height, 'margin': gap, 'font-size': Math.round(scaleFactor * header.fontSize) }, headerHeight = Math.round(scaleFactor * header.minHeight), contentHeight = boxCSS.height - headerHeight - header['padding-top'] - header['padding-bottom']; $box.css(boxCSS) [box.isActive ? 'removeClass' : 'addClass'](inactiveBoxClass) [box.isSmall ? 'addClass' : 'removeClass'](smallBoxClass); $header.css({ 'min-height': headerHeight, 'padding': header['padding-top'] + 'px ' + header['padding-right'] + 'px ' + header['padding-bottom'] + 'px ' + header['padding-left'] + 'px' }); $content.css({ 'height': contentHeight, 'font-size': contentFontSize }); bgHeight = Math.max(bgHeight, place.top + place.height); });
boxes.forEach(function (box) { var $box = $container.children(BOX.box2Selector(box)), $lastVisible = $box.children('article').children(':visible:last'), requiredHeight, requiredRows; if ($lastVisible.length === 0) { return; } requiredHeight = $lastVisible.position().top + $lastVisible.outerHeight(true); requiredRows = Math.ceil(requiredHeight / currentBoxSize); if (box.rows !== requiredRows) { if (!needUpdate) { needUpdate = (requiredRows > box.cols); } box.rows = Math.max(requiredRows, box.cols); } });