Further work on infobox, styling everything, removing clutter

This commit is contained in:
Pieter Vander Vennet 2020-06-27 03:06:51 +02:00
parent 2acd53d150
commit 0b4016b65d
48 changed files with 1283 additions and 454 deletions

View file

@ -6,6 +6,8 @@ export abstract class UIElement {
public readonly id: string;
public readonly _source: UIEventSource<any>;
private _hideIfEmpty = false;
protected constructor(source: UIEventSource<any>) {
this.id = "ui-element-" + UIElement.nextId;
@ -33,9 +35,23 @@ export abstract class UIElement {
}
element.innerHTML = this.InnerRender();
if(this._hideIfEmpty){
if(element.innerHTML === ""){
element.parentElement.style.display = "none";
}else{
element.parentElement.style.display = undefined;
}
}
this.InnerUpdate(element);
}
HideOnEmpty(hide : boolean){
this._hideIfEmpty = hide;
this.Update();
return this;
}
// Called after the HTML has been replaced. Can be used for css tricks
InnerUpdate(htmlElement : HTMLElement){}
@ -45,6 +61,10 @@ export abstract class UIElement {
AttachTo(divId: string) {
let element = document.getElementById(divId);
if(element === null){
console.log("SEVERE: could not attach UIElement to ", divId);
return;
}
element.innerHTML = this.Render();
this.Update();
return this;