diff --git a/umap/static/umap/js/modules/help.js b/umap/static/umap/js/modules/help.js index 7587a138..824a0749 100644 --- a/umap/static/umap/js/modules/help.js +++ b/umap/static/umap/js/modules/help.js @@ -190,26 +190,29 @@ export default class Help { show(entries) { const container = DomUtil.add('div') DomUtil.createTitle(container, translate('Help')) - // Special dynamic case. Do we still think this dialog is usefull ? - if (entries[0] === 'edit') { + for (const name of entries) { DomUtil.element({ tagName: 'div', className: 'umap-help-entry', parent: container, - }).appendChild(this._buildEditEntry()) - } else { - for (const name of entries) { - DomUtil.element({ - tagName: 'div', - className: 'umap-help-entry', - parent: container, - innerHTML: ENTRIES[name], - }) - } + innerHTML: ENTRIES[name], + }) } this.map.dialog.open({ content: container, className: 'dark' }) } + // Special dynamic case. Do we still think this dialog is usefull ? + showGetStarted() { + const container = DomUtil.add('div') + DomUtil.createTitle(container, translate('Where do we go from here?')) + DomUtil.element({ + tagName: 'div', + className: 'umap-help-entry', + parent: container, + }).appendChild(this._buildEditEntry()) + this.map.dialog.open({ content: container, className: 'dark' }) + } + button(container, entries, classname) { const button = DomUtil.createButton( classname || 'umap-help-button', @@ -217,15 +220,18 @@ export default class Help { translate('Help') ) entries = typeof entries === 'string' ? [entries] : entries - DomEvent.on(button, 'click', DomEvent.stop).on(button, 'click', () => + DomEvent.on(button, 'click', DomEvent.stop).on(button, 'click', () => { this.show(entries) - ) + }) return button } - link(container, entries) { - const button = this.button(container, entries, 'umap-help-link') + getStartedLink(container) { + const button = DomUtil.createButton('umap-help-link', container, translate('Help')) button.textContent = translate('Help') + DomEvent.on(button, 'click', DomEvent.stop).on(button, 'click', () => { + this.showGetStarted() + }) return button } @@ -237,16 +243,14 @@ export default class Help { _buildEditEntry() { const container = DomUtil.create('div', '') - const title = DomUtil.create('h4', '', container) const actionsContainer = DomUtil.create('ul', 'umap-edit-actions', container) const addAction = (action) => { const actionContainer = DomUtil.add('li', '', actionsContainer) - DomUtil.add('i', action.options.className, actionContainer), - DomUtil.add('span', '', actionContainer, action.options.tooltip) + DomUtil.add('i', action.options.className, actionContainer) + DomUtil.add('span', '', actionContainer, action.options.tooltip) DomEvent.on(actionContainer, 'click', action.addHooks, action) DomEvent.on(actionContainer, 'click', this.map.dialog.close, this.map.dialog) } - title.textContent = translate('Where do we go from here?') for (const id in this.map.helpMenuActions) { addAction(this.map.helpMenuActions[id]) } diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 9b481139..5b8fa700 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -751,7 +751,7 @@ const ControlsMixin = { this.options.user.url ) } - this.help.link(rightContainer, 'edit') + this.help.getStartedLink(rightContainer) const controlEditCancel = L.DomUtil.createButton( 'leaflet-control-edit-cancel', rightContainer,