forked from MapComplete/MapComplete
Cleanup of code
This commit is contained in:
parent
dd91e11bd0
commit
e0f9a93468
12 changed files with 193 additions and 369 deletions
|
@ -1,35 +0,0 @@
|
|||
import {UIElement} from "../UIElement";
|
||||
import {UIEventSource} from "../UIEventSource";
|
||||
import { FilteredLayer } from "../../Logic/FilteredLayer";
|
||||
import Translations from "../../UI/i18n/Translations";
|
||||
|
||||
|
||||
export class CheckBox extends UIElement{
|
||||
private data: UIEventSource<boolean>;
|
||||
|
||||
private readonly _data: UIEventSource<boolean>;
|
||||
private readonly _showEnabled: string|UIElement;
|
||||
private readonly _showDisabled: string|UIElement;
|
||||
|
||||
constructor(showEnabled: string|UIElement, showDisabled: string|UIElement, data: UIEventSource<boolean> = undefined) {
|
||||
super(undefined);
|
||||
this._data = data ?? new UIEventSource<boolean>(false);
|
||||
this.ListenTo(this._data);
|
||||
this._showEnabled = showEnabled;
|
||||
this._showDisabled = showDisabled;
|
||||
const self = this;
|
||||
this.onClick(() => {
|
||||
self._data.setData(!self._data.data);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
if (this._data.data) {
|
||||
return Translations.W(this._showEnabled).Render();
|
||||
} else {
|
||||
return Translations.W(this._showDisabled).Render();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
import {UIElement} from "../UIElement";
|
||||
import {UIEventSource} from "../UIEventSource";
|
||||
|
||||
|
||||
export class CollapseButton extends UIElement {
|
||||
public isCollapsed = new UIEventSource(false);
|
||||
|
||||
constructor(idToCollapse: string) {
|
||||
super(undefined);
|
||||
this.ListenTo(this.isCollapsed);
|
||||
this.isCollapsed.addCallback((collapse) => {
|
||||
const el = document.getElementById(idToCollapse);
|
||||
if (el === undefined || el === null) {
|
||||
console.log("Element not found")
|
||||
return;
|
||||
}
|
||||
if (collapse) {
|
||||
el.style.height = "3.5em";
|
||||
el.style.width = "15em";
|
||||
} else {
|
||||
el.style.height = "auto";
|
||||
el.style.width = "auto";
|
||||
}
|
||||
});
|
||||
|
||||
const self = this;
|
||||
this.onClick(() => {
|
||||
self.isCollapsed.setData(!self.isCollapsed.data);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
protected InnerRender(): string {
|
||||
const up = './assets/arrow-up.svg';
|
||||
const down = './assets/arrow-down.svg';
|
||||
let arrow = up;
|
||||
if (this.isCollapsed.data) {
|
||||
arrow = down;
|
||||
}
|
||||
return `<img class='collapse-button' src='${arrow}' alt='collapse'>`;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue