Problem/Motivation

If you use a breakpoint with a 16 column grid the LayoutManager won't show the columns and you're unable to configure the regions because there's no css that defines how width the columns have to be.

Proposed resolution

Attached patch removes the css and replaces it by a calculated width for all grids. Since the total columns always have to be 100% width that's a fairly easy calculation.
Further I've added a check to prevent the LayoutManager from displaying stupid breakpoint width's. It's simply to hard to configure a breakpoint <200px - thus the LayoutManager has now a min width of 250px and notices the user if this minimal width is used.

Remaining tasks

Reviews needed

User interface changes

Hopefully improvements...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

das-peter’s picture

And here's the follow-up. Unfortunately, the regions also rely on that grid css.
As I don't know a better way to access the current number of columns of the grid in Region.prototype.alterSpan() I added those now as parameter :|
If there's an easier way to access that information the patch would be smaller ;)
However, the approach is the same -> calculate the width as percentage.

das-peter’s picture

Ooops, there was still an issue in the previous patch.
Fixed missing isRelative parameter in one of the modified calls.

Further I noticed that LayoutStep.prototype.startRegionResize() seems to calculate odd data.
Thus I've that patched as well:

  • Use this.$editor.width() to calculate the frame width - this is the effective value and not the "it should be like defined in the step" one ;) (Had some trouble with margins)
  • Added values that define where the most left / right columns of the region are
  • Changed max left / right traversal values. I think they make more sense now - e.g. if you drag the right handle to the left you shouldn't be allowed to make the region smaller than 1 column.
     LayoutStep.prototype.modifyRegionBuild = function ($region) {
@@ -122,16 +122,18 @@
       });
       // Calculate the column size so regions can be snapped to grid columns.
       data.totalColumns = Number(this.grid.info('columns'));
-      data.frame = Math.floor(Number(this.step.info('size')) / data.totalColumns);
+      data.frame = Math.floor(Number(this.$editor.width()) / data.totalColumns);
       // Store the X origin of the original click.
       data.originX = event.pageX;
       // Get the column the resize started in.
       widthOffset = (data.side === 'right') ? data.width : 0;
       originalColumn = Math.floor(($region.position().left + widthOffset) / data.frame);
       data.originColumn = (data.side === 'left') ? ++originalColumn : originalColumn;
+      data.leftColumn = Math.ceil($region.position().left / data.frame) + 1;
+      data.rightColumn = Math.ceil(data.leftColumn + (data.width / data.frame));
       // Calculate the left and right bounds for the resizing.
-      data.rightMaxTraversal = data.totalColumns - data.originColumn;
-      data.leftMaxTraversal = (data.originColumn -1) * -1;
+      data.rightMaxTraversal = (data.side === 'left') ? ((data.rightColumn - data.leftColumn - 1)) : ((data.totalColumns - data.rightColumn + 1));
+      data.leftMaxTraversal = (data.side === 'right') ? ((data.rightColumn - data.leftColumn - 1) * -1) : (data.leftColumn - 1) * -1;
       // Add behaviors.
das-peter’s picture