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

51 lines
1009 B
JavaScript
Raw Normal View History

2020-02-04 21:42:14 +01:00
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');
2020-02-04 23:03:33 +01:00
container.classList.add('widget-container');
2020-02-04 21:42:14 +01:00
container.appendChild(widget.getTitle());
container.appendChild(widget.getElement());
htmlElement.appendChild(container);
}
);
return htmlElement;
}
2020-02-04 23:03:33 +01:00
enableWidgets()
{
this.widgets.forEach(
(widget) => {
widget.enable();
}
);
}
disableWidgets()
{
this.widgets.forEach(
(widget) => {
widget.disable();
}
);
}
2020-02-04 21:42:14 +01:00
}