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({
|
||||
initialize: function (feature) {
|
||||
this.feature = feature
|
||||
this.container = DomUtil.create('div', 'umap-popup')
|
||||
this.format()
|
||||
BasePopup.prototype.initialize.call(this, {}, feature)
|
||||
this.setContent(this.container)
|
||||
BasePopup.prototype.initialize.call(this, {}, feature.ui)
|
||||
this.getContentFromTemplate()
|
||||
},
|
||||
|
||||
format: async function () {
|
||||
getContentFromTemplate: async function () {
|
||||
const container = DomUtil.create('div', 'umap-popup')
|
||||
const name = this.feature.getOption('popupTemplate')
|
||||
this.content = await loadTemplate(name, this.feature, this.container)
|
||||
const elements = this.container.querySelectorAll('img,iframe')
|
||||
this.content = await loadTemplate(name, this.feature, container)
|
||||
const elements = container.querySelectorAll('img,iframe')
|
||||
for (const element of elements) {
|
||||
this.onElementLoaded(element)
|
||||
}
|
||||
if (!elements.length && this.container.textContent.replace('\n', '') === '') {
|
||||
this.container.innerHTML = ''
|
||||
DomUtil.add('h3', '', this.container, this.feature.getDisplayName())
|
||||
if (!elements.length && container.textContent.replace('\n', '') === '') {
|
||||
container.innerHTML = ''
|
||||
DomUtil.add('h3', '', container, this.feature.getDisplayName())
|
||||
}
|
||||
this.setContent(container)
|
||||
},
|
||||
|
||||
onElementLoaded: function (el) {
|
||||
|
|
Loading…
Reference in a new issue