mapcomplete/UI/Base/Link.ts

24 lines
703 B
TypeScript
Raw Permalink Normal View History

2020-11-05 12:28:02 +01:00
import {UIElement} from "../UIElement";
2020-11-06 01:58:26 +01:00
import Translations from "../i18n/Translations";
2020-11-05 12:28:02 +01:00
export default class Link extends UIElement {
private readonly _embeddedShow: UIElement;
private readonly _target: string;
private readonly _newTab: string;
2020-11-06 01:58:26 +01:00
constructor(embeddedShow: UIElement | string, target: string, newTab: boolean = false) {
2020-11-05 12:28:02 +01:00
super();
2020-11-06 01:58:26 +01:00
this._embeddedShow = Translations.W(embeddedShow);
2020-11-05 12:28:02 +01: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>`;
}
}