mirror of
https://github.com/umap-project/umap.git
synced 2025-05-01 12:32:23 +02:00
fixup: allow aynchronous popups
This commit is contained in:
parent
7670989798
commit
8a929d2352
1 changed files with 10 additions and 10 deletions
|
@ -21,23 +21,23 @@ export default function loadPopup(name) {
|
||||||
const Popup = BasePopup.extend({
|
const Popup = BasePopup.extend({
|
||||||
initialize: function (feature) {
|
initialize: function (feature) {
|
||||||
this.feature = feature
|
this.feature = feature
|
||||||
this.container = DomUtil.create('div', 'umap-popup')
|
BasePopup.prototype.initialize.call(this, {}, feature.ui)
|
||||||
this.format()
|
this.getContentFromTemplate()
|
||||||
BasePopup.prototype.initialize.call(this, {}, feature)
|
|
||||||
this.setContent(this.container)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
format: async function () {
|
getContentFromTemplate: async function () {
|
||||||
|
const container = DomUtil.create('div', 'umap-popup')
|
||||||
const name = this.feature.getOption('popupTemplate')
|
const name = this.feature.getOption('popupTemplate')
|
||||||
this.content = await loadTemplate(name, this.feature, this.container)
|
this.content = await loadTemplate(name, this.feature, container)
|
||||||
const elements = this.container.querySelectorAll('img,iframe')
|
const elements = container.querySelectorAll('img,iframe')
|
||||||
for (const element of elements) {
|
for (const element of elements) {
|
||||||
this.onElementLoaded(element)
|
this.onElementLoaded(element)
|
||||||
}
|
}
|
||||||
if (!elements.length && this.container.textContent.replace('\n', '') === '') {
|
if (!elements.length && container.textContent.replace('\n', '') === '') {
|
||||||
this.container.innerHTML = ''
|
container.innerHTML = ''
|
||||||
DomUtil.add('h3', '', this.container, this.feature.getDisplayName())
|
DomUtil.add('h3', '', container, this.feature.getDisplayName())
|
||||||
}
|
}
|
||||||
|
this.setContent(container)
|
||||||
},
|
},
|
||||||
|
|
||||||
onElementLoaded: function (el) {
|
onElementLoaded: function (el) {
|
||||||
|
|
Loading…
Reference in a new issue