mr-crocs-adventures/tilorswift/js/menu/WidgetBar.js

51 lines
1009 B
JavaScript

export default class WidgetBar
{
constructor(id)
{
this.id = id;
this.widgets = [];
}
addWidget(widget)
{
this.widgets.push(widget);
}
getElement()
{
let htmlElement = document.createElement('div');
htmlElement.id = this.id;
this.widgets.forEach(
(widget) => {
let container = document.createElement('div');
container.classList.add('widget-container');
container.appendChild(widget.getTitle());
container.appendChild(widget.getElement());
htmlElement.appendChild(container);
}
);
return htmlElement;
}
enableWidgets()
{
this.widgets.forEach(
(widget) => {
widget.enable();
}
);
}
disableWidgets()
{
this.widgets.forEach(
(widget) => {
widget.disable();
}
);
}
}