Apply Lebab for template conversions

This commit is contained in:
David Larlet 2023-05-30 14:53:53 -04:00
parent 4f5674073f
commit 0a75998f11
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD
14 changed files with 85 additions and 99 deletions

View file

@ -61,6 +61,7 @@ pretty: ## Apply PrettierJS to all JS files (or specified `filepath`)
lebab: ## Convert JS `filepath` to modern syntax with Lebab, then prettify lebab: ## Convert JS `filepath` to modern syntax with Lebab, then prettify
./node_modules/lebab/bin/index.js --replace ${filepath} --transform arrow,arrow-return ./node_modules/lebab/bin/index.js --replace ${filepath} --transform arrow,arrow-return
./node_modules/lebab/bin/index.js --replace ${filepath} --transform let ./node_modules/lebab/bin/index.js --replace ${filepath} --transform let
./node_modules/lebab/bin/index.js --replace ${filepath} --transform template
$(MAKE) pretty filepath=${filepath} $(MAKE) pretty filepath=${filepath}
lebab-all: $(jsdir)* ## Convert all JS files to modern syntax with Lebab + prettify lebab-all: $(jsdir)* ## Convert all JS files to modern syntax with Lebab + prettify

View file

@ -61,10 +61,10 @@ L.U.AutoComplete = L.Class.extend({
resizeContainer: function () { resizeContainer: function () {
const l = this.getLeft(this.input) const l = this.getLeft(this.input)
const t = this.getTop(this.input) + this.input.offsetHeight const t = this.getTop(this.input) + this.input.offsetHeight
this.container.style.left = l + 'px' this.container.style.left = `${l}px`
this.container.style.top = t + 'px' this.container.style.top = `${t}px`
const width = this.options.width ? this.options.width : this.input.offsetWidth - 2 const width = this.options.width ? this.options.width : this.input.offsetWidth - 2
this.container.style.width = width + 'px' this.container.style.width = `${width}px`
}, },
onKeyDown: function (e) { onKeyDown: function (e) {
@ -164,7 +164,7 @@ L.U.AutoComplete = L.Class.extend({
this.clear() this.clear()
return return
} }
if (val + '' === this.CACHE + '') return if (`${val}` === `${this.CACHE}`) return
else this.CACHE = val else this.CACHE = val
this._do_search( this._do_search(
val, val,
@ -275,7 +275,7 @@ L.U.AutoComplete.Ajax = L.U.AutoComplete.extend({
_do_search: function (val, callback, context) { _do_search: function (val, callback, context) {
val = val.toLowerCase() val = val.toLowerCase()
this.xhr.get('/agnocomplete/AutocompleteUser/?q=' + encodeURIComponent(val), { this.xhr.get(`/agnocomplete/AutocompleteUser/?q=${encodeURIComponent(val)}`, {
callback: callback, callback: callback,
context: context || this, context: context || this,
}) })

View file

@ -15,7 +15,7 @@ L.U.ImportAction = L.U.BaseAction.extend({
options: { options: {
helpMenu: true, helpMenu: true,
className: 'upload-data dark', className: 'upload-data dark',
tooltip: L._('Import data') + ' (Ctrl+I)', tooltip: `${L._('Import data')} (Ctrl+I)`,
}, },
addHooks: function () { addHooks: function () {
@ -320,7 +320,7 @@ L.U.EditControl = L.Control.extend({
), ),
edit = L.DomUtil.create('a', '', container) edit = L.DomUtil.create('a', '', container)
edit.href = '#' edit.href = '#'
edit.title = L._('Enable editing') + ' (Ctrl+E)' edit.title = `${L._('Enable editing')} (Ctrl+E)`
L.DomEvent.addListener(edit, 'click', L.DomEvent.stop).addListener( L.DomEvent.addListener(edit, 'click', L.DomEvent.stop).addListener(
edit, edit,
@ -542,7 +542,7 @@ L.U.DataLayersControl = L.Control.extend({
datalayer.options.name datalayer.options.name
) )
datalayerLi.id = 'browse_data_toggle_' + L.stamp(datalayer) datalayerLi.id = `browse_data_toggle_${L.stamp(datalayer)}`
L.DomUtil.classIf(datalayerLi, 'off', !datalayer.isVisible()) L.DomUtil.classIf(datalayerLi, 'off', !datalayer.isVisible())
title.textContent = datalayer.options.name title.textContent = datalayer.options.name
@ -626,11 +626,11 @@ L.U.DataLayer.include({
}, },
getHidableElements: function () { getHidableElements: function () {
return document.querySelectorAll('.' + this.getHidableClass()) return document.querySelectorAll(`.${this.getHidableClass()}`)
}, },
getHidableClass: function () { getHidableClass: function () {
return 'show_with_datalayer_' + L.stamp(this) return `show_with_datalayer_${L.stamp(this)}`
}, },
propagateRemote: function () { propagateRemote: function () {
@ -689,7 +689,7 @@ L.U.Map.include({
filter.value = this.options.filter || '' filter.value = this.options.filter || ''
const addFeature = (feature) => { const addFeature = (feature) => {
const feature_li = L.DomUtil.create('li', feature.getClassName() + ' feature'), const feature_li = L.DomUtil.create('li', `${feature.getClassName()} feature`),
zoom_to = L.DomUtil.create('i', 'feature-zoom_to', feature_li), zoom_to = L.DomUtil.create('i', 'feature-zoom_to', feature_li),
edit = L.DomUtil.create('i', 'show-on-edit feature-edit', feature_li), edit = L.DomUtil.create('i', 'show-on-edit feature-edit', feature_li),
color = L.DomUtil.create('i', 'feature-color', feature_li), color = L.DomUtil.create('i', 'feature-color', feature_li),
@ -702,7 +702,7 @@ L.U.Map.include({
title.textContent = feature.getDisplayName() || '—' title.textContent = feature.getDisplayName() || '—'
color.style.backgroundColor = feature.getOption('color') color.style.backgroundColor = feature.getOption('color')
if (symbol) { if (symbol) {
color.style.backgroundImage = 'url(' + symbol + ')' color.style.backgroundImage = `url(${symbol})`
} }
L.DomEvent.on( L.DomEvent.on(
zoom_to, zoom_to,
@ -740,7 +740,7 @@ L.U.Map.include({
featuresContainer featuresContainer
), ),
headline = L.DomUtil.create('h5', '', container) headline = L.DomUtil.create('h5', '', container)
container.id = 'browse_data_datalayer_' + datalayer.umap_id container.id = `browse_data_datalayer_${datalayer.umap_id}`
datalayer.renderToolbox(headline) datalayer.renderToolbox(headline)
L.DomUtil.add('span', '', headline, datalayer.options.name) L.DomUtil.add('span', '', headline, datalayer.options.name)
const ul = L.DomUtil.create('ul', '', container) const ul = L.DomUtil.create('ul', '', container)
@ -1009,18 +1009,18 @@ L.U.AttributionControl = L.Control.Attribution.extend({
'span', 'span',
'', '',
this._container, this._container,
' — ' + L.Util.toHTML(this._map.options.shortCredit) `${L.Util.toHTML(this._map.options.shortCredit)}`
) )
} }
if (this._map.options.captionMenus) { if (this._map.options.captionMenus) {
const link = L.DomUtil.add('a', '', this._container, ' — ' + L._('About')) const link = L.DomUtil.add('a', '', this._container, `${L._('About')}`)
L.DomEvent.on(link, 'click', L.DomEvent.stop) L.DomEvent.on(link, 'click', L.DomEvent.stop)
.on(link, 'click', this._map.displayCaption, this._map) .on(link, 'click', this._map.displayCaption, this._map)
.on(link, 'dblclick', L.DomEvent.stop) .on(link, 'dblclick', L.DomEvent.stop)
} }
if (window.top === window.self && this._map.options.captionMenus) { if (window.top === window.self && this._map.options.captionMenus) {
// We are not in iframe mode // We are not in iframe mode
const home = L.DomUtil.add('a', '', this._container, ' — ' + L._('Home')) const home = L.DomUtil.add('a', '', this._container, `${L._('Home')}`)
home.href = '/' home.href = '/'
} }
}, },
@ -1035,7 +1035,7 @@ L.U.StarControl = L.Control.extend({
const status = map.options.starred ? ' starred' : '' const status = map.options.starred ? ' starred' : ''
const container = L.DomUtil.create( const container = L.DomUtil.create(
'div', 'div',
'leaflet-control-star umap-control' + status `leaflet-control-star umap-control${status}`
), ),
link = L.DomUtil.create('a', '', container) link = L.DomUtil.create('a', '', container)
link.href = '#' link.href = '#'
@ -1254,21 +1254,14 @@ 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 return `${this.baseUrl}?${L.Util.buildQueryString(this.queryString)}${currentView}`
}, },
build: function () { build: function () {
const iframeUrl = this.buildUrl() const iframeUrl = this.buildUrl()
const code = const code = `<iframe width="${this.dimensions.width}" height="${this.dimensions.height}" frameborder="0" allowfullscreen allow="geolocation" src="${iframeUrl}"></iframe>`
'<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>' code += `<p><a href="${this.baseUrl}">${L._('See full screen')}</a></p>`
} }
return code return code
}, },

View file

@ -70,7 +70,7 @@ L.Util.toHTML = (r) => {
r = r.replace(/^\*\* (.*)/gm, '<ul><ul><li>$1</li></ul></ul>') r = r.replace(/^\*\* (.*)/gm, '<ul><ul><li>$1</li></ul></ul>')
r = r.replace(/^\* (.*)/gm, '<ul><li>$1</li></ul>') r = r.replace(/^\* (.*)/gm, '<ul><li>$1</li></ul>')
for (ii = 0; ii < 3; ii++) for (ii = 0; ii < 3; ii++)
r = r.replace(new RegExp('</ul>' + newline + '<ul>', 'g'), newline) r = r.replace(new RegExp(`</ul>${newline}<ul>`, 'g'), newline)
// links // links
r = r.replace(/(\[\[http)/g, '[[h_t_t_p') // Escape for avoiding clash between [[http://xxx]] and http://xxx r = r.replace(/(\[\[http)/g, '[[h_t_t_p') // Escape for avoiding clash between [[http://xxx]] and http://xxx
@ -107,7 +107,7 @@ L.Util.toHTML = (r) => {
r = r.replace(/(h_t_t_p)/g, 'http') r = r.replace(/(h_t_t_p)/g, 'http')
// Preserver line breaks // Preserver line breaks
if (newline) r = r.replace(new RegExp(newline + '(?=[^]+)', 'g'), '<br>' + newline) if (newline) r = r.replace(new RegExp(`${newline}(?=[^]+)`, 'g'), `<br>${newline}`)
return r return r
} }
@ -205,12 +205,12 @@ L.Util.flattenCoordinates = (coords) => {
L.Util.buildQueryString = (params) => { L.Util.buildQueryString = (params) => {
const query_string = [] const query_string = []
for (const key in params) { for (const key in params) {
query_string.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key])) query_string.push(`${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`)
} }
return query_string.join('&') return query_string.join('&')
} }
L.Util.getBaseUrl = () => '//' + window.location.host + window.location.pathname L.Util.getBaseUrl = () => `//${window.location.host}${window.location.pathname}`
L.DomUtil.add = (tagName, className, container, content) => { L.DomUtil.add = (tagName, className, container, content) => {
const el = L.DomUtil.create(tagName, className, container) const el = L.DomUtil.create(tagName, className, container)
@ -415,9 +415,9 @@ L.U.Help = L.Class.extend({
L.DomUtil.add('h3', '', container, 'GeojSON') L.DomUtil.add('h3', '', container, 'GeojSON')
L.DomUtil.add('p', '', container, L._('All properties are imported.')) L.DomUtil.add('p', '', container, L._('All properties are imported.'))
L.DomUtil.add('h3', '', container, 'GPX') L.DomUtil.add('h3', '', container, 'GPX')
L.DomUtil.add('p', '', container, L._('Properties imported:') + 'name, desc') L.DomUtil.add('p', '', container, `${L._('Properties imported:')}name, desc`)
L.DomUtil.add('h3', '', container, 'KML') L.DomUtil.add('h3', '', container, 'KML')
L.DomUtil.add('p', '', container, L._('Properties imported:') + 'name, description') L.DomUtil.add('p', '', container, `${L._('Properties imported:')}name, description`)
L.DomUtil.add('h3', '', container, 'CSV') L.DomUtil.add('h3', '', container, 'CSV')
L.DomUtil.add( L.DomUtil.add(
'p', 'p',
@ -493,9 +493,9 @@ L.U.Help = L.Class.extend({
return container return container
}, },
formatURL: formatURL: `${L._(
L._('Supported variables that will be dynamically replaced') + 'Supported variables that will be dynamically replaced'
': {bbox}, {lat}, {lng}, {zoom}, {east}, {north}..., {left}, {top}...', )}: {bbox}, {lat}, {lng}, {zoom}, {east}, {north}..., {left}, {top}...`,
formatIconSymbol: L._( formatIconSymbol: L._(
'Symbol can be either a unicode character or an URL. You can use feature properties as variables: ex.: with "http://myserver.org/images/{name}.png", the {name} variable will be replaced by the "name" value of each marker.' 'Symbol can be either a unicode character or an URL. You can use feature properties as variables: ex.: with "http://myserver.org/images/{name}.png", the {name} variable will be replaced by the "name" value of each marker.'
), ),

View file

@ -50,12 +50,9 @@ L.U.FeatureMixin = {
getPermalink: function () { getPermalink: function () {
const slug = this.getSlug() const slug = this.getSlug()
if (slug) if (slug)
return ( return `${L.Util.getBaseUrl()}?${L.Util.buildQueryString({ feature: slug })}${
L.Util.getBaseUrl() +
'?' +
L.Util.buildQueryString({ feature: slug }) +
window.location.hash window.location.hash
) }`
}, },
view: function (e) { view: function (e) {
@ -105,7 +102,7 @@ L.U.FeatureMixin = {
if (L.Util.indexOf(['name', 'description'], property) !== -1) { if (L.Util.indexOf(['name', 'description'], property) !== -1) {
continue continue
} }
properties.push(['properties.' + property, { label: property }]) properties.push([`properties.${property}`, { label: property }])
} }
// We always want name and description for now (properties management to come) // We always want name and description for now (properties management to come)
properties.unshift('properties.description') properties.unshift('properties.description')
@ -570,7 +567,7 @@ L.U.Marker = L.Marker.extend({
_getIconUrl: function (name) { _getIconUrl: function (name) {
if (typeof name === 'undefined') name = 'icon' if (typeof name === 'undefined') name = 'icon'
return this.getOption(name + 'Url') return this.getOption(`${name}Url`)
}, },
getIconClass: function () { getIconClass: function () {

View file

@ -12,7 +12,7 @@ L.FormBuilder.Element.include({
className += className +=
this.get(true) === undefined ? ' inheritable undefined' : ' inheritable ' this.get(true) === undefined ? ' inheritable undefined' : ' inheritable '
} }
className += ' umap-field-' + this.name className += ` umap-field-${this.name}`
this.wrapper = L.DomUtil.create('div', className, this.form) this.wrapper = L.DomUtil.create('div', className, this.form)
this.header = L.DomUtil.create('div', 'header', this.wrapper) this.header = L.DomUtil.create('div', 'header', this.wrapper)
if (this.options.inheritable) { if (this.options.inheritable) {
@ -567,12 +567,12 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
addIconPreview: function (pictogram) { addIconPreview: function (pictogram) {
const baseClass = 'umap-icon-choice', const baseClass = 'umap-icon-choice',
value = pictogram.src, value = pictogram.src,
className = value === this.value() ? baseClass + ' selected' : baseClass, className = value === this.value() ? `${baseClass} selected` : baseClass,
container = L.DomUtil.create('div', className, this.pictogramsContainer), container = L.DomUtil.create('div', className, this.pictogramsContainer),
img = L.DomUtil.create('img', '', container) img = L.DomUtil.create('img', '', container)
img.src = value img.src = value
if (pictogram.name && pictogram.attribution) { if (pictogram.name && pictogram.attribution) {
img.title = pictogram.name + ' — © ' + pictogram.attribution img.title = `${pictogram.name} — © ${pictogram.attribution}`
} }
L.DomEvent.on( L.DomEvent.on(
container, container,
@ -668,7 +668,7 @@ L.FormBuilder.Switch = L.FormBuilder.CheckBox.extend({
this.label = L.DomUtil.create('label', '', this.input.parentNode) this.label = L.DomUtil.create('label', '', this.input.parentNode)
else this.input.parentNode.appendChild(this.label) else this.input.parentNode.appendChild(this.label)
L.DomUtil.addClass(this.input.parentNode, 'with-switch') L.DomUtil.addClass(this.input.parentNode, 'with-switch')
const id = (this.builder.options.id || Date.now()) + '.' + this.name const id = `${this.builder.options.id || Date.now()}.${this.name}`
this.label.setAttribute('for', id) this.label.setAttribute('for', id)
L.DomUtil.addClass(this.input, 'switch') L.DomUtil.addClass(this.input, 'switch')
this.input.id = id this.input.id = id
@ -686,11 +686,9 @@ L.FormBuilder.MultiChoice = L.FormBuilder.Element.extend({
fetch: function () { fetch: function () {
let value = (this.backup = this.toHTML()) let value = (this.backup = this.toHTML())
if (!this.container.querySelector('input[type="radio"][value="' + value + '"]')) if (!this.container.querySelector(`input[type="radio"][value="${value}"]`))
value = this.default value = this.default
this.container.querySelector( this.container.querySelector(`input[type="radio"][value="${value}"]`).checked = true
'input[type="radio"][value="' + value + '"]'
).checked = true
}, },
value: function () { value: function () {
@ -706,7 +704,7 @@ L.FormBuilder.MultiChoice = L.FormBuilder.Element.extend({
const choices = this.getChoices() const choices = this.getChoices()
this.container = L.DomUtil.create( this.container = L.DomUtil.create(
'div', 'div',
this.className + ' by' + choices.length, `${this.className} by${choices.length}`,
this.parentNode this.parentNode
) )
for (let i = 0; i < choices.length; i++) { for (let i = 0; i < choices.length; i++) {
@ -721,7 +719,7 @@ L.FormBuilder.MultiChoice = L.FormBuilder.Element.extend({
input.type = 'radio' input.type = 'radio'
input.name = this.name input.name = this.name
input.value = value input.value = value
const id = Date.now() + '.' + this.name + '.' + counter const id = `${Date.now()}.${this.name}.${counter}`
label.setAttribute('for', id) label.setAttribute('for', id)
input.id = id input.id = id
L.DomEvent.on(input, 'change', this.sync, this) L.DomEvent.on(input, 'change', this.sync, this)

View file

@ -18,7 +18,7 @@ L.U.Icon = L.DivIcon.extend({
let url let url
if (this.feature && this.feature._getIconUrl(name)) if (this.feature && this.feature._getIconUrl(name))
url = this.feature._getIconUrl(name) url = this.feature._getIconUrl(name)
else url = this.options[name + 'Url'] else url = this.options[`${name}Url`]
return this.formatUrl(url, this.feature) return this.formatUrl(url, this.feature)
}, },
@ -147,13 +147,9 @@ L.U.Icon.Ball = L.U.Icon.Default.extend({
if (L.Browser.ielt9) { if (L.Browser.ielt9) {
background = color background = color
} else if (L.Browser.webkit) { } else if (L.Browser.webkit) {
background = background = `-webkit-gradient( radial, 6 38%, 0, 6 38%, 8, from(white), to(${color}) )`
'-webkit-gradient( radial, 6 38%, 0, 6 38%, 8, from(white), to(' + color + ') )'
} else { } else {
background = background = `radial-gradient(circle at 6px 38% , white -4px, ${color} 8px) repeat scroll 0 0 transparent`
'radial-gradient(circle at 6px 38% , white -4px, ' +
color +
' 8px) repeat scroll 0 0 transparent'
} }
this.elements.container.style.background = background this.elements.container.style.background = background
}, },

View file

@ -108,7 +108,7 @@ L.U.Map.include({
for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) { for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) {
L.Util.setNullableBooleanFromQueryString( L.Util.setNullableBooleanFromQueryString(
this.options, this.options,
this.HIDDABLE_CONTROLS[i] + 'Control' `${this.HIDDABLE_CONTROLS[i]}Control`
) )
} }
this.datalayersOnLoad = L.Util.queryString('datalayers') this.datalayersOnLoad = L.Util.queryString('datalayers')
@ -359,7 +359,7 @@ L.U.Map.include({
let name, status, control let name, status, control
for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) { for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) {
name = this.HIDDABLE_CONTROLS[i] name = this.HIDDABLE_CONTROLS[i]
status = this.options[name + 'Control'] status = this.options[`${name}Control`]
if (status === false) continue if (status === false) continue
control = this._controls[name] control = this._controls[name]
control.addTo(this) control.addTo(this)
@ -582,7 +582,7 @@ L.U.Map.include({
} catch (e) { } catch (e) {
this.removeLayer(tilelayer) this.removeLayer(tilelayer)
this.ui.alert({ this.ui.alert({
content: L._('Error in the tilelayer URL') + ': ' + tilelayer._url, content: `${L._('Error in the tilelayer URL')}: ${tilelayer._url}`,
level: 'error', level: 'error',
}) })
// Users can put tilelayer URLs by hand, and if they add wrong {variable}, // Users can put tilelayer URLs by hand, and if they add wrong {variable},
@ -619,7 +619,7 @@ L.U.Map.include({
this.removeLayer(overlay) this.removeLayer(overlay)
console.error(e) console.error(e)
this.ui.alert({ this.ui.alert({
content: L._('Error in the overlay URL') + ': ' + overlay._url, content: `${L._('Error in the overlay URL')}: ${overlay._url}`,
level: 'error', level: 'error',
}) })
} }
@ -685,13 +685,13 @@ L.U.Map.include({
createDataLayer: function (datalayer) { createDataLayer: function (datalayer) {
datalayer = datalayer || { datalayer = datalayer || {
name: L._('Layer') + ' ' + (this.datalayers_index.length + 1), name: `${L._('Layer')} ${this.datalayers_index.length + 1}`,
} }
return new L.U.DataLayer(this, datalayer) return new L.U.DataLayer(this, datalayer)
}, },
getDefaultOption: function (option) { getDefaultOption: function (option) {
return this.options['default_' + option] return this.options[`default_${option}`]
}, },
getOption: function (option) { getOption: function (option) {
@ -764,7 +764,7 @@ L.U.Map.include({
'queryString.captionMenus', 'queryString.captionMenus',
] ]
for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) { for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) {
UIFields.push('queryString.' + this.HIDDABLE_CONTROLS[i] + 'Control') UIFields.push(`queryString.${this.HIDDABLE_CONTROLS[i]}Control`)
} }
const iframeExporter = new L.U.IframeExporter(this) const iframeExporter = new L.U.IframeExporter(this)
const buildIframeCode = () => { const buildIframeCode = () => {
@ -1104,7 +1104,7 @@ L.U.Map.include({
} }
}) })
datalayer.renderToolbox(headline) datalayer.renderToolbox(headline)
L.DomUtil.add('span', '', headline, datalayer.options.name + ' ') L.DomUtil.add('span', '', headline, `${datalayer.options.name} `)
}) })
const creditsContainer = L.DomUtil.create('div', 'credits-container', container), const creditsContainer = L.DomUtil.create('div', 'credits-container', container),
credits = L.DomUtil.createFieldset(creditsContainer, L._('Credits')) credits = L.DomUtil.createFieldset(creditsContainer, L._('Credits'))
@ -1122,7 +1122,7 @@ L.U.Map.include({
'p', 'p',
'', '',
credits, credits,
L._('Map user content has been published under licence') + ' ' `${L._('Map user content has been published under licence')} `
), ),
link = L.DomUtil.add('a', '', licence, this.options.licence.name) link = L.DomUtil.add('a', '', licence, this.options.licence.name)
link.href = this.options.licence.url link.href = this.options.licence.url
@ -1135,7 +1135,7 @@ L.U.Map.include({
const tilelayerCredit = L.DomUtil.create('p', '', credits), const tilelayerCredit = L.DomUtil.create('p', '', credits),
name = L.DomUtil.create('strong', '', tilelayerCredit), name = L.DomUtil.create('strong', '', tilelayerCredit),
attribution = L.DomUtil.create('span', '', tilelayerCredit) attribution = L.DomUtil.create('span', '', tilelayerCredit)
name.textContent = this.selected_tilelayer.options.name + ' ' name.textContent = `${this.selected_tilelayer.options.name} `
attribution.innerHTML = this.selected_tilelayer.getAttribution() attribution.innerHTML = this.selected_tilelayer.getAttribution()
L.DomUtil.create('hr', '', credits) L.DomUtil.create('hr', '', credits)
const umapCredit = L.DomUtil.create('p', '', credits), const umapCredit = L.DomUtil.create('p', '', credits),
@ -1440,7 +1440,7 @@ L.U.Map.include({
_editControls: function (container) { _editControls: function (container) {
let UIFields = [] let UIFields = []
for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) { for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) {
UIFields.push('options.' + this.HIDDABLE_CONTROLS[i] + 'Control') UIFields.push(`options.${this.HIDDABLE_CONTROLS[i]}Control`)
} }
UIFields = UIFields.concat([ UIFields = UIFields.concat([
'options.moreControl', 'options.moreControl',
@ -1598,7 +1598,7 @@ L.U.Map.include({
'options.tilelayer.url_template', 'options.tilelayer.url_template',
{ {
handler: 'BlurInput', handler: 'BlurInput',
helpText: L._('Supported scheme') + ': http://{s}.domain.com/{z}/{x}/{y}.png', helpText: `${L._('Supported scheme')}: http://{s}.domain.com/{z}/{x}/{y}.png`,
placeholder: 'url', placeholder: 'url',
}, },
], ],
@ -1636,7 +1636,7 @@ L.U.Map.include({
'options.overlay.url_template', 'options.overlay.url_template',
{ {
handler: 'BlurInput', handler: 'BlurInput',
helpText: L._('Supported scheme') + ': http://{s}.domain.com/{z}/{x}/{y}.png', helpText: `${L._('Supported scheme')}: http://{s}.domain.com/{z}/{x}/{y}.png`,
placeholder: 'url', placeholder: 'url',
helpText: L._('Background overlay url'), helpText: L._('Background overlay url'),
}, },
@ -1894,7 +1894,7 @@ L.U.Map.include({
'a', 'a',
'umap-about-link', 'umap-about-link',
container, container,
' — ' + L._('About') `${L._('About')}`
) )
about.href = '#' about.href = '#'
L.DomEvent.on(about, 'click', this.displayCaption, this) L.DomEvent.on(about, 'click', this.displayCaption, this)
@ -1902,7 +1902,7 @@ L.U.Map.include({
'a', 'a',
'umap-open-browser-link', 'umap-open-browser-link',
container, container,
' | ' + L._('Browse data') ` | ${L._('Browse data')}`
) )
browser.href = '#' browser.href = '#'
L.DomEvent.on(browser, 'click', L.DomEvent.stop).on( L.DomEvent.on(browser, 'click', L.DomEvent.stop).on(
@ -1916,7 +1916,7 @@ L.U.Map.include({
'a', 'a',
'umap-open-filter-link', 'umap-open-filter-link',
container, container,
' | ' + L._('Select data') ` | ${L._('Select data')}`
) )
filter.href = '#' filter.href = '#'
L.DomEvent.on(filter, 'click', L.DomEvent.stop).on( L.DomEvent.on(filter, 'click', L.DomEvent.stop).on(
@ -1943,7 +1943,7 @@ L.U.Map.include({
'umap-main-edit-toolbox with-transition dark', 'umap-main-edit-toolbox with-transition dark',
this._controlContainer this._controlContainer
), ),
title = L.DomUtil.add('h3', '', container, L._('Editing') + '&nbsp;'), title = L.DomUtil.add('h3', '', container, `${L._('Editing')}&nbsp;`),
name = L.DomUtil.create('a', 'umap-click-to-edit', title), name = L.DomUtil.create('a', 'umap-click-to-edit', title),
setName = function () { setName = function () {
name.textContent = this.getDisplayName() name.textContent = this.getDisplayName()
@ -1954,7 +1954,7 @@ L.U.Map.include({
this.help.button(title, 'edit') this.help.button(title, 'edit')
const save = L.DomUtil.create('a', 'leaflet-control-edit-save button', container) const save = L.DomUtil.create('a', 'leaflet-control-edit-save button', container)
save.href = '#' save.href = '#'
save.title = L._('Save current edits') + ' (Ctrl+S)' save.title = `${L._('Save current edits')} (Ctrl+S)`
save.textContent = L._('Save') save.textContent = L._('Save')
const cancel = L.DomUtil.create( const cancel = L.DomUtil.create(
'a', 'a',
@ -2093,27 +2093,27 @@ L.U.Map.include({
if (this.editEnabled) { if (this.editEnabled) {
if (!this.isDirty) { if (!this.isDirty) {
items.push({ items.push({
text: L._('Stop editing') + ' (Ctrl+E)', text: `${L._('Stop editing')} (Ctrl+E)`,
callback: this.disableEdit, callback: this.disableEdit,
}) })
} }
if (this.options.enableMarkerDraw) { if (this.options.enableMarkerDraw) {
items.push({ items.push({
text: L._('Draw a marker') + ' (Ctrl+M)', text: `${L._('Draw a marker')} (Ctrl+M)`,
callback: this.startMarker, callback: this.startMarker,
context: this, context: this,
}) })
} }
if (this.options.enablePolylineDraw) { if (this.options.enablePolylineDraw) {
items.push({ items.push({
text: L._('Draw a polygon') + ' (Ctrl+P)', text: `${L._('Draw a polygon')} (Ctrl+P)`,
callback: this.startPolygon, callback: this.startPolygon,
context: this, context: this,
}) })
} }
if (this.options.enablePolygonDraw) { if (this.options.enablePolygonDraw) {
items.push({ items.push({
text: L._('Draw a line') + ' (Ctrl+L)', text: `${L._('Draw a line')} (Ctrl+L)`,
callback: this.startPolyline, callback: this.startPolyline,
context: this, context: this,
}) })
@ -2127,7 +2127,7 @@ L.U.Map.include({
}) })
} else { } else {
items.push({ items.push({
text: L._('Start editing') + ' (Ctrl+E)', text: `${L._('Start editing')} (Ctrl+E)`,
callback: this.enableEdit, callback: this.enableEdit,
}) })
} }

View file

@ -188,7 +188,7 @@ L.U.DataLayer = L.Evented.extend({
this._propertiesIndex = [] this._propertiesIndex = []
this.parentPane = this.map.getPane('overlayPane') this.parentPane = this.map.getPane('overlayPane')
this.pane = this.map.createPane('datalayer' + L.stamp(this), this.parentPane) this.pane = this.map.createPane(`datalayer${L.stamp(this)}`, this.parentPane)
this.pane.dataset.id = L.stamp(this) this.pane.dataset.id = L.stamp(this)
this.renderer = L.svg({ pane: this.pane }) this.renderer = L.svg({ pane: this.pane })
@ -441,7 +441,7 @@ L.U.DataLayer = L.Evented.extend({
}) })
// No browser cache for owners/editors. // No browser cache for owners/editors.
if (this.map.options.allowEdit) url = url + '?' + Date.now() if (this.map.options.allowEdit) url = `${url}?${Date.now()}`
return url return url
}, },
@ -559,7 +559,7 @@ L.U.DataLayer = L.Evented.extend({
const gj = JSON.parse(c) const gj = JSON.parse(c)
callback(gj) callback(gj)
} catch (err) { } catch (err) {
this.map.ui.alert({ content: 'Invalid JSON file: ' + err }) this.map.ui.alert({ content: `Invalid JSON file: ${err}` })
return return
} }
} }
@ -974,8 +974,9 @@ L.U.DataLayer = L.Evented.extend({
buildVersionsFieldset: function (container) { buildVersionsFieldset: function (container) {
const appendVersion = function (data) { const appendVersion = function (data) {
const date = new Date(parseInt(data.at, 10)) const date = new Date(parseInt(data.at, 10))
const content = const content = `${date.toLocaleDateString(L.locale)} (${
date.toLocaleDateString(L.locale) + ' (' + parseInt(data.size) / 1000 + 'Kb)' parseInt(data.size) / 1000
}Kb)`
const el = L.DomUtil.create('div', 'umap-datalayer-version', versionsContainer) const el = L.DomUtil.create('div', 'umap-datalayer-version', versionsContainer)
const a = L.DomUtil.create('a', '', el) const a = L.DomUtil.create('a', '', el)
L.DomUtil.add('span', '', el, content) L.DomUtil.add('span', '', el, content)

View file

@ -182,7 +182,7 @@ L.U.MapPermissions = L.Class.extend({
element, element,
'umap-map-owner', 'umap-map-owner',
container, container,
' ' + L._('by') + ' ' ` ${L._('by')} `
), ),
owner = L.DomUtil.create('a') owner = L.DomUtil.create('a')
owner.href = this.options.owner.url owner.href = this.options.owner.url

View file

@ -176,7 +176,7 @@ L.U.PopupTemplate.BaseWithTitle = L.U.PopupTemplate.Default.extend({
L.U.PopupTemplate.Table = L.U.PopupTemplate.BaseWithTitle.extend({ L.U.PopupTemplate.Table = L.U.PopupTemplate.BaseWithTitle.extend({
formatRow: function (key, value) { formatRow: function (key, value) {
if (value.indexOf('http') === 0) { if (value.indexOf('http') === 0) {
value = '<a href="' + value + '" target="_blank">' + value + '</a>' value = `<a href="${value}" target="_blank">${value}</a>`
} }
return value return value
}, },
@ -215,8 +215,8 @@ L.U.PopupTemplate.GeoRSSImage = L.U.PopupTemplate.BaseWithTitle.extend({
img.src = this.feature.properties.img img.src = this.feature.properties.img
// Sadly, we are unable to override this from JS the clean way // Sadly, we are unable to override this from JS the clean way
// See https://github.com/Leaflet/Leaflet/commit/61d746818b99d362108545c151a27f09d60960ee#commitcomment-6061847 // See https://github.com/Leaflet/Leaflet/commit/61d746818b99d362108545c151a27f09d60960ee#commitcomment-6061847
img.style.maxWidth = this.options.maxWidth + 'px' img.style.maxWidth = `${this.options.maxWidth}px`
img.style.maxHeight = this.options.maxWidth + 'px' img.style.maxHeight = `${this.options.maxWidth}px`
this.onElementLoaded(img) this.onElementLoaded(img)
} }
return container return container

View file

@ -71,7 +71,7 @@ L.U.Slideshow = L.Class.extend({
timeSpinner: function () { timeSpinner: function () {
const time = parseInt(this.options.delay, 10) const time = parseInt(this.options.delay, 10)
if (!time) return if (!time) return
const css = 'rotation ' + time / 1000 + 's infinite linear', const css = `rotation ${time / 1000}s infinite linear`,
spinners = document.querySelectorAll('.umap-slideshow-toolbox .play .spinner') spinners = document.querySelectorAll('.umap-slideshow-toolbox .play .spinner')
for (let i = 0; i < spinners.length; i++) { for (let i = 0; i < spinners.length; i++) {
spinners[i].style.animation = css spinners[i].style.animation = css

View file

@ -55,7 +55,7 @@ L.U.TableEditor = L.Class.extend({
renderRow: function (feature) { renderRow: function (feature) {
const builder = new L.U.FormBuilder(feature, this.field_properties, { const builder = new L.U.FormBuilder(feature, this.field_properties, {
id: 'umap-feature-properties_' + L.stamp(feature), id: `umap-feature-properties_${L.stamp(feature)}`,
className: 'trow', className: 'trow',
callback: feature.resetTooltip, callback: feature.resetTooltip,
}) })
@ -71,7 +71,7 @@ L.U.TableEditor = L.Class.extend({
this.field_properties = [] this.field_properties = []
for (let i = 0; i < this.properties.length; i++) { for (let i = 0; i < this.properties.length; i++) {
this.field_properties.push([ this.field_properties.push([
'properties.' + this.properties[i], `properties.${this.properties[i]}`,
{ wrapper: 'div', wrapperClass: 'tcell' }, { wrapper: 'div', wrapperClass: 'tcell' },
]) ])
} }

View file

@ -185,13 +185,13 @@ L.U.UI = L.Evented.extend({
}, },
setTooltipPosition: function (coords) { setTooltipPosition: function (coords) {
if (coords.left) this._tooltip.style.left = coords.left + 'px' if (coords.left) this._tooltip.style.left = `${coords.left}px`
else this._tooltip.style.left = 'initial' else this._tooltip.style.left = 'initial'
if (coords.right) this._tooltip.style.right = coords.right + 'px' if (coords.right) this._tooltip.style.right = `${coords.right}px`
else this._tooltip.style.right = 'initial' else this._tooltip.style.right = 'initial'
if (coords.top) this._tooltip.style.top = coords.top + 'px' if (coords.top) this._tooltip.style.top = `${coords.top}px`
else this._tooltip.style.top = 'initial' else this._tooltip.style.top = 'initial'
if (coords.bottom) this._tooltip.style.bottom = coords.bottom + 'px' if (coords.bottom) this._tooltip.style.bottom = `${coords.bottom}px`
else this._tooltip.style.bottom = 'initial' else this._tooltip.style.bottom = 'initial'
}, },