Merge master
This commit is contained in:
commit
62dd8d3f0a
1 changed files with 25 additions and 22 deletions
|
@ -20,12 +20,14 @@ class TitleElement extends UIElement {
|
|||
this._selectedFeature = selectedFeature;
|
||||
this._allElementsStorage = allElementsStorage;
|
||||
this.ListenTo(Locale.language);
|
||||
this.ListenTo(this._selectedFeature)
|
||||
this.dumbMode = false;
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
|
||||
const defaultTitle = Translations.WT(this._layoutToUse.data?.title)?.txt ?? "MapComplete"
|
||||
console.log("Default title: ", defaultTitle)
|
||||
const feature = this._selectedFeature.data;
|
||||
|
||||
if (feature === undefined) {
|
||||
|
@ -35,12 +37,12 @@ class TitleElement extends UIElement {
|
|||
|
||||
const layout = this._layoutToUse.data;
|
||||
const properties = this._selectedFeature.data.properties;
|
||||
|
||||
for (const layer of layout.layers) {
|
||||
if (layer.title === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (layer.source.osmTags.matchesProperties(properties)) {
|
||||
|
||||
const title = new TagRenderingAnswer(
|
||||
this._allElementsStorage.getEventSourceFor(feature),
|
||||
layer.title
|
||||
|
@ -58,15 +60,16 @@ export default class TitleHandler {
|
|||
selectedFeature: UIEventSource<any>,
|
||||
allElementsStorage: ElementStorage) {
|
||||
|
||||
new TitleElement(layoutToUse, selectedFeature, allElementsStorage)
|
||||
.addCallbackAndRun(contents => {
|
||||
|
||||
console.log("Titlehandler inited")
|
||||
selectedFeature.addCallbackAndRun(_ => {
|
||||
const title = new TitleElement(layoutToUse, selectedFeature, allElementsStorage)
|
||||
const d = document.createElement('div');
|
||||
const contents = title.InnerRender()
|
||||
d.innerHTML = contents;
|
||||
console.log("Setting title to ", d.innerText, contents)
|
||||
// We pass everything into a div to strip out images etc...
|
||||
document.title = (d.textContent || d.innerText);
|
||||
|
||||
});
|
||||
})
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue