@aurigma/design-atoms-model
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
118 lines • 5.42 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 (b.hasOwnProperty(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 __());
};
})();
import { RgbColors } from "../../Colors";
import { RectangleItem } from "./RectangleItem";
import { SurfaceContainer } from "../Container";
import * as Math from "../../Math/index";
import * as _ from "underscore";
import { equals } from "../../Utils/Utils";
var ContentItem = /** @class */ (function (_super) {
__extends(ContentItem, _super);
function ContentItem() {
var _this = _super.call(this) || this;
_this._maskOpacity = 0.45;
_this._parentPlaceholder = null;
_this.type = ContentItem.type;
_this.borderWidth = 0;
_this.fillColor = RgbColors.transparent;
_this._ignorePermissionsChange = true;
_this.itemPermissions.itemToolbarPermissions.showEditButton = true;
_this._ignorePermissionsChange = false;
return _this;
}
Object.defineProperty(ContentItem.prototype, "maskOpacity", {
get: function () {
return this._maskOpacity;
},
set: function (value) {
if (!Math.EqualsOfFloatNumbers(this._maskOpacity, value)) {
this._maskOpacity = value;
this._propertyChanged.notify(this, "maskOpacity");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(ContentItem.prototype, "parentPlaceholder", {
get: function () {
return this._parentPlaceholder;
},
set: function (value) {
this._parentPlaceholder = value;
this._propertyChanged.notify(this, "parentPlaceholder");
},
enumerable: true,
configurable: true
});
ContentItem.prototype.applyPermissionsConstrain = function () {
if (this.parentPlaceholder != null) {
if (this.parentPlaceholder.isCoverMode) {
this.manipulationPermissions.resizeGrips.edgeConstraint = false;
this.manipulationPermissions.resizeGrips.setCornerArbitraryConstraint(false);
this.manipulationPermissions.allowRotateConstraint = false;
}
else {
this.manipulationPermissions.resizeGrips.edgeConstraint = null;
this.manipulationPermissions.resizeGrips.setCornerArbitraryConstraint(null);
this.manipulationPermissions.allowRotateConstraint = null;
}
this.parentPlaceholder.applyPermissionsConstrain();
}
if (this.isRenderTypeIsNormal)
return;
this.itemPermissions.allowOpacityChange = false;
this.shapePermissions.allowChangeBorderColor = false;
this.shapePermissions.allowChangeFillColor = false;
};
ContentItem.prototype.getSimplifiedObject = function (omitProperties) {
if (!_.isArray(omitProperties) && !_.isString(omitProperties))
omitProperties = [];
return _super.prototype.getSimplifiedObject.call(this, ["parentPlaceholder"].concat(omitProperties));
};
ContentItem.prototype._canSetIsVariable = function () {
return true;
};
ContentItem.prototype._getPrintAreaBounds = function () {
var parentContainer = this.parentContainer != null ? this.parentContainer : this.parentPlaceholder != null ? this.parentPlaceholder.parentContainer : null;
if (parentContainer instanceof SurfaceContainer)
return parentContainer.parentComponent.bounds;
return null;
};
ContentItem.prototype._getParentContainer = function () {
if (this.parentPlaceholder != null)
return this.parentPlaceholder.parentContainer;
return null;
};
ContentItem.prototype._copy = function (source, destination, generateNewIds, appropriateParentContainer) {
_super.prototype._copy.call(this, source, destination, generateNewIds, appropriateParentContainer);
destination._maskOpacity = source._maskOpacity;
destination.isVariable = source.isVariable;
};
ContentItem.prototype.equals = function (other) {
return _super.prototype.equals.call(this, other) &&
equals(this._maskOpacity, other._maskOpacity) &&
equals(this.isVariable, other.isVariable);
};
ContentItem.prototype.clone = function (generateNewIds, appropriateParentContainer) {
if (generateNewIds === void 0) { generateNewIds = false; }
if (appropriateParentContainer === void 0) { appropriateParentContainer = false; }
var item = new ContentItem();
this._copy(this, item, generateNewIds, appropriateParentContainer);
return item;
};
ContentItem.type = "ContentItem";
return ContentItem;
}(RectangleItem));
export { ContentItem };
//# sourceMappingURL=ContentItem.js.map