batch-row.js 394 B

12345678910111213141516171819202122
  1. import Ember from 'ember';
  2. export function batchRow(list, rowWidth) {
  3. var rows = [];
  4. var row = [];
  5. Ember.EnumerableUtils.forEach(list, function(element) {
  6. row.push(element);
  7. if (row.length === rowWidth) {
  8. rows.push(row);
  9. row = [];
  10. }
  11. });
  12. if (row.length) {
  13. rows.push(row);
  14. }
  15. return rows;
  16. }
  17. export default Ember.Handlebars.makeBoundHelper(batchRow);