2018-11-11 02:25:47 +01:00
|
|
|
class BaseUi {
|
|
|
|
constructor(id, label, onClick, additionalClasses) {
|
|
|
|
this.element = document.createElement('div');
|
|
|
|
this.element.setAttribute('id', id);
|
|
|
|
if (additionalClasses) {
|
|
|
|
this.element.classList.add(...additionalClasses);
|
|
|
|
}
|
|
|
|
if (onClick) {
|
|
|
|
this.element.addEventListener('click', onClick);
|
|
|
|
}
|
|
|
|
this.element.innerHTML = label;
|
|
|
|
}
|
|
|
|
|
|
|
|
disable() {
|
|
|
|
this.element.classList.add('disabled');
|
|
|
|
}
|
|
|
|
enable() {
|
|
|
|
this.element.classList.remove('disabled');
|
|
|
|
}
|
|
|
|
hide() {
|
|
|
|
this.element.classList.add('hidden');
|
|
|
|
}
|
|
|
|
show() {
|
|
|
|
this.element.classList.remove('hidden');
|
|
|
|
}
|
2018-11-11 22:35:08 +01:00
|
|
|
select() {
|
|
|
|
this.element.classList.add('selected');
|
|
|
|
}
|
|
|
|
unselect() {
|
|
|
|
this.element.classList.remove('selected');
|
|
|
|
}
|
2018-11-11 02:25:47 +01:00
|
|
|
appendTo(element) {
|
|
|
|
element.appendChild(this.element);
|
|
|
|
}
|
|
|
|
}
|