2020-06-29 03:12:44 +02:00
|
|
|
import {UIElement} from "../UIElement";
|
2020-07-25 18:00:08 +02:00
|
|
|
import Translations from "../i18n/Translations";
|
2021-06-12 02:58:32 +02:00
|
|
|
import BaseUIElement from "../BaseUIElement";
|
2020-06-29 03:12:44 +02:00
|
|
|
|
2021-06-15 00:55:12 +02:00
|
|
|
export class Button extends BaseUIElement {
|
2021-06-12 02:58:32 +02:00
|
|
|
private _text: BaseUIElement;
|
2020-06-29 03:12:44 +02:00
|
|
|
private _onclick: () => void;
|
|
|
|
|
2021-06-15 00:55:12 +02:00
|
|
|
constructor(text: string | UIElement, onclick: (() => void)) {
|
|
|
|
super();
|
2020-07-25 18:00:08 +02:00
|
|
|
this._text = Translations.W(text);
|
2020-06-29 03:12:44 +02:00
|
|
|
this._onclick = onclick;
|
|
|
|
}
|
|
|
|
|
2021-06-15 00:55:12 +02:00
|
|
|
protected InnerConstructElement(): HTMLElement {
|
|
|
|
const el = this._text.ConstructElement();
|
|
|
|
if(el === undefined){
|
|
|
|
return undefined;
|
2020-06-29 03:12:44 +02:00
|
|
|
}
|
2021-06-15 00:55:12 +02:00
|
|
|
const form = document.createElement("form")
|
|
|
|
const button = document.createElement("button")
|
|
|
|
button.type = "button"
|
|
|
|
button.appendChild(el)
|
|
|
|
button.onclick = this._onclick
|
|
|
|
form.appendChild(button)
|
|
|
|
return form;
|
2020-06-29 03:12:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|