From 63f8943f3d6394f776f71fe51b0c93d7772a1f38 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 16 May 2024 12:15:16 +0200 Subject: [PATCH] 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 --- umap/static/umap/js/modules/panel.js | 3 ++- umap/static/umap/js/modules/schema.js | 1 + umap/static/umap/js/umap.js | 1 - umap/static/umap/js/umap.popup.js | 9 ++++++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/modules/panel.js b/umap/static/umap/js/modules/panel.js index 6bbc5262..ab7e6857 100644 --- a/umap/static/umap/js/modules/panel.js +++ b/umap/static/umap/js/modules/panel.js @@ -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) diff --git a/umap/static/umap/js/modules/schema.js b/umap/static/umap/js/modules/schema.js index 3db6f726..2ec3078a 100644 --- a/umap/static/umap/js/modules/schema.js +++ b/umap/static/umap/js/modules/schema.js @@ -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', }, diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 8bc9ac21..52c99558 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -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' diff --git a/umap/static/umap/js/umap.popup.js b/umap/static/umap/js/umap.popup.js index b81576a3..403acc19 100644 --- a/umap/static/umap/js/umap.popup.js +++ b/umap/static/umap/js/umap.popup.js @@ -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 = {}