37 lines
998 B
TypeScript
37 lines
998 B
TypeScript
|
import { UINode } from "./node";
|
||
|
|
||
|
export class ProgressBar extends UINode {
|
||
|
private progressElement: HTMLProgressElement;
|
||
|
public constructor(title: string, max: number) {
|
||
|
super(title);
|
||
|
this.progressElement = document.createElement("progress");
|
||
|
this.progressElement.max = max;
|
||
|
this.element.appendChild(this.progressElement);
|
||
|
this.element.setAttribute("aria-label", title);
|
||
|
}
|
||
|
|
||
|
public getElement(): HTMLElement {
|
||
|
return this.progressElement;
|
||
|
}
|
||
|
|
||
|
public setText(text: string) {
|
||
|
this.title = text;
|
||
|
this.element.setAttribute("aria-label", text);
|
||
|
}
|
||
|
|
||
|
public getValue(): number {
|
||
|
return this.progressElement.value;
|
||
|
}
|
||
|
|
||
|
public setValue(value: number) {
|
||
|
this.progressElement.value = value;
|
||
|
}
|
||
|
|
||
|
public getMax(): number {
|
||
|
return this.progressElement.max;
|
||
|
}
|
||
|
|
||
|
public setMax(max: number) {
|
||
|
this.progressElement.max = max;
|
||
|
}
|
||
|
}
|