2020-06-24 00:35:19 +02:00
|
|
|
import {UIElement} from "./UIElement";
|
|
|
|
import {UIEventSource} from "./UIEventSource";
|
2020-07-30 09:59:30 +02:00
|
|
|
import {OsmConnection} from "../Logic/Osm/OsmConnection";
|
2020-07-20 23:43:42 +02:00
|
|
|
import Translations from "./i18n/Translations";
|
2020-07-31 01:45:54 +02:00
|
|
|
import {State} from "../State";
|
2020-06-24 00:35:19 +02:00
|
|
|
|
|
|
|
export class CenterMessageBox extends UIElement {
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
) {
|
2020-07-31 01:45:54 +02:00
|
|
|
super(State.state.centerMessage);
|
2020-06-24 00:35:19 +02:00
|
|
|
|
2020-07-31 01:45:54 +02:00
|
|
|
this.ListenTo(State.state.locationControl);
|
2020-07-31 16:17:16 +02:00
|
|
|
this.ListenTo(State.state.layerUpdater.retries);
|
|
|
|
this.ListenTo(State.state.layerUpdater.runningQuery);
|
|
|
|
this.ListenTo(State.state.layerUpdater.sufficentlyZoomed);
|
2020-06-24 00:35:19 +02:00
|
|
|
}
|
|
|
|
|
2020-07-31 01:45:54 +02:00
|
|
|
private prep(): { innerHtml: string, done: boolean } {
|
|
|
|
if (State.state.centerMessage.data != "") {
|
|
|
|
return {innerHtml: State.state.centerMessage.data, done: false};
|
2020-06-24 00:35:19 +02:00
|
|
|
}
|
2020-07-31 16:17:16 +02:00
|
|
|
const lu = State.state.layerUpdater;
|
|
|
|
if(lu.retries.data > 0) {
|
|
|
|
return {innerHtml: Translations.t.centerMessage.retrying.Subs({count: ""+ lu.retries.data}).Render(), done: false};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lu.runningQuery.data) {
|
2020-07-31 01:45:54 +02:00
|
|
|
return {innerHtml: Translations.t.centerMessage.loadingData.Render(), done: false};
|
2020-07-31 16:17:16 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
if (!lu.sufficentlyZoomed.data) {
|
2020-07-31 01:45:54 +02:00
|
|
|
return {innerHtml: Translations.t.centerMessage.zoomIn.Render(), done: false};
|
|
|
|
} else {
|
|
|
|
return {innerHtml: Translations.t.centerMessage.ready.Render(), done: true};
|
2020-06-24 00:35:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-31 01:45:54 +02:00
|
|
|
InnerRender(): string {
|
|
|
|
return this.prep().innerHtml;
|
2020-06-24 00:35:19 +02:00
|
|
|
}
|
|
|
|
|
2020-07-31 01:45:54 +02:00
|
|
|
|
2020-06-24 00:35:19 +02:00
|
|
|
InnerUpdate(htmlElement: HTMLElement) {
|
|
|
|
const pstyle = htmlElement.parentElement.style;
|
2020-07-31 01:45:54 +02:00
|
|
|
if (State.state.centerMessage.data != "") {
|
2020-06-24 00:35:19 +02:00
|
|
|
pstyle.opacity = "1";
|
|
|
|
pstyle.pointerEvents = "all";
|
2020-07-31 01:45:54 +02:00
|
|
|
State.state.osmConnection.registerActivateOsmAUthenticationClass();
|
2020-06-24 00:35:19 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
pstyle.pointerEvents = "none";
|
|
|
|
|
2020-07-31 01:45:54 +02:00
|
|
|
if (this.prep().done) {
|
2020-06-24 00:35:19 +02:00
|
|
|
pstyle.opacity = "0";
|
2020-07-31 01:45:54 +02:00
|
|
|
} else {
|
|
|
|
pstyle.opacity = "0.5";
|
2020-06-24 00:35:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|