UNPKG

core-cde

Version:

59 lines 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HyperLink = void 0; const Errors_1 = require("../Errors"); const Text_1 = require("./Text"); class HyperLink extends Text_1.Text { constructor(type, id) { super(type, id); /** * Ссылка */ this._url = null; } get url() { return this._url; } set url(value) { this._url = value; if (value.length > 0 && value[0] !== '#') { this.pageId = null; this.widgetId = null; this.isExtRef = true; return; } this.isExtRef = false; } /** * Получить объект класса HyperLink из json * @param json валидная json строка * @returns объект класса HyperLink */ static fromJSON(json) { try { return Object.assign(new HyperLink(null, null), JSON.parse(json)); } catch (error) { throw new Errors_1.JsonParseError('HyperLink widget'); } } /** * Получить объект для сериализации * @returns Объект для сериализации */ toJSON() { return Object.assign({}, null, { id: this.id, type: this.type, styles: this.styles, value: this.value, textAlign: this.textAlign, _url: this._url, isExtRef: this.isExtRef, pageId: this.pageId, widgetId: this.widgetId }); } } exports.HyperLink = HyperLink; //# sourceMappingURL=HyperLink.js.map