diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 486cea80..58357fa6 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1462,7 +1462,7 @@ L.U.IframeExporter = L.Evented.extend({ return this.map }, - buildUrl: function () { + buildUrl: function (options) { const datalayers = [] if (this.options.viewCurrentFeature && this.map.currentFeature) { this.queryString.feature = this.map.currentFeature.getSlug() @@ -1478,14 +1478,16 @@ L.U.IframeExporter = L.Evented.extend({ delete this.queryString.datalayers } const currentView = this.options.currentView ? window.location.hash : '' - return `${this.baseUrl}?${L.Util.buildQueryString(this.queryString)}${currentView}` + const queryString = L.extend({}, this.queryString, options) + return `${this.baseUrl}?${L.Util.buildQueryString(queryString)}${currentView}` }, build: function () { const iframeUrl = this.buildUrl() let code = `` if (this.options.includeFullScreenLink) { - code += `

${L._('See full screen')}

` + const fullUrl = this.buildUrl({ scrollWheelZoom: true }) + code += `

${L._('See full screen')}

` } return code }, diff --git a/umap/static/umap/test/Controls.js b/umap/static/umap/test/Controls.js index 32725a42..d6014232 100644 --- a/umap/static/umap/test/Controls.js +++ b/umap/static/umap/test/Controls.js @@ -1,4 +1,4 @@ -describe('L.Utorage.Controls', function () { +describe('L.U.Controls', function () { before(function () { this.server = sinon.fakeServer.create() this.server.respondWith( @@ -48,4 +48,27 @@ describe('L.Utorage.Controls', function () { assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 3) }) }) + + describe('#exportPanel()', function () { + it('should be opened at datalayer button click', function () { + let button = qs('.leaflet-control-embed a') + assert.ok(button) + happen.click(button) + assert.ok(qs('#umap-ui-container .umap-share')) + }) + it('should update iframe link', function () { + let textarea = qs('.umap-share-iframe') + assert.ok(textarea) + console.log(textarea.textContent) + assert.include(textarea.textContent, 'src="') + assert.include(textarea.textContent, 'href="') + // We should ave both, once for iframe link, once for full screen + assert.include(textarea.textContent, 'scrollWheelZoom=true') + assert.include(textarea.textContent, 'scrollWheelZoom=false') + assert.notInclude(textarea.textContent, 'datalayers=62') + let switcher = qs('label[title="Keep current visible layers"]') + happen.click(switcher) + assert.include(textarea.textContent, 'datalayers=62') + }) + }) })