mapcomplete/UI/Base/Combine.ts

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-07-20 23:37:48 +00:00
import {UIElement} from "../UIElement";
import Translations from "../i18n/Translations";
export default class Combine extends UIElement {
private uiElements: (string | UIElement)[];
2020-07-31 02:58:58 +00:00
private className: string = undefined;
2020-07-23 14:28:19 +00:00
private clas: string = undefined;
2020-07-20 23:37:48 +00:00
2020-07-31 02:58:58 +00:00
constructor(uiElements: (string | UIElement)[], className: string = undefined) {
2020-07-20 23:37:48 +00:00
super(undefined);
2020-07-31 02:58:58 +00:00
this.className = className;
this.uiElements = uiElements;
2020-07-20 23:37:48 +00:00
}
InnerRender(): string {
let elements = "";
for (const element of this.uiElements) {
if (element instanceof UIElement) {
elements += element.Render();
} else {
elements += element;
}
2020-07-20 23:37:48 +00:00
}
2020-07-31 02:58:58 +00:00
if(this.className !== undefined){
elements = `<span class='${this.className}'>${elements}</span>`;
}
2020-07-20 23:37:48 +00:00
return elements;
}
2020-07-22 13:56:43 +00:00
InnerUpdate(htmlElement: HTMLElement) {
for (const element of this.uiElements) {
if (element instanceof UIElement) {
element.Update();
}
}
}
2020-07-20 23:37:48 +00:00
}