From 423084e9ea186fb50d6788e7eece837caa37db69 Mon Sep 17 00:00:00 2001 From: 3st3ban3 Date: Sat, 14 Jan 2023 23:15:27 +0100 Subject: [PATCH] Interface option to hide caption menus --- umap/static/umap/js/umap.controls.js | 17 ++++++++----- umap/static/umap/js/umap.forms.js | 1 + umap/static/umap/js/umap.js | 38 ++++++++++++++++++---------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index eaed1b82..608f73a0 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -954,12 +954,14 @@ L.U.AttributionControl = L.Control.Attribution.extend({ if (this._map.options.shortCredit) { L.DomUtil.add('span', '', this._container, ' — ' + L.Util.toHTML(this._map.options.shortCredit)); } - var link = L.DomUtil.add('a', '', this._container, ' — ' + L._('About')); - L.DomEvent - .on(link, 'click', L.DomEvent.stop) - .on(link, 'click', this._map.displayCaption, this._map) - .on(link, 'dblclick', L.DomEvent.stop); - if (window.top === window.self) { + if (this._map.options.captionMenus) { + var link = L.DomUtil.add('a', '', this._container, ' — ' + L._('About')); + L.DomEvent + .on(link, 'click', L.DomEvent.stop) + .on(link, 'click', this._map.displayCaption, this._map) + .on(link, 'dblclick', L.DomEvent.stop); + } + if (window.top === window.self && this._map.options.captionMenus) { // We are not in iframe mode var home = L.DomUtil.add('a', '', this._container, ' — ' + L._('Home')); home.href = '/'; @@ -1150,7 +1152,8 @@ L.U.IframeExporter = L.Evented.extend({ embedControl: null, datalayersControl: true, onLoadPanel: 'none', - captionBar: false + captionBar: false, + captionMenus: true }, dimensions: { diff --git a/umap/static/umap/js/umap.forms.js b/umap/static/umap/js/umap.forms.js index 0067b4c6..b3a37733 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -759,6 +759,7 @@ L.U.FormBuilder = L.FormBuilder.extend({ onLoadPanel: {handler: 'onLoadPanel', label: L._('Do you want to display a panel on load?')}, displayPopupFooter: {handler: 'Switch', label: L._('Do you want to display popup footer?')}, captionBar: {handler: 'Switch', label: L._('Do you want to display a caption bar?')}, + captionMenus: {handler: 'Switch', label: L._('Do you want to display caption menus?')}, zoomTo: {handler: 'IntInput', placeholder: L._('Inherit'), helpEntries: 'zoomTo', label: L._('Default zoom level'), inheritable: true}, showLabel: {handler: 'LabelChoice', label: L._('Display label'), inheritable: true}, labelDirection: {handler: 'LabelDirection', label: L._('Label direction'), inheritable: true}, diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 6521c221..fd59c5ea 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -43,6 +43,7 @@ L.Map.mergeOptions({ ], moreControl: true, captionBar: false, + captionMenus: true, slideshow: {}, clickable: true, easing: true, @@ -89,6 +90,7 @@ L.U.Map.include({ L.Util.setBooleanFromQueryString(this.options, 'displayDataBrowserOnLoad'); L.Util.setBooleanFromQueryString(this.options, 'displayCaptionOnLoad'); L.Util.setBooleanFromQueryString(this.options, 'captionBar'); + L.Util.setBooleanFromQueryString(this.options, 'captionMenus'); for (var i = 0; i < this.HIDDABLE_CONTROLS.length; i++) { L.Util.setNullableBooleanFromQueryString(this.options, this.HIDDABLE_CONTROLS[i] + 'Control'); } @@ -628,7 +630,8 @@ L.U.Map.include({ 'queryString.miniMap', 'queryString.scaleControl', 'queryString.onLoadPanel', - 'queryString.captionBar' + 'queryString.captionBar', + 'queryString.captionMenus' ]; for (var i = 0; i < this.HIDDABLE_CONTROLS.length; i++) { UIFields.push('queryString.' + this.HIDDABLE_CONTROLS[i] + 'Control'); @@ -1067,6 +1070,7 @@ L.U.Map.include({ 'popupContentTemplate', 'zoomTo', 'captionBar', + 'captionMenus', 'slideshow', 'sortKey', 'labelKey', @@ -1232,10 +1236,14 @@ L.U.Map.include({ 'options.scaleControl', 'options.onLoadPanel', 'options.displayPopupFooter', - 'options.captionBar' + 'options.captionBar', + 'options.captionMenus' ]); builder = new L.U.FormBuilder(this, UIFields, { - callback: this.renderControls, + callback: function() { + this.renderControls(); + this.initCaptionBar(); + }, callbackContext: this }); var controlsOptions = L.DomUtil.createFieldset(container, L._('User interface options')); @@ -1450,17 +1458,19 @@ L.U.Map.include({ name = L.DomUtil.create('h3', '', container); L.DomEvent.disableClickPropagation(container); this.permissions.addOwnerLink('span', container); - var about = L.DomUtil.add('a', 'umap-about-link', container, ' — ' + L._('About')); - about.href = '#'; - L.DomEvent.on(about, 'click', this.displayCaption, this); - var browser = L.DomUtil.add('a', 'umap-open-browser-link', container, ' | ' + L._('Browse data')); - browser.href = '#'; - L.DomEvent.on(browser, 'click', L.DomEvent.stop) - .on(browser, 'click', this.openBrowser, this); - var filter = L.DomUtil.add('a', 'umap-open-filter-link', container, ' | ' + L._('Filter data')); - filter.href = '#'; - L.DomEvent.on(filter, 'click', L.DomEvent.stop) - .on(filter, 'click', this.openFilter, this); + if (this.options.captionMenus) { + var about = L.DomUtil.add('a', 'umap-about-link', container, ' — ' + L._('About')); + about.href = '#'; + L.DomEvent.on(about, 'click', this.displayCaption, this); + var browser = L.DomUtil.add('a', 'umap-open-browser-link', container, ' | ' + L._('Browse data')); + browser.href = '#'; + L.DomEvent.on(browser, 'click', L.DomEvent.stop) + .on(browser, 'click', this.openBrowser, this); + var filter = L.DomUtil.add('a', 'umap-open-filter-link', container, ' | ' + L._('Filter data')); + filter.href = '#'; + L.DomEvent.on(filter, 'click', L.DomEvent.stop) + .on(filter, 'click', this.openFilter, this); + } var setName = function () { name.textContent = this.getDisplayName(); };