Fullscreen link should reflect the user choices

But the scollWheelZoom that is forced to true.

fix #390
This commit is contained in:
Yohan Boniface 2023-06-24 11:23:38 +02:00
parent 001b79795a
commit 05a029f261
2 changed files with 30 additions and 4 deletions

View file

@ -1462,7 +1462,7 @@ L.U.IframeExporter = L.Evented.extend({
return this.map return this.map
}, },
buildUrl: function () { buildUrl: function (options) {
const datalayers = [] const datalayers = []
if (this.options.viewCurrentFeature && this.map.currentFeature) { if (this.options.viewCurrentFeature && this.map.currentFeature) {
this.queryString.feature = this.map.currentFeature.getSlug() this.queryString.feature = this.map.currentFeature.getSlug()
@ -1478,14 +1478,17 @@ L.U.IframeExporter = L.Evented.extend({
delete this.queryString.datalayers delete this.queryString.datalayers
} }
const currentView = this.options.currentView ? window.location.hash : '' 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 () { build: function () {
const iframeUrl = this.buildUrl() const iframeUrl = this.buildUrl()
let fullUrl
let code = `<iframe width="${this.dimensions.width}" height="${this.dimensions.height}" frameborder="0" allowfullscreen allow="geolocation" src="${iframeUrl}"></iframe>` let code = `<iframe width="${this.dimensions.width}" height="${this.dimensions.height}" frameborder="0" allowfullscreen allow="geolocation" src="${iframeUrl}"></iframe>`
if (this.options.includeFullScreenLink) { if (this.options.includeFullScreenLink) {
code += `<p><a href="${this.baseUrl}">${L._('See full screen')}</a></p>` fullUrl = this.buildUrl({ scrollWheelZoom: true })
code += `<p><a href="${fullUrl}">${L._('See full screen')}</a></p>`
} }
return code return code
}, },

View file

@ -1,4 +1,4 @@
describe('L.Utorage.Controls', function () { describe('L.U.Controls', function () {
before(function () { before(function () {
this.server = sinon.fakeServer.create() this.server = sinon.fakeServer.create()
this.server.respondWith( this.server.respondWith(
@ -48,4 +48,27 @@ describe('L.Utorage.Controls', function () {
assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 3) 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')
})
})
}) })