mapcomplete/UI/Base/VerticalCombine.ts

40 lines
1 KiB
TypeScript
Raw Normal View History

2020-06-29 03:12:44 +02:00
import {UIElement} from "../UIElement";
2020-06-24 00:35:19 +02:00
export class VerticalCombine extends UIElement {
private _elements: UIElement[];
private _className: string;
constructor(elements: UIElement[], className: string = undefined) {
2020-06-24 00:35:19 +02:00
super(undefined);
this._elements = elements;
this._className = className;
2020-06-24 00:35:19 +02:00
}
protected InnerRender(): string {
let html = "";
for (const element of this._elements) {
2020-06-24 00:35:19 +02:00
if (!element.IsEmpty()) {
html += "<div>" + element.Render() + "</div>";
2020-06-24 00:35:19 +02:00
}
}
if(html === ""){
return "";
}
if (this._className === undefined) {
return html;
}
return "<div class='"+this._className+"'>" + html + "</div>";
2020-06-24 00:35:19 +02:00
}
InnerUpdate(htmlElement: HTMLElement) {
for (const element of this._elements){
element.Update();
}
2020-06-24 00:35:19 +02:00
}
Activate() {
for (const element of this._elements){
element.Activate();
}
}
}