forked from MapComplete/MapComplete
Full, interactive i18n (still some quests to enable it though)
This commit is contained in:
parent
fd6f77c98e
commit
0f2dff8f41
15 changed files with 205 additions and 90 deletions
67
UI/FullScreenMessageBoxHandler.ts
Normal file
67
UI/FullScreenMessageBoxHandler.ts
Normal file
|
@ -0,0 +1,67 @@
|
|||
import {UIEventSource} from "./UIEventSource";
|
||||
import {UIElement} from "./UIElement";
|
||||
import {VariableUiElement} from "./Base/VariableUIElement";
|
||||
import Translations from "./i18n/Translations";
|
||||
|
||||
/**
|
||||
* Handles the full screen popup on mobile
|
||||
*/
|
||||
export class FullScreenMessageBoxHandler {
|
||||
|
||||
private _uielement: UIEventSource<UIElement>;
|
||||
|
||||
constructor(uielement: UIEventSource<UIElement>,
|
||||
onClear: (() => void)) {
|
||||
this._uielement = uielement;
|
||||
this.listenTo(uielement);
|
||||
this.update();
|
||||
|
||||
window.onhashchange = function () {
|
||||
if (location.hash === "") {
|
||||
// No more element: back to the map!
|
||||
uielement.setData(undefined);
|
||||
onClear();
|
||||
}
|
||||
}
|
||||
|
||||
Translations.t.general.returnToTheMap
|
||||
.onClick(() => {
|
||||
console.log("Clicked 'return to the map'")
|
||||
uielement.setData(undefined);
|
||||
onClear();
|
||||
})
|
||||
.AttachTo("to-the-map-h2");
|
||||
|
||||
|
||||
}
|
||||
|
||||
listenTo(uiEventSource: UIEventSource<any>) {
|
||||
const self = this;
|
||||
uiEventSource.addCallback(function () {
|
||||
self.update();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
update() {
|
||||
const wrapper = document.getElementById("messagesboxmobilewrapper");
|
||||
const gen = this._uielement.data;
|
||||
if (gen === undefined) {
|
||||
wrapper.classList.add("hidden")
|
||||
if (location.hash !== "") {
|
||||
location.hash = ""
|
||||
}
|
||||
return;
|
||||
}
|
||||
location.hash = "#element"
|
||||
wrapper.classList.remove("hidden");
|
||||
|
||||
gen
|
||||
?.HideOnEmpty(true)
|
||||
?.AttachTo("messagesboxmobile")
|
||||
?.Activate();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue