mapcomplete/UI/Base/Link.ts

24 lines
703 B
TypeScript
Raw Normal View History

2020-11-05 11:28:02 +00:00
import {UIElement} from "../UIElement";
2020-11-06 00:58:26 +00:00
import Translations from "../i18n/Translations";
2020-11-05 11:28:02 +00:00
export default class Link extends UIElement {
private readonly _embeddedShow: UIElement;
private readonly _target: string;
private readonly _newTab: string;
2020-11-06 00:58:26 +00:00
constructor(embeddedShow: UIElement | string, target: string, newTab: boolean = false) {
2020-11-05 11:28:02 +00:00
super();
2020-11-06 00:58:26 +00:00
this._embeddedShow = Translations.W(embeddedShow);
2020-11-05 11:28:02 +00:00
this._target = target;
this._newTab = "";
if (newTab) {
this._newTab = "target='_blank'"
}
}
InnerRender(): string {
return `<a href="${this._target}" ${this._newTab}>${this._embeddedShow.Render()}</a>`;
}
}