UNPKG

@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.

144 lines 6.23 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { ArgumentNullException } from "../../Exception"; import { EventObject } from "../../EventObject"; import * as _ from "underscore"; import { Property } from "../Decorators/Property"; var ResizeGripsPermissions = /** @class */ (function () { function ResizeGripsPermissions(proportional, arbitrary, arbitraryFirst) { if (arbitraryFirst === void 0) { arbitraryFirst = true; } this._edgeConstraint = null; this._cornerArbitraryConstraint = null; this.propertyChanged = new EventObject(); this.type = ResizeGripsPermissions.type; this.edge = arbitrary; this._setCornerValues(proportional, arbitrary, arbitraryFirst); } Object.defineProperty(ResizeGripsPermissions.prototype, "edgeConstraint", { set: function (value) { var oldVal = this.edge; this._edgeConstraint = value; if (this.edge !== oldVal) this.propertyChanged.notify(); }, enumerable: true, configurable: true }); Object.defineProperty(ResizeGripsPermissions.prototype, "edge", { get: function () { return this._edgeConstraint != null ? this._edgeConstraint : this._edge; }, set: function (value) { if (this._edge === value) return; this._edge = value; this.propertyChanged.notify(); }, enumerable: true, configurable: true }); Object.defineProperty(ResizeGripsPermissions.prototype, "corner", { get: function () { return this._corner; }, set: function (value) { if (value == null) { throw new ArgumentNullException("corner cannot be null"); } if (this._corner === value) return; this._corner = value; this.propertyChanged.notify(); }, enumerable: true, configurable: true }); ResizeGripsPermissions.prototype._setCornerValues = function (proportional, arbitrary, arbitraryFirst) { if (proportional && arbitrary) { this.corner = arbitraryFirst ? [ResizeGripsPermissions.arbitrary, ResizeGripsPermissions.proportional] : [ResizeGripsPermissions.proportional, ResizeGripsPermissions.arbitrary]; } else if (proportional) { this.corner = [ResizeGripsPermissions.proportional]; } else if (arbitrary) { this.corner = [ResizeGripsPermissions.arbitrary]; } else { this.corner = []; } }; ResizeGripsPermissions.prototype.getCornerProportional = function () { return this.corner.includes(ResizeGripsPermissions.proportional); }; ResizeGripsPermissions.prototype.getCornerArbitrary = function () { return this._cornerArbitraryConstraint != null ? this._cornerArbitraryConstraint : this.corner.includes(ResizeGripsPermissions.arbitrary); }; ResizeGripsPermissions.prototype.setCornerProportional = function (value) { var arb = this.getCornerArbitrary(); this._setCornerValues(value, arb, true); }; ResizeGripsPermissions.prototype.setCornerArbitrary = function (value) { var prop = this.getCornerProportional(); this._setCornerValues(prop, value, true); }; ResizeGripsPermissions.prototype.setCornerArbitraryConstraint = function (value) { var oldVal = this.getCornerArbitrary(); this._cornerArbitraryConstraint = value; if (this.getCornerArbitrary() !== oldVal) this.propertyChanged.notify(); }; ResizeGripsPermissions.prototype.clone = function () { var result = new ResizeGripsPermissions(true, true); result.edge = this.edge; result.corner = this.corner.slice(); return result; }; ResizeGripsPermissions.prototype.equals = function (p) { return this.edge === p.edge && _.isEqual(this.corner, p.corner); }; Object.defineProperty(ResizeGripsPermissions.prototype, "data", { get: function () { return { Edge: this.edge, Corner: this.corner }; }, enumerable: true, configurable: true }); ResizeGripsPermissions._fromData = function (data) { if (data == null) return new ResizeGripsPermissions(false, false); var result = new ResizeGripsPermissions(true, true); result.corner = data.Corner; result.edge = data.Edge; return result; }; ResizeGripsPermissions.prototype.getSimplifiedObject = function () { var result = {}; result["edge"] = this.edge; result["corner"] = this.corner; return result; }; ResizeGripsPermissions.arbitrary = "Arbitrary"; ResizeGripsPermissions.proportional = "Proportional"; ResizeGripsPermissions.type = "ResizeGripsPermissions"; __decorate([ Property({ ignore: true }), __metadata("design:type", Boolean), __metadata("design:paramtypes", [Boolean]) ], ResizeGripsPermissions.prototype, "edgeConstraint", null); return ResizeGripsPermissions; }()); export { ResizeGripsPermissions }; //# sourceMappingURL=ResizeGripsPermissions.js.map