diff --git a/umap/static/umap/js/modules/help.js b/umap/static/umap/js/modules/help.js index 40d16159..281138d4 100644 --- a/umap/static/umap/js/modules/help.js +++ b/umap/static/umap/js/modules/help.js @@ -1,5 +1,6 @@ import { DomEvent, DomUtil } from '../../vendors/leaflet/leaflet-src.esm.js' import { translate } from './i18n.js' +import * as Utils from './utils.js' const SHORTCUTS = { DRAW_MARKER: { @@ -163,9 +164,9 @@ const ENTRIES = { } export default class Help { - constructor(map) { - this.map = map - this.dialog = new U.Dialog() + constructor(umap) { + this.umap = umap + this.dialog = new U.Dialog({ className: 'dark', accept: false, cancel: false }) this.isMacOS = /mac/i.test( // eslint-disable-next-line compat/compat -- Fallback available. navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform @@ -199,7 +200,7 @@ export default class Help { innerHTML: ENTRIES[name], }) } - this.dialog.open({ template: container, className: 'dark', cancel: false, accept: false }) + this.dialog.open({ template: container }) } // Special dynamic case. Do we still think this dialog is useful? @@ -211,7 +212,7 @@ export default class Help { className: 'umap-help-entry', parent: container, }).appendChild(this._buildEditEntry()) - this.map.dialog.open({ content: container, className: 'dark' }) + this.dialog.open({ template: container }) } button(container, entries) { @@ -247,9 +248,11 @@ export default class Help { DomEvent.on(actionContainer, 'click', action.addHooks, action) DomEvent.on(actionContainer, 'click', this.dialog.close, this.dialog) } - for (const id in this.map.helpMenuActions) { - addAction(this.map.helpMenuActions[id]) + for (const action of Object.values(Help.MENU_ACTIONS)) { + addAction(action) } return container } } + +Help.MENU_ACTIONS = {} diff --git a/umap/static/umap/js/modules/rendering/map.js b/umap/static/umap/js/modules/rendering/map.js index ce91b416..92e10a8e 100644 --- a/umap/static/umap/js/modules/rendering/map.js +++ b/umap/static/umap/js/modules/rendering/map.js @@ -36,7 +36,6 @@ const ControlsMixin = { ], initControls: function () { - this.helpMenuActions = {} this._controls = {} if (this.umap.hasEditMode() && !this.options.noControl) { diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index fc7826e5..46f7cf50 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -523,7 +523,7 @@ export default class Umap extends ServerStored { this._leafletMap.importer.openFiles() break case 'h': - this.help.show('edit') + this.help.showGetStarted() break default: used = false @@ -1203,7 +1203,7 @@ export default class Umap extends ServerStored { this.editPanel.close() this.fullPanel.close() this.sync.stop() - this.closeInplaceToolbar() + this._leafletMap.closeInplaceToolbar() } askForReset(e) { diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 2b4602ac..58e59534 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -12,8 +12,8 @@ U.BaseAction = L.ToolbarAction.extend({ tooltip: this.options.tooltip, } L.ToolbarAction.prototype.initialize.call(this) - if (this.options.helpMenu && !this.map.helpMenuActions[this.options.className]) - this.map.helpMenuActions[this.options.className] = this + if (this.options.helpMenu && !U.Help.MENU_ACTIONS[this.options.className]) + U.Help.MENU_ACTIONS[this.options.className] = this }, }) @@ -675,7 +675,10 @@ U.TileLayerChooser = L.Control.extend({ const el = L.DomUtil.create('li', selectedClass, this._tilelayers_container) const img = L.DomUtil.create('img', '', el) const name = L.DomUtil.create('div', '', el) - img.src = U.Utils.template(tilelayer.options.url_template, this.map.options.demoTileInfos) + img.src = U.Utils.template( + tilelayer.options.url_template, + this.map.options.demoTileInfos + ) img.loading = 'lazy' name.textContent = tilelayer.options.name L.DomEvent.on(