Merge pull request #1764 from umap-project/browser-open-signature
chore: change Panel.open signature
This commit is contained in:
commit
099a34f56a
11 changed files with 21 additions and 25 deletions
|
@ -149,7 +149,7 @@ export default class Browser {
|
|||
formContainer.appendChild(builder.build())
|
||||
|
||||
this.map.panel.open({
|
||||
data: { html: container },
|
||||
content: container,
|
||||
className: 'umap-browser',
|
||||
})
|
||||
|
||||
|
|
|
@ -14,26 +14,22 @@ export class Panel {
|
|||
DomEvent.on(this.container, 'MozMousePixelScroll', DomEvent.stopPropagation)
|
||||
}
|
||||
|
||||
open(e) {
|
||||
open({ content, className, actions = [] } = {}) {
|
||||
this.container.className = `with-transition panel ${this.classname} ${this.mode}`
|
||||
this.container.innerHTML = ''
|
||||
const actionsContainer = DomUtil.create('ul', 'toolbox', this.container)
|
||||
const body = DomUtil.create('div', 'body', this.container)
|
||||
if (e.data.html.nodeType && e.data.html.nodeType === 1)
|
||||
body.appendChild(e.data.html)
|
||||
else body.innerHTML = e.data.html
|
||||
body.appendChild(content)
|
||||
const closeLink = DomUtil.create('li', 'umap-close-link', actionsContainer)
|
||||
DomUtil.add('i', 'icon icon-16 icon-close', closeLink)
|
||||
closeLink.title = translate('Close')
|
||||
const resizeLink = DomUtil.create('li', 'umap-resize-link', actionsContainer)
|
||||
DomUtil.add('i', 'icon icon-16 icon-resize', resizeLink)
|
||||
resizeLink.title = translate('Toggle size')
|
||||
if (e.actions) {
|
||||
for (let i = 0; i < e.actions.length; i++) {
|
||||
actionsContainer.appendChild(e.actions[i])
|
||||
for (let action of actions) {
|
||||
actionsContainer.appendChild(action)
|
||||
}
|
||||
}
|
||||
if (e.className) DomUtil.addClass(body, e.className)
|
||||
if (className) DomUtil.addClass(body, className)
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
DomUtil.addClass(this.container, 'on')
|
||||
resolve()
|
||||
|
|
|
@ -709,7 +709,7 @@ const ControlsMixin = {
|
|||
})
|
||||
container.appendChild(builder.build())
|
||||
|
||||
this.panel.open({ data: { html: container } })
|
||||
this.panel.open({ content: container })
|
||||
},
|
||||
|
||||
displayCaption: function () {
|
||||
|
@ -789,7 +789,7 @@ const ControlsMixin = {
|
|||
`,
|
||||
urls
|
||||
)
|
||||
this.panel.open({ data: { html: container } })
|
||||
this.panel.open({ content: container })
|
||||
},
|
||||
|
||||
renderEditToolbar: function () {
|
||||
|
@ -976,7 +976,7 @@ const ControlsMixin = {
|
|||
this
|
||||
)
|
||||
|
||||
this.editPanel.open({ data: { html: container } })
|
||||
this.editPanel.open({ content: container })
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1051,7 +1051,7 @@ U.TileLayerChooser = L.Control.extend({
|
|||
this._tilelayers_container = L.DomUtil.create('ul', '', container)
|
||||
this.buildList(options)
|
||||
this.map.editPanel.open({
|
||||
data: { html: container },
|
||||
content: container,
|
||||
className: options.className,
|
||||
})
|
||||
},
|
||||
|
@ -1159,7 +1159,7 @@ U.Locate = L.Control.Locate.extend({
|
|||
this._map = this.map
|
||||
L.Control.Locate.prototype._activate.call(this)
|
||||
this._map = null
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
U.Search = L.PhotonSearch.extend({
|
||||
|
@ -1298,7 +1298,7 @@ U.SearchControl = L.Control.extend({
|
|||
this.map.fire('dataload', { id: id })
|
||||
})
|
||||
this.search.resultsContainer = resultsContainer
|
||||
this.map.panel.open({ data: { html: container } }).then(input.focus)
|
||||
this.map.panel.open({ content: container }).then(input.focus)
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ U.FeatureMixin = {
|
|||
this.appendEditFieldsets(container)
|
||||
const advancedActions = L.DomUtil.createFieldset(container, L._('Advanced actions'))
|
||||
this.getAdvancedEditActions(advancedActions)
|
||||
const onLoad = this.map.editPanel.open({ data: { html: container } })
|
||||
const onLoad = this.map.editPanel.open({ content: container })
|
||||
onLoad.then(() => {
|
||||
builder.helpers['properties.name'].input.focus()
|
||||
})
|
||||
|
|
|
@ -107,7 +107,7 @@ U.Importer = L.Class.extend({
|
|||
|
||||
open: function () {
|
||||
if (!this.container) this.build()
|
||||
const onLoad = this.map.editPanel.open({ data: { html: this.container } })
|
||||
const onLoad = this.map.editPanel.open({ content: this.container })
|
||||
onLoad.then(() => {
|
||||
this.fileInput.value = null
|
||||
this.layerInput.innerHTML = ''
|
||||
|
|
|
@ -1532,7 +1532,7 @@ U.Map = L.Map.extend({
|
|||
]
|
||||
const creditsBuilder = new U.FormBuilder(this, creditsFields)
|
||||
credits.appendChild(creditsBuilder.build())
|
||||
this.editPanel.open({ data: { html: container } })
|
||||
this.editPanel.open({ content: container })
|
||||
},
|
||||
|
||||
edit: function () {
|
||||
|
@ -1550,7 +1550,7 @@ U.Map = L.Map.extend({
|
|||
this._editSlideshow(container)
|
||||
this._advancedActions(container)
|
||||
|
||||
this.editPanel.open({ data: { html: container }, className: 'dark' })
|
||||
this.editPanel.open({ content: container, className: 'dark' })
|
||||
},
|
||||
|
||||
enableEdit: function () {
|
||||
|
|
|
@ -1385,7 +1385,7 @@ U.DataLayer = L.Evented.extend({
|
|||
)
|
||||
}
|
||||
this.map.editPanel.open({
|
||||
data: { html: container },
|
||||
content: container,
|
||||
actions: [U.Browser.backButton(this.map)],
|
||||
})
|
||||
},
|
||||
|
|
|
@ -126,7 +126,7 @@ U.MapPermissions = L.Class.extend({
|
|||
this.map.eachDataLayer((datalayer) => {
|
||||
datalayer.permissions.edit(container)
|
||||
})
|
||||
this.map.editPanel.open({ data: { html: container }, className: 'dark' })
|
||||
this.map.editPanel.open({ content: container, className: 'dark' })
|
||||
},
|
||||
|
||||
attach: async function () {
|
||||
|
|
|
@ -56,7 +56,7 @@ U.Popup.Panel = U.Popup.extend({
|
|||
|
||||
onAdd: function (map) {
|
||||
map.panel.open({
|
||||
data: { html: this._content },
|
||||
content: this._content,
|
||||
actions: [U.Browser.backButton(map)],
|
||||
})
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ U.Share = L.Class.extend({
|
|||
|
||||
open: function () {
|
||||
if (!this.container) this.build()
|
||||
this.map.panel.open({ data: { html: this.container } })
|
||||
this.map.panel.open({ content: this.container })
|
||||
},
|
||||
|
||||
format: function (mode) {
|
||||
|
|
|
@ -110,7 +110,7 @@ U.TableEditor = L.Class.extend({
|
|||
}
|
||||
L.DomEvent.on(addButton, 'click', addProperty, this)
|
||||
this.datalayer.map.fullPanel.open({
|
||||
data: { html: this.table },
|
||||
content: this.table,
|
||||
className: 'umap-table-editor',
|
||||
actions: [addButton],
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue