@webuildbots/webuildbots-sdk
Version:
webuildbots sdk
64 lines (63 loc) • 2.65 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var block_enums_1 = require("../../const/block-enums");
var block_builder_1 = __importDefault(require("./block-builder"));
/**
* @depreciated - Use {@link GalleryBB} instead
*/
var ComplexBB = /** @class */ (function (_super) {
__extends(ComplexBB, _super);
function ComplexBB(complexBlockType, topElementStyle, imageAspectRatio) {
if (complexBlockType === void 0) { complexBlockType = block_enums_1.ComplexBlockTypes.GENERIC; }
var _this = _super.call(this) || this;
_this.block.type = block_enums_1.BlockTypes.COMPLEX;
_this.block.content.items = [];
_this.block.meta.complexBlockType = complexBlockType;
if (topElementStyle) {
_this.block.meta.topElementStyle = topElementStyle;
}
if (imageAspectRatio) {
_this.block.meta.imageAspectRatio = imageAspectRatio;
}
return _this;
}
ComplexBB.prototype.pushItem = function (ib) {
// Add the item
var item = ib.build();
this.block.content.items.push(item);
// Check if we need to set the topElementStyle.
var isFirstItem = this.block.content.items.length === 1;
var isList = this.block.meta.complexBlockType === block_enums_1.ComplexBlockTypes.LIST;
var styleIsSet = this.block.meta.topElementStyle != null;
if (!isFirstItem || !isList || styleIsSet) {
return this;
}
// Set topElementStyle
if (item.image) {
this.block.meta.topElementStyle = block_enums_1.TopElementStyles.LARGE;
}
else {
this.block.meta.topElementStyle = block_enums_1.TopElementStyles.COMPACT;
}
return this;
};
ComplexBB.ITEM_LIMIT = 10;
return ComplexBB;
}(block_builder_1.default));
exports.default = ComplexBB;