diff --git a/umap/static/umap/base.css b/umap/static/umap/base.css index 78b7c342..b07dd8f1 100644 --- a/umap/static/umap/base.css +++ b/umap/static/umap/base.css @@ -162,14 +162,16 @@ textarea { padding: 7px; } select { + border: 1px solid #222; width: 100%; height: 28px; line-height: 28px; - color: #efefef; - border: 1px solid #222; - background-color: #393F3F; margin-top: 5px; } +.dark select { + color: #efefef; + background-color: #393F3F; +} select[multiple="multiple"] { height: auto; } @@ -225,7 +227,8 @@ button.flat, font-size: 10px; border-radius: 0 2px; } -.content .helptext { +.content .helptext, +#umap-ui-container .help-text { background-color: #eee; color: #000; } @@ -294,16 +297,19 @@ input[type="file"] + .error { text-align: left; display: block; cursor: pointer; - background-color: #232729; + background-color: #eee; height: 30px; line-height: 30px; - color: #fff; margin: 0; font-family: fira_sans; font-weight: normal; font-size: 1.2em; padding: 0 5px; } +.dark .fieldset.toggle .legend { + background-color: #232729; + color: #fff; +} .fieldset.toggle .legend:before { background-repeat: no-repeat; text-indent: 24px; @@ -311,11 +317,14 @@ input[type="file"] + .error { width: 24px; line-height: 24px; display: inline-block; - background-image: url('./img/16-white.svg'); + background-image: url('./img/16.svg'); vertical-align: bottom; content: " "; background-position: -144px -76px; } +.dark .fieldset.toggle .legend:before { + background-image: url('./img/16-white.svg'); +} .fieldset.toggle.on .legend:before { background-position: -144px -51px; } @@ -401,6 +410,7 @@ input.switch:checked ~ label:after { .umap-multiplechoice.by5 { grid-template-columns: 1fr 1fr 1fr; } +.button-bar.by4, .umap-multiplechoice.by4 { grid-template-columns: 1fr 1fr 1fr 1fr; } @@ -448,7 +458,8 @@ input.switch:checked ~ label:after { } .umap-field-iconUrl .action-button, .inheritable .define, -.inheritable .undefine { +.inheritable .undefine, +.copy-button { float: right; width: initial; min-height: 18px; diff --git a/umap/static/umap/img/16.svg b/umap/static/umap/img/16.svg index a7f38acd..3ed21c10 100644 --- a/umap/static/umap/img/16.svg +++ b/umap/static/umap/img/16.svg @@ -1,4 +1,4 @@ - + @@ -168,5 +168,7 @@ + + diff --git a/umap/static/umap/img/source/16.svg b/umap/static/umap/img/source/16.svg index f63086c6..ed2042bf 100644 --- a/umap/static/umap/img/source/16.svg +++ b/umap/static/umap/img/source/16.svg @@ -2,7 +2,7 @@ + @@ -852,5 +859,17 @@ id="path2378" style="stroke-width:0.264583" /> + + diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 157f32bf..bcdd0be4 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1086,12 +1086,77 @@ L.U.Map.include({ const container = L.DomUtil.create('div', 'umap-share') const title = L.DomUtil.create('h3', '', container) title.textContent = L._('Share, download and embed this map') + if (this.options.shortUrl) { + L.DomUtil.createButton( + 'button copy-button', + container, + L._('copy'), + () => navigator.clipboard.writeText(this.options.shortUrl), + this + ) + L.DomUtil.add('h4', '', container, L._('Short URL')) + const shortUrlLabel = L.DomUtil.create('label', '', container) + shortUrlLabel.textContent = L._('Share this link to view the map') + const shortUrl = L.DomUtil.create('input', 'umap-short-url', container) + shortUrl.type = 'text' + shortUrl.value = this.options.shortUrl + L.DomUtil.create('hr', '', container) + } + + L.DomUtil.add('h4', '', container, L._('Download data')) + const downloadLabel = L.DomUtil.create('label', '', container) + downloadLabel.textContent = L._('Choose the format of the data to export') + const exportCaveat = L.DomUtil.add( + 'small', + 'help-text', + container, + L._('Only visible features will be downloaded.') + ) + console.log(this.EXPORT_TYPES) + const typeInput = L.DomUtil.create( + 'div', + `button-bar by${Object.keys(this.EXPORT_TYPES).length}`, + container + ) + let option + for (const key in this.EXPORT_TYPES) { + if (this.EXPORT_TYPES.hasOwnProperty(key)) { + L.DomUtil.createButton( + 'button', + typeInput, + this.EXPORT_TYPES[key].name || key, + () => this.download(key), + this + ) + } + } + L.DomUtil.create('hr', '', container) + + L.DomUtil.add('h4', '', container, L._('Backup data')) + const backupLabel = L.DomUtil.create('label', '', container) + backupLabel.textContent = L._('Download all data and settings of the map') + const downloadUrl = L.Util.template(this.options.urls.map_download, { + map_id: this.options.umap_id, + }) + const link = L.DomUtil.createLink( + 'button', + container, + L._('Download full backup'), + downloadUrl + ) + let name = this.options.name || 'data' + name = name.replace(/[^a-z0-9]/gi, '_').toLowerCase() + link.setAttribute('download', `${name}.umap`) + L.DomUtil.create('hr', '', container) const embedTitle = L.DomUtil.add('h4', '', container, L._('Embed the map')) const iframe = L.DomUtil.create('textarea', 'umap-share-iframe', container) const urlTitle = L.DomUtil.add('h4', '', container, L._('Direct link')) + const shortUrlLabel = L.DomUtil.create('label', '', container) + shortUrlLabel.textContent = L._( + 'Share this link to open a customized map view' + ) const exportUrl = L.DomUtil.create('input', 'umap-share-url', container) - let option exportUrl.type = 'text' const UIFields = [ ['dimensions.width', { handler: 'Input', label: L._('width') }], @@ -1132,54 +1197,12 @@ L.U.Map.include({ const builder = new L.U.FormBuilder(iframeExporter, UIFields, { callback: buildIframeCode, }) - const iframeOptions = L.DomUtil.createFieldset(container, L._('Export options')) + const iframeOptions = L.DomUtil.createFieldset( + container, + L._('Embed and link options') + ) iframeOptions.appendChild(builder.build()) - if (this.options.shortUrl) { - L.DomUtil.create('hr', '', container) - L.DomUtil.add('h4', '', container, L._('Short URL')) - const shortUrl = L.DomUtil.create('input', 'umap-short-url', container) - shortUrl.type = 'text' - shortUrl.value = this.options.shortUrl - } - L.DomUtil.create('hr', '', container) - L.DomUtil.add('h4', '', container, L._('Backup data')) - const downloadUrl = L.Util.template(this.options.urls.map_download, { - map_id: this.options.umap_id, - }) - const link = L.DomUtil.createLink( - 'button', - container, - L._('Download full data'), - downloadUrl - ) - let name = this.options.name || 'data' - name = name.replace(/[^a-z0-9]/gi, '_').toLowerCase() - link.setAttribute('download', `${name}.umap`) - L.DomUtil.create('hr', '', container) - L.DomUtil.add('h4', '', container, L._('Download data')) - const typeInput = L.DomUtil.create('select', '', container) - typeInput.name = 'format' - const exportCaveat = L.DomUtil.add( - 'small', - 'help-text', - container, - L._('Only visible features will be downloaded.') - ) - for (const key in this.EXPORT_TYPES) { - if (this.EXPORT_TYPES.hasOwnProperty(key)) { - option = L.DomUtil.create('option', '', typeInput) - option.value = key - option.textContent = this.EXPORT_TYPES[key].name || key - if (this.EXPORT_TYPES[key].selected) option.selected = true - } - } - L.DomUtil.createButton( - 'button', - container, - L._('Download data'), - () => this.download(typeInput.value), - this - ) + this.ui.openPanel({ data: { html: container } }) }, })