diff --git a/admin-console/src/main/webapp/resources/administration/js/entando.grid-generator.js b/admin-console/src/main/webapp/resources/administration/js/entando.grid-generator.js index e401e3711..cb5b31fa1 100644 --- a/admin-console/src/main/webapp/resources/administration/js/entando.grid-generator.js +++ b/admin-console/src/main/webapp/resources/administration/js/entando.grid-generator.js @@ -1,7 +1,5 @@ - (function(context){ - /** * @constructor * @param {Object} options - the options @@ -9,25 +7,22 @@ * @param {number} options.rowHeight - the row height in pixels */ function GridGenerator(options) { - var me = this; - - if (_.isEmpty(options.frames)) { - throw this.newError(GridGenerator.MISSING_FRAMES); - } - this.options = options; - this.originalFrames = options.frames; - var lastDefinedFrame = _.maxBy(options.frames, 'sketch.y2'); + var bottomRight; + if (_.isEmpty(options.frames)) { + bottomRight = 0; + } else { + bottomRight = _.get(lastDefinedFrame, 'sketch.y2', -1); + } this.totalBoundaries = { x1: 0, y1: 0, x2: 11, - y2: _.get(lastDefinedFrame, 'sketch.y2', -1) + y2: bottomRight }; - this.totalFrames = _.map(options.frames, function(frame) { var internalFrame; if (frame.sketch) { @@ -40,23 +35,19 @@ y1: me.totalBoundaries.y2, y2: me.totalBoundaries.y2 }; - } internalFrame.description = frame.description; internalFrame.pos = frame.pos; return internalFrame; }); - var malformed = this.detectMalformed(this.totalFrames); if (!_.isEmpty(malformed)) { throw this.newError(GridGenerator.ERROR.MALFORMED_FRAMES, malformed); } - var overlaps = this.detectOverlaps(this.totalFrames); if (!_.isEmpty(overlaps)) { throw this.newError(GridGenerator.ERROR.OVERLAPPING_FRAMES, overlaps); } - } GridGenerator.ERROR = { @@ -68,7 +59,6 @@ var DIRECTION_ROW = 'row', DIRECTION_COL = 'col'; - /** * Returns all frames with the auto-generated missing sketch properties * @returns {Array} @@ -111,7 +101,6 @@ }); }; - /** * Returns all frames included in the frames param, that * are in the specified section (grid row or column) @@ -125,15 +114,12 @@ p = (direction === DIRECTION_ROW ? 'y' : 'x'), p1 = p+1, p2 = p+2; - for (var i=section[p1]; i<=section[p2]; ++i) { framesInSection.push(this.getFramesAtIndex(frames, direction, i)); } return _.uniq(_.flatten(framesInSection)); }; - - /** * Returns a set of sections (grid rows or columns) * @param {Array} frames - the frames to be considered @@ -142,7 +128,6 @@ * @returns {Array} a set of sections (grid rows or columns) */ GridGenerator.prototype.splitSections = function splitSections(frames, boundaries, direction) { - var p1, p2, propsToPick; if (direction === DIRECTION_ROW) { p1 = 'y1'; @@ -153,42 +138,32 @@ p2 = 'x2'; propsToPick = ['y1', 'y2']; } - var startIndex = boundaries[p1]; var endIndex = boundaries[p2]; - - var sections = []; var curSection = _.pick(boundaries, propsToPick); curSection[p1] = startIndex; - - for (var i=startIndex; i'; } else { content = this.readTree(col); } - var classes = [ 'col-xs-' + l, (content && !col.rows? 'grid-slot' : 'empty-slot') @@ -354,7 +296,6 @@ if (isMainFrame) { classes.push('topFrame'); } - html += '