Merge pull request #1171 from umap-project/fullscreen-link-querystring

Fullscreen link should reflect the user choices
This commit is contained in:
Yohan Boniface 2023-06-26 08:10:07 +02:00 committed by GitHub
commit 4c5fb43720
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 4 deletions

View file

@ -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 = `<iframe width="${this.dimensions.width}" height="${this.dimensions.height}" frameborder="0" allowfullscreen allow="geolocation" src="${iframeUrl}"></iframe>`
if (this.options.includeFullScreenLink) {
code += `<p><a href="${this.baseUrl}">${L._('See full screen')}</a></p>`
const fullUrl = this.buildUrl({ scrollWheelZoom: true })
code += `<p><a href="${fullUrl}">${L._('See full screen')}</a></p>`
}
return code
},

View file

@ -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')
})
})
})