2020-06-27 03:06:51 +02:00
|
|
|
import {UIEventSource} from "./UIEventSource";
|
|
|
|
import {UIElement} from "./UIElement";
|
2020-06-29 03:12:44 +02:00
|
|
|
import {VariableUiElement} from "./Base/VariableUIElement";
|
2020-07-21 02:55:28 +02:00
|
|
|
import Translations from "./i18n/Translations";
|
2020-07-31 01:45:54 +02:00
|
|
|
import {State} from "../State";
|
2020-06-27 03:06:51 +02:00
|
|
|
|
2020-07-21 02:55:28 +02:00
|
|
|
/**
|
|
|
|
* Handles the full screen popup on mobile
|
|
|
|
*/
|
|
|
|
export class FullScreenMessageBoxHandler {
|
2020-07-31 01:45:54 +02:00
|
|
|
|
2020-07-21 00:07:04 +02:00
|
|
|
private _uielement: UIEventSource<UIElement>;
|
2020-06-27 03:06:51 +02:00
|
|
|
|
2020-07-31 01:45:54 +02:00
|
|
|
constructor(onClear: (() => void)) {
|
|
|
|
this._uielement = State.state.fullScreenMessage;
|
|
|
|
const self = this;
|
|
|
|
this._uielement.addCallback(function () {
|
|
|
|
self.update();
|
|
|
|
});
|
|
|
|
|
2020-06-27 03:06:51 +02:00
|
|
|
this.update();
|
|
|
|
|
2020-07-25 18:00:08 +02:00
|
|
|
if (window !== undefined) {
|
|
|
|
window.onhashchange = function () {
|
|
|
|
if (location.hash === "") {
|
|
|
|
// No more element: back to the map!
|
2020-07-31 01:45:54 +02:00
|
|
|
self._uielement.setData(undefined);
|
2020-07-25 18:00:08 +02:00
|
|
|
onClear();
|
|
|
|
}
|
2020-06-29 03:12:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-21 02:55:28 +02:00
|
|
|
Translations.t.general.returnToTheMap
|
2020-07-21 00:07:04 +02:00
|
|
|
.onClick(() => {
|
2020-07-31 01:45:54 +02:00
|
|
|
self._uielement.setData(undefined);
|
2020-07-21 00:07:04 +02:00
|
|
|
onClear();
|
|
|
|
})
|
2020-07-25 18:00:08 +02:00
|
|
|
.AttachTo("to-the-map");
|
2020-06-27 03:06:51 +02:00
|
|
|
|
2020-06-29 03:12:44 +02:00
|
|
|
|
2020-06-27 03:06:51 +02:00
|
|
|
}
|
|
|
|
|
2020-06-29 03:12:44 +02:00
|
|
|
|
2020-06-27 03:06:51 +02:00
|
|
|
update() {
|
|
|
|
const wrapper = document.getElementById("messagesboxmobilewrapper");
|
|
|
|
const gen = this._uielement.data;
|
|
|
|
if (gen === undefined) {
|
2020-06-29 03:12:44 +02:00
|
|
|
wrapper.classList.add("hidden")
|
|
|
|
if (location.hash !== "") {
|
|
|
|
location.hash = ""
|
|
|
|
}
|
2020-06-27 03:06:51 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-06-29 03:12:44 +02:00
|
|
|
location.hash = "#element"
|
2020-06-27 03:06:51 +02:00
|
|
|
wrapper.classList.remove("hidden");
|
|
|
|
|
2020-07-21 00:07:04 +02:00
|
|
|
gen
|
2020-06-27 03:06:51 +02:00
|
|
|
?.HideOnEmpty(true)
|
|
|
|
?.AttachTo("messagesboxmobile")
|
|
|
|
?.Activate();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|