Sha256: ba7ee2c50593b3c0b4784f0b8035ff365009a71cb0b19727d294d80672dbb553

Contents?: true

Size: 829 Bytes

Versions: 7

Compression:

Stored size: 829 Bytes

Contents

pageflow.sitemap.layout.ChapterCollision = function(pagesGroupedByChapters) {
  this.pagesGroupedByChapters = function() {
    var laneHeights = {};

    return _(pagesGroupedByChapters).map(function(group) {
      var chapter = group.chapter;

      if (!chapter) {
        return group;
      }

      var lane = chapter.configuration.get('lane') || 0;
      var row = chapter.configuration.get('row') || 0;

      return {
        chapter: chapter,
        pages: group.pages,
        lane: lane,
        row: freeRow(lane, row, group.pages.length)
      };

      function freeRow(lane, row, pagesCount) {
        var laneHeight = laneHeights[lane] || 0;
        var result;

        result = Math.max(laneHeight, row);
        laneHeights[lane] = result + pagesCount + 1;

        return result;
      }
    }, []);
  };
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pageflow-sitemap-1.5.0 app/assets/javascripts/pageflow/sitemap/editor/d3/layout/chapter_collision.js
pageflow-sitemap-1.4.0 app/assets/javascripts/pageflow/sitemap/editor/d3/layout/chapter_collision.js
pageflow-sitemap-1.3.0 app/assets/javascripts/pageflow/sitemap/editor/d3/layout/chapter_collision.js
pageflow-sitemap-1.2.0 app/assets/javascripts/pageflow/sitemap/editor/d3/layout/chapter_collision.js
pageflow-sitemap-1.1.0 app/assets/javascripts/pageflow/sitemap/editor/d3/layout/chapter_collision.js
pageflow-sitemap-1.0.0 app/assets/javascripts/pageflow/sitemap/editor/d3/layout/chapter_collision.js
pageflow-sitemap-0.1.0 app/assets/javascripts/pageflow/sitemap/editor/d3/layout/chapter_collision.js