feat: make popup panel expanded by default and add a small panel

cf https://forum.openstreetmap.fr/t/umap-2-3-changement-de-gestion-des-pop-up/23680
This commit is contained in:
Yohan Boniface 2024-05-16 12:15:16 +02:00
parent a1084e0c7b
commit 63f8943f3d
4 changed files with 11 additions and 3 deletions

View file

@ -14,7 +14,8 @@ export class Panel {
DomEvent.on(this.container, 'MozMousePixelScroll', DomEvent.stopPropagation)
}
open({ content, className, actions = [] } = {}) {
open({ content, className, actions = [], mode = null } = {}) {
if (mode) this.mode = mode
this.container.className = `with-transition panel ${this.classname} ${this.mode}`
this.container.innerHTML = ''
const actionsContainer = DomUtil.create('ul', 'toolbox', this.container)

View file

@ -341,6 +341,7 @@ export const SCHEMA = {
['Default', translate('Popup')],
['Large', translate('Popup (large)')],
['Panel', translate('Side panel')],
['SmallPanel', translate('Small side panel')],
],
default: 'Default',
},

View file

@ -218,7 +218,6 @@ U.Map = L.Map.extend({
} else if (this.options.onLoadPanel === 'datalayers') {
this.openBrowser('layers')
} else if (this.options.onLoadPanel === 'datafilters') {
this.panel.mode = 'expanded'
this.openBrowser('filters')
} else if (this.options.onLoadPanel === 'caption') {
this.panel.mode = 'condensed'

View file

@ -52,12 +52,14 @@ U.Popup.Large = U.Popup.extend({
U.Popup.Panel = U.Popup.extend({
options: {
zoomAnimation: false,
mode: 'expanded',
},
onAdd: function (map) {
map.panel.open({
content: this._content,
actions: [U.Browser.backButton(map)],
mode: this.options.mode,
})
// fire events as in base class Popup.js:onAdd
@ -90,7 +92,12 @@ U.Popup.Panel = U.Popup.extend({
_animateZoom: function () {},
})
U.Popup.SimplePanel = U.Popup.Panel // Retrocompat.
U.Popup.SmallPanel = U.Popup.Panel.extend({
options: {
zoomAnimation: false,
mode: 'condensed',
},
})
/* Content templates */
U.PopupTemplate = {}