2020-06-27 03:06:51 +02:00
|
|
|
import {UIElement} from "./UIElement";
|
2020-07-21 02:55:28 +02:00
|
|
|
import Translations from "./i18n/Translations";
|
2020-10-02 19:00:24 +02:00
|
|
|
import State from "../State";
|
2020-09-03 16:44:48 +02:00
|
|
|
import Combine from "./Base/Combine";
|
2020-06-27 03:06:51 +02:00
|
|
|
|
2020-07-21 02:55:28 +02:00
|
|
|
/**
|
|
|
|
* Handles the full screen popup on mobile
|
|
|
|
*/
|
2020-09-03 16:44:48 +02:00
|
|
|
export class FullScreenMessageBox extends UIElement {
|
2020-07-31 01:45:54 +02:00
|
|
|
|
2020-09-12 23:15:17 +02:00
|
|
|
private static readonly _toTheMap_height : string = "5em";
|
|
|
|
|
2020-09-03 16:44:48 +02:00
|
|
|
private _uielement: UIElement;
|
2020-09-12 23:15:17 +02:00
|
|
|
private readonly returnToTheMap: UIElement;
|
2020-06-27 03:06:51 +02:00
|
|
|
|
2020-07-31 01:45:54 +02:00
|
|
|
constructor(onClear: (() => void)) {
|
2020-10-01 20:36:42 +02:00
|
|
|
super(State.state.fullScreenMessage);
|
2020-07-31 01:45:54 +02:00
|
|
|
const self = this;
|
2020-09-12 23:15:17 +02:00
|
|
|
State.state.fullScreenMessage.addCallbackAndRun(uiElement => {
|
|
|
|
this._uielement = new Combine([State.state.fullScreenMessage.data]).SetStyle(
|
|
|
|
"display:block;"+
|
|
|
|
"padding: 1em;"+
|
2020-09-17 20:59:05 +02:00
|
|
|
"padding-bottom:6em;"+
|
2020-09-12 23:15:17 +02:00
|
|
|
`margin-bottom:${FullScreenMessageBox._toTheMap_height};`+
|
|
|
|
"box-sizing:border-box;"+
|
|
|
|
`height:calc(100vh - ${FullScreenMessageBox._toTheMap_height});`+
|
|
|
|
"overflow-y: auto;" +
|
2020-09-17 20:59:05 +02:00
|
|
|
"max-width:100vw;" +
|
|
|
|
"overflow-x:hidden;" +
|
2020-11-14 02:54:33 +01:00
|
|
|
"background:var(--background-color);" +
|
|
|
|
"color: var(--foreground-color);"
|
2020-09-12 23:15:17 +02:00
|
|
|
|
|
|
|
);
|
2020-07-31 01:45:54 +02:00
|
|
|
});
|
2020-09-12 23:15:17 +02:00
|
|
|
|
|
|
|
|
2020-09-03 16:44:48 +02:00
|
|
|
this.HideOnEmpty(true);
|
|
|
|
|
|
|
|
State.state.fullScreenMessage.addCallback(latestData => {
|
|
|
|
if (latestData === undefined) {
|
|
|
|
location.hash = "";
|
|
|
|
} else {
|
2020-09-12 23:15:17 +02:00
|
|
|
// The 'hash' makes sure a new piece of history is added. This makes the 'back-button' on android remove the popup
|
2020-09-03 16:44:48 +02:00
|
|
|
location.hash = "#element";
|
|
|
|
}
|
|
|
|
this.Update();
|
|
|
|
})
|
2020-06-27 03:06:51 +02:00
|
|
|
|
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-10-01 20:36:42 +02:00
|
|
|
console.log("Clearing full screen message");
|
|
|
|
State.state.fullScreenMessage.setData(undefined);
|
2020-07-25 18:00:08 +02:00
|
|
|
onClear();
|
|
|
|
}
|
2020-06-29 03:12:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-12 23:15:17 +02:00
|
|
|
this.returnToTheMap =
|
|
|
|
new Combine([Translations.t.general.returnToTheMap.Clone().SetStyle("font-size:xx-large")])
|
|
|
|
.SetStyle("background:#7ebc6f;" +
|
|
|
|
"position: fixed;" +
|
|
|
|
"z-index: 10000;" +
|
|
|
|
"bottom: 0;" +
|
|
|
|
"left: 0;" +
|
|
|
|
`height: ${FullScreenMessageBox._toTheMap_height};` +
|
|
|
|
"width: 100vw;" +
|
|
|
|
"color: white;" +
|
|
|
|
"font-weight: bold;" +
|
|
|
|
"pointer-events: all;" +
|
|
|
|
"cursor: pointer;" +
|
|
|
|
"padding-top: 1.2em;" +
|
|
|
|
"text-align: center;" +
|
|
|
|
"padding-bottom: 1.2em;" +
|
|
|
|
"box-sizing:border-box")
|
2020-07-21 00:07:04 +02:00
|
|
|
.onClick(() => {
|
2020-09-03 16:44:48 +02:00
|
|
|
console.log("Returning...")
|
|
|
|
State.state.fullScreenMessage.setData(undefined);
|
2020-07-21 00:07:04 +02:00
|
|
|
onClear();
|
2020-09-03 16:44:48 +02:00
|
|
|
self.Update();
|
|
|
|
});
|
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-09-03 16:44:48 +02:00
|
|
|
InnerRender(): string {
|
2020-09-12 23:15:17 +02:00
|
|
|
if (State.state.fullScreenMessage.data === undefined) {
|
2020-09-03 16:44:48 +02:00
|
|
|
return "";
|
2020-06-27 03:06:51 +02:00
|
|
|
}
|
2020-09-12 23:15:17 +02:00
|
|
|
return new Combine([this._uielement, this.returnToTheMap])
|
|
|
|
.Render();
|
2020-06-27 03:06:51 +02:00
|
|
|
}
|
|
|
|
|
2020-09-03 16:44:48 +02:00
|
|
|
|
2020-06-27 03:06:51 +02:00
|
|
|
}
|