Merge pull request #1086 from umap-project/lebab-arrow
Install and apply Lebab for JS arrows’ conversions
This commit is contained in:
commit
d0f89c3be2
15 changed files with 1084 additions and 188 deletions
6
Makefile
6
Makefile
|
@ -58,3 +58,9 @@ filepath = "${jsdir}*.js"
|
|||
pretty: ## Apply PrettierJS to all JS files (or specified `filepath`)
|
||||
./node_modules/prettier/bin-prettier.js --write ${filepath}
|
||||
|
||||
lebab: ## Convert JS `filepath` to modern syntax with Lebab, then prettify
|
||||
./node_modules/lebab/bin/index.js --replace ${filepath} --transform arrow,arrow-return
|
||||
$(MAKE) pretty filepath=${filepath}
|
||||
|
||||
lebab-all: $(jsdir)* ## Convert all JS files to modern syntax with Lebab + prettify
|
||||
for file in $^ ; do $(MAKE) lebab filepath=$${file}; done
|
||||
|
|
976
package-lock.json
generated
976
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -8,6 +8,7 @@
|
|||
"devDependencies": {
|
||||
"chai": "^3.3.0",
|
||||
"happen": "~0.1.3",
|
||||
"lebab": "^3.2.1",
|
||||
"mocha": "^2.3.3",
|
||||
"mocha-phantomjs": "^4.0.1",
|
||||
"optimist": "~0.4.0",
|
||||
|
|
|
@ -129,10 +129,7 @@ L.U.AutoComplete = L.Class.extend({
|
|||
},
|
||||
|
||||
onBlur: function () {
|
||||
var self = this
|
||||
setTimeout(function () {
|
||||
self.hide()
|
||||
}, 100)
|
||||
setTimeout(() => this.hide(), 100)
|
||||
},
|
||||
|
||||
clear: function () {
|
||||
|
@ -207,7 +204,7 @@ L.U.AutoComplete = L.Class.extend({
|
|||
|
||||
resultToIndex: function (result) {
|
||||
var out = null
|
||||
this.forEach(this.RESULTS, function (item, index) {
|
||||
this.forEach(this.RESULTS, (item, index) => {
|
||||
if (item.item.value == result.item.value) {
|
||||
out = index
|
||||
return
|
||||
|
@ -217,12 +214,11 @@ L.U.AutoComplete = L.Class.extend({
|
|||
},
|
||||
|
||||
handleResults: function (data) {
|
||||
var self = this
|
||||
this.clear()
|
||||
this.container.style.display = 'block'
|
||||
this.resizeContainer()
|
||||
this.forEach(data, function (item) {
|
||||
self.RESULTS.push(self.createResult(item))
|
||||
this.forEach(data, (item) => {
|
||||
this.RESULTS.push(this.createResult(item))
|
||||
})
|
||||
this.CURRENT = 0
|
||||
this.highlight()
|
||||
|
@ -230,9 +226,8 @@ L.U.AutoComplete = L.Class.extend({
|
|||
},
|
||||
|
||||
highlight: function () {
|
||||
var self = this
|
||||
this.forEach(this.RESULTS, function (result, index) {
|
||||
if (index === self.CURRENT) L.DomUtil.addClass(result.el, 'on')
|
||||
this.forEach(this.RESULTS, (result, index) => {
|
||||
if (index === this.CURRENT) L.DomUtil.addClass(result.el, 'on')
|
||||
else L.DomUtil.removeClass(result.el, 'on')
|
||||
})
|
||||
},
|
||||
|
|
|
@ -566,7 +566,7 @@ L.U.DataLayersControl = L.Control.extend({
|
|||
if (e.finalIndex === 0) layer.bringToTop()
|
||||
else if (e.finalIndex > e.initialIndex) layer.insertBefore(other)
|
||||
else layer.insertAfter(other)
|
||||
this.map.eachDataLayerReverse(function (datalayer) {
|
||||
this.map.eachDataLayerReverse((datalayer) => {
|
||||
if (datalayer.getRank() >= minIndex) datalayer.isDirty = true
|
||||
})
|
||||
this.map.indexDatalayers()
|
||||
|
@ -681,7 +681,7 @@ L.U.Map.include({
|
|||
filter.placeholder = L._('Filter…')
|
||||
filter.value = this.options.filter || ''
|
||||
|
||||
var addFeature = function (feature) {
|
||||
var addFeature = (feature) => {
|
||||
var feature_li = L.DomUtil.create('li', feature.getClassName() + ' feature'),
|
||||
zoom_to = L.DomUtil.create('i', 'feature-zoom_to', feature_li),
|
||||
edit = L.DomUtil.create('i', 'show-on-edit feature-edit', feature_li),
|
||||
|
@ -726,7 +726,7 @@ L.U.Map.include({
|
|||
return feature_li
|
||||
}
|
||||
|
||||
var append = function (datalayer) {
|
||||
var append = (datalayer) => {
|
||||
var container = L.DomUtil.create(
|
||||
'div',
|
||||
datalayer.getHidableClass(),
|
||||
|
@ -739,9 +739,9 @@ L.U.Map.include({
|
|||
var ul = L.DomUtil.create('ul', '', container)
|
||||
L.DomUtil.classIf(container, 'off', !datalayer.isVisible())
|
||||
|
||||
var build = function () {
|
||||
var build = () => {
|
||||
ul.innerHTML = ''
|
||||
datalayer.eachFeature(function (feature) {
|
||||
datalayer.eachFeature((feature) => {
|
||||
if (
|
||||
(filterValue && !feature.matchFilter(filterValue, filterKeys)) ||
|
||||
feature.properties.isVisible === false
|
||||
|
@ -752,11 +752,11 @@ L.U.Map.include({
|
|||
}
|
||||
build()
|
||||
datalayer.on('datachanged', build)
|
||||
datalayer.map.ui.once('panel:closed', function () {
|
||||
datalayer.map.ui.once('panel:closed', () => {
|
||||
datalayer.off('datachanged', build)
|
||||
})
|
||||
datalayer.map.ui.once('panel:ready', function () {
|
||||
datalayer.map.ui.once('panel:ready', function () {
|
||||
datalayer.map.ui.once('panel:ready', () => {
|
||||
datalayer.map.ui.once('panel:ready', () => {
|
||||
datalayer.off('datachanged', build)
|
||||
})
|
||||
})
|
||||
|
@ -765,12 +765,12 @@ L.U.Map.include({
|
|||
var appendAll = function () {
|
||||
this.options.filter = filterValue = filter.value
|
||||
featuresContainer.innerHTML = ''
|
||||
this.eachBrowsableDataLayer(function (datalayer) {
|
||||
this.eachBrowsableDataLayer((datalayer) => {
|
||||
append(datalayer)
|
||||
})
|
||||
}
|
||||
var resetLayers = function () {
|
||||
this.eachBrowsableDataLayer(function (datalayer) {
|
||||
this.eachBrowsableDataLayer((datalayer) => {
|
||||
datalayer.resetLayer(true)
|
||||
})
|
||||
}
|
||||
|
@ -812,8 +812,8 @@ L.U.Map.include({
|
|||
this.getMap().options.advancedFilters[property] = []
|
||||
}
|
||||
})
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
datalayer.eachFeature(function (feature) {
|
||||
this.eachDataLayer((datalayer) => {
|
||||
datalayer.eachFeature((feature) => {
|
||||
advancedFilterKeys.forEach((property) => {
|
||||
if (feature.properties[property]) {
|
||||
if (!advancedFiltersFull[property].includes(feature.properties[property])) {
|
||||
|
@ -875,7 +875,7 @@ L.U.Map.include({
|
|||
|
||||
var filterFeatures = function () {
|
||||
var noResults = true
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
this.eachDataLayer((datalayer) => {
|
||||
datalayer.eachFeature(function (feature) {
|
||||
feature.properties.isVisible = true
|
||||
for (const [property, values] of Object.entries(
|
||||
|
@ -1060,11 +1060,11 @@ L.U.Search = L.PhotonSearch.extend({
|
|||
edit.title = L._('Save this location as new feature')
|
||||
// We need to use "mousedown" because Leaflet.Photon listen to mousedown
|
||||
// on el.
|
||||
L.DomEvent.on(zoom, 'mousedown', function (e) {
|
||||
L.DomEvent.on(zoom, 'mousedown', (e) => {
|
||||
L.DomEvent.stop(e)
|
||||
self.zoomToFeature(feature)
|
||||
})
|
||||
L.DomEvent.on(edit, 'mousedown', function (e) {
|
||||
L.DomEvent.on(edit, 'mousedown', (e) => {
|
||||
L.DomEvent.stop(e)
|
||||
var datalayer = self.map.defaultDataLayer()
|
||||
var layer = datalayer.geojsonToFeatures(feature)
|
||||
|
@ -1101,7 +1101,7 @@ L.U.SearchControl = L.Control.extend({
|
|||
var link = L.DomUtil.create('a', '', container)
|
||||
link.href = '#'
|
||||
link.title = L._('Search a place name')
|
||||
L.DomEvent.on(link, 'click', function (e) {
|
||||
L.DomEvent.on(link, 'click', (e) => {
|
||||
L.DomEvent.stop(e)
|
||||
self.openPanel(map)
|
||||
})
|
||||
|
@ -1122,14 +1122,14 @@ L.U.SearchControl = L.Control.extend({
|
|||
var resultsContainer = L.DomUtil.create('div', 'photon-autocomplete', container)
|
||||
this.search = new L.U.Search(map, input, options)
|
||||
var id = Math.random()
|
||||
this.search.on('ajax:send', function () {
|
||||
this.search.on('ajax:send', () => {
|
||||
map.fire('dataloading', { id: id })
|
||||
})
|
||||
this.search.on('ajax:return', function () {
|
||||
this.search.on('ajax:return', () => {
|
||||
map.fire('dataload', { id: id })
|
||||
})
|
||||
this.search.resultsContainer = resultsContainer
|
||||
map.ui.once('panel:ready', function () {
|
||||
map.ui.once('panel:ready', () => {
|
||||
input.focus()
|
||||
})
|
||||
map.ui.openPanel({ data: { html: container } })
|
||||
|
@ -1236,7 +1236,7 @@ L.U.IframeExporter = L.Evented.extend({
|
|||
this.queryString.feature = this.map.currentFeature.getSlug()
|
||||
}
|
||||
if (this.options.keepCurrentDatalayers) {
|
||||
this.map.eachDataLayer(function (datalayer) {
|
||||
this.map.eachDataLayer((datalayer) => {
|
||||
if (datalayer.isVisible() && datalayer.umap_id) {
|
||||
datalayers.push(datalayer.umap_id)
|
||||
}
|
||||
|
@ -1272,7 +1272,7 @@ L.U.Editable = L.Editable.extend({
|
|||
)
|
||||
this.on('editable:drawing:end', this.closeTooltip)
|
||||
// Layer for items added by users
|
||||
this.on('editable:drawing:cancel', function (e) {
|
||||
this.on('editable:drawing:cancel', (e) => {
|
||||
if (e.layer._latlngs && e.layer._latlngs.length < e.layer.editor.MIN_VERTEX)
|
||||
e.layer.del()
|
||||
if (e.layer instanceof L.U.Marker) e.layer.del()
|
||||
|
@ -1281,7 +1281,7 @@ L.U.Editable = L.Editable.extend({
|
|||
e.layer.isDirty = true
|
||||
if (this.map.editedFeature !== e.layer) e.layer.edit(e)
|
||||
})
|
||||
this.on('editable:editing', function (e) {
|
||||
this.on('editable:editing', (e) => {
|
||||
var layer = e.layer
|
||||
layer.isDirty = true
|
||||
if (layer._tooltip && layer.isTooltipOpen()) {
|
||||
|
@ -1289,12 +1289,12 @@ L.U.Editable = L.Editable.extend({
|
|||
layer._tooltip.update()
|
||||
}
|
||||
})
|
||||
this.on('editable:vertex:ctrlclick', function (e) {
|
||||
this.on('editable:vertex:ctrlclick', (e) => {
|
||||
var index = e.vertex.getIndex()
|
||||
if (index === 0 || (index === e.vertex.getLastIndex() && e.vertex.continue))
|
||||
e.vertex.continue()
|
||||
})
|
||||
this.on('editable:vertex:altclick', function (e) {
|
||||
this.on('editable:vertex:altclick', (e) => {
|
||||
if (e.vertex.editor.vertexCanBeDeleted(e.vertex)) e.vertex.delete()
|
||||
})
|
||||
this.on('editable:vertex:rawclick', this.onVertexRawClick)
|
||||
|
|
|
@ -7,10 +7,8 @@ L.U.Map = L.Map.extend({})
|
|||
/*
|
||||
* Utils
|
||||
*/
|
||||
L.Util.queryString = function (name, fallback) {
|
||||
var decode = function (s) {
|
||||
return decodeURIComponent(s.replace(/\+/g, ' '))
|
||||
}
|
||||
L.Util.queryString = (name, fallback) => {
|
||||
var decode = (s) => decodeURIComponent(s.replace(/\+/g, ' '))
|
||||
var qs = window.location.search.slice(1).split('&'),
|
||||
qa = {}
|
||||
for (var i in qs) {
|
||||
|
@ -21,21 +19,21 @@ L.Util.queryString = function (name, fallback) {
|
|||
return qa[name] || fallback
|
||||
}
|
||||
|
||||
L.Util.booleanFromQueryString = function (name) {
|
||||
L.Util.booleanFromQueryString = (name) => {
|
||||
var value = L.Util.queryString(name)
|
||||
return value === '1' || value === 'true'
|
||||
}
|
||||
|
||||
L.Util.setFromQueryString = function (options, name) {
|
||||
L.Util.setFromQueryString = (options, name) => {
|
||||
var value = L.Util.queryString(name)
|
||||
if (typeof value !== 'undefined') options[name] = value
|
||||
}
|
||||
|
||||
L.Util.setBooleanFromQueryString = function (options, name) {
|
||||
L.Util.setBooleanFromQueryString = (options, name) => {
|
||||
var value = L.Util.queryString(name)
|
||||
if (typeof value !== 'undefined') options[name] = value == '1' || value == 'true'
|
||||
}
|
||||
L.Util.setNullableBooleanFromQueryString = function (options, name) {
|
||||
L.Util.setNullableBooleanFromQueryString = (options, name) => {
|
||||
var value = L.Util.queryString(name)
|
||||
if (typeof value !== 'undefined') {
|
||||
if (value === 'null') value = null
|
||||
|
@ -44,11 +42,11 @@ L.Util.setNullableBooleanFromQueryString = function (options, name) {
|
|||
options[name] = value
|
||||
}
|
||||
}
|
||||
L.Util.escapeHTML = function (s) {
|
||||
L.Util.escapeHTML = (s) => {
|
||||
s = s ? s.toString() : ''
|
||||
return s.replace(/</gm, '<')
|
||||
}
|
||||
L.Util.toHTML = function (r) {
|
||||
L.Util.toHTML = (r) => {
|
||||
if (!r) return ''
|
||||
var ii
|
||||
|
||||
|
@ -113,13 +111,9 @@ L.Util.toHTML = function (r) {
|
|||
|
||||
return r
|
||||
}
|
||||
L.Util.isObject = function (what) {
|
||||
return typeof what === 'object' && what !== null
|
||||
}
|
||||
L.Util.CopyJSON = function (geojson) {
|
||||
return JSON.parse(JSON.stringify(geojson))
|
||||
}
|
||||
L.Util.detectFileType = function (f) {
|
||||
L.Util.isObject = (what) => typeof what === 'object' && what !== null
|
||||
L.Util.CopyJSON = (geojson) => JSON.parse(JSON.stringify(geojson))
|
||||
L.Util.detectFileType = (f) => {
|
||||
var filename = f.name ? escape(f.name.toLowerCase()) : ''
|
||||
function ext(_) {
|
||||
return filename.indexOf(_) !== -1
|
||||
|
@ -136,11 +130,10 @@ L.Util.detectFileType = function (f) {
|
|||
if (ext('.umap')) return 'umap'
|
||||
}
|
||||
|
||||
L.Util.usableOption = function (options, option) {
|
||||
return options[option] !== undefined && options[option] !== ''
|
||||
}
|
||||
L.Util.usableOption = (options, option) =>
|
||||
options[option] !== undefined && options[option] !== ''
|
||||
|
||||
L.Util.greedyTemplate = function (str, data, ignore) {
|
||||
L.Util.greedyTemplate = (str, data, ignore) => {
|
||||
function getValue(data, path) {
|
||||
var value = data
|
||||
for (var i = 0; i < path.length; i++) {
|
||||
|
@ -152,7 +145,7 @@ L.Util.greedyTemplate = function (str, data, ignore) {
|
|||
|
||||
return str.replace(
|
||||
/\{ *([\w_\:\.\|]+)(?:\|("[^"]*"))? *\}/g,
|
||||
function (str, key, staticFallback) {
|
||||
(str, key, staticFallback) => {
|
||||
var vars = key.split('|'),
|
||||
value,
|
||||
path
|
||||
|
@ -175,10 +168,10 @@ L.Util.greedyTemplate = function (str, data, ignore) {
|
|||
)
|
||||
}
|
||||
|
||||
L.Util.sortFeatures = function (features, sortKey) {
|
||||
L.Util.sortFeatures = (features, sortKey) => {
|
||||
var sortKeys = (sortKey || 'name').split(',')
|
||||
|
||||
var sort = function (a, b, i) {
|
||||
var sort = (a, b, i) => {
|
||||
var sortKey = sortKeys[i],
|
||||
score,
|
||||
valA = a.properties[sortKey] || '',
|
||||
|
@ -194,7 +187,7 @@ L.Util.sortFeatures = function (features, sortKey) {
|
|||
return score
|
||||
}
|
||||
|
||||
features.sort(function (a, b) {
|
||||
features.sort((a, b) => {
|
||||
if (!a.properties || !b.properties) {
|
||||
return 0
|
||||
}
|
||||
|
@ -204,12 +197,12 @@ L.Util.sortFeatures = function (features, sortKey) {
|
|||
return features
|
||||
}
|
||||
|
||||
L.Util.flattenCoordinates = function (coords) {
|
||||
L.Util.flattenCoordinates = (coords) => {
|
||||
while (coords[0] && typeof coords[0][0] !== 'number') coords = coords[0]
|
||||
return coords
|
||||
}
|
||||
|
||||
L.Util.buildQueryString = function (params) {
|
||||
L.Util.buildQueryString = (params) => {
|
||||
var query_string = []
|
||||
for (var key in params) {
|
||||
query_string.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]))
|
||||
|
@ -217,11 +210,9 @@ L.Util.buildQueryString = function (params) {
|
|||
return query_string.join('&')
|
||||
}
|
||||
|
||||
L.Util.getBaseUrl = function () {
|
||||
return '//' + window.location.host + window.location.pathname
|
||||
}
|
||||
L.Util.getBaseUrl = () => '//' + window.location.host + window.location.pathname
|
||||
|
||||
L.DomUtil.add = function (tagName, className, container, content) {
|
||||
L.DomUtil.add = (tagName, className, container, content) => {
|
||||
var el = L.DomUtil.create(tagName, className, container)
|
||||
if (content) {
|
||||
if (content.nodeType && content.nodeType === 1) {
|
||||
|
@ -233,7 +224,7 @@ L.DomUtil.add = function (tagName, className, container, content) {
|
|||
return el
|
||||
}
|
||||
|
||||
L.DomUtil.createFieldset = function (container, legend, options) {
|
||||
L.DomUtil.createFieldset = (container, legend, options) => {
|
||||
options = options || {}
|
||||
var fieldset = L.DomUtil.create('div', 'fieldset toggle', container)
|
||||
var legendEl = L.DomUtil.add('h5', 'legend style_options_toggle', fieldset, legend)
|
||||
|
@ -249,12 +240,12 @@ L.DomUtil.createFieldset = function (container, legend, options) {
|
|||
return fieldsEl
|
||||
}
|
||||
|
||||
L.DomUtil.classIf = function (el, className, bool) {
|
||||
L.DomUtil.classIf = (el, className, bool) => {
|
||||
if (bool) L.DomUtil.addClass(el, className)
|
||||
else L.DomUtil.removeClass(el, className)
|
||||
}
|
||||
|
||||
L.DomUtil.element = function (what, attrs, parent) {
|
||||
L.DomUtil.element = (what, attrs, parent) => {
|
||||
var el = document.createElement(what)
|
||||
for (var attr in attrs) {
|
||||
el[attr] = attrs[attr]
|
||||
|
@ -265,19 +256,19 @@ L.DomUtil.element = function (what, attrs, parent) {
|
|||
return el
|
||||
}
|
||||
|
||||
L.DomUtil.before = function (target, el) {
|
||||
L.DomUtil.before = (target, el) => {
|
||||
target.parentNode.insertBefore(el, target)
|
||||
return el
|
||||
}
|
||||
|
||||
L.DomUtil.after = function (target, el) {
|
||||
L.DomUtil.after = (target, el) => {
|
||||
target.parentNode.insertBefore(el, target.nextSibling)
|
||||
return el
|
||||
}
|
||||
|
||||
L.DomUtil.RGBRegex = /rgb *\( *([0-9]{1,3}) *, *([0-9]{1,3}) *, *([0-9]{1,3}) *\)/
|
||||
|
||||
L.DomUtil.TextColorFromBackgroundColor = function (el) {
|
||||
L.DomUtil.TextColorFromBackgroundColor = (el) => {
|
||||
var out = '#000000'
|
||||
if (!window.getComputedStyle) {
|
||||
return out
|
||||
|
@ -293,7 +284,7 @@ L.DomUtil.TextColorFromBackgroundColor = function (el) {
|
|||
}
|
||||
return out
|
||||
}
|
||||
L.DomEvent.once = function (el, types, fn, context) {
|
||||
L.DomEvent.once = (el, types, fn, context) => {
|
||||
// cf https://github.com/Leaflet/Leaflet/pull/3528#issuecomment-134551575
|
||||
|
||||
if (typeof types === 'object') {
|
||||
|
@ -303,7 +294,7 @@ L.DomEvent.once = function (el, types, fn, context) {
|
|||
return L.DomEvent
|
||||
}
|
||||
|
||||
var handler = L.bind(function () {
|
||||
var handler = L.bind(() => {
|
||||
L.DomEvent.off(el, types, fn, context).off(el, types, handler, context)
|
||||
}, L.DomEvent)
|
||||
|
||||
|
@ -405,7 +396,7 @@ L.U.Help = L.Class.extend({
|
|||
self = this,
|
||||
title = L.DomUtil.create('h3', '', container),
|
||||
actionsContainer = L.DomUtil.create('ul', 'umap-edit-actions', container)
|
||||
var addAction = function (action) {
|
||||
var addAction = (action) => {
|
||||
var actionContainer = L.DomUtil.add('li', '', actionsContainer)
|
||||
L.DomUtil.add('i', action.options.className, actionContainer),
|
||||
L.DomUtil.add('span', '', actionContainer, action.options.tooltip)
|
||||
|
|
|
@ -622,7 +622,7 @@ L.U.Marker = L.Marker.extend({
|
|||
zoomTo: function (e) {
|
||||
if (this.datalayer.isClustered() && !this._icon) {
|
||||
// callback is mandatory for zoomToShowLayer
|
||||
this.datalayer.layer.zoomToShowLayer(this, e.callback || function () {})
|
||||
this.datalayer.layer.zoomToShowLayer(this, e.callback || (() => {}))
|
||||
} else {
|
||||
L.U.FeatureMixin.zoomTo.call(this, e)
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ L.FormBuilder.ColorPicker = L.FormBuilder.Input.extend({
|
|||
|
||||
onBlur: function () {
|
||||
var self = this,
|
||||
closePicker = function () {
|
||||
closePicker = () => {
|
||||
self.container.style.display = 'none'
|
||||
}
|
||||
// We must leave time for the click to be listened.
|
||||
|
@ -395,7 +395,7 @@ L.FormBuilder.SlideshowDelay = L.FormBuilder.IntSelect.extend({
|
|||
L.FormBuilder.DataLayerSwitcher = L.FormBuilder.Select.extend({
|
||||
getOptions: function () {
|
||||
var options = []
|
||||
this.builder.map.eachDataLayerReverse(function (datalayer) {
|
||||
this.builder.map.eachDataLayerReverse((datalayer) => {
|
||||
if (datalayer.isLoaded() && !datalayer.isRemoteLayer() && datalayer.canBrowse()) {
|
||||
options.push([L.stamp(datalayer), datalayer.getName()])
|
||||
}
|
||||
|
@ -864,9 +864,7 @@ L.FormBuilder.ManageEditors = L.FormBuilder.Element.extend({
|
|||
},
|
||||
|
||||
onUnselect: function (choice) {
|
||||
var index = this._values.findIndex(function (item) {
|
||||
return item.id === choice.item.value
|
||||
})
|
||||
var index = this._values.findIndex((item) => item.id === choice.item.value)
|
||||
if (index !== -1) {
|
||||
this._values.splice(index, 1)
|
||||
this.set()
|
||||
|
|
|
@ -256,7 +256,7 @@ L.U.Map.include({
|
|||
if (slug && this.features_index[slug]) this.features_index[slug].view()
|
||||
})
|
||||
|
||||
window.onbeforeunload = function (e) {
|
||||
window.onbeforeunload = (e) => {
|
||||
var msg = L._('You have unsaved changes.')
|
||||
if (self.isDirty) {
|
||||
e.returnValue = msg
|
||||
|
@ -376,19 +376,19 @@ L.U.Map.include({
|
|||
var toload = (dataToload = seen = this.options.datalayers.length),
|
||||
self = this,
|
||||
datalayer
|
||||
var loaded = function () {
|
||||
var loaded = () => {
|
||||
self.datalayersLoaded = true
|
||||
self.fire('datalayersloaded')
|
||||
}
|
||||
var decrementToLoad = function () {
|
||||
var decrementToLoad = () => {
|
||||
toload--
|
||||
if (toload === 0) loaded()
|
||||
}
|
||||
var dataLoaded = function () {
|
||||
var dataLoaded = () => {
|
||||
self.dataLoaded = true
|
||||
self.fire('dataloaded')
|
||||
}
|
||||
var decrementDataToLoad = function () {
|
||||
var decrementDataToLoad = () => {
|
||||
dataToload--
|
||||
if (dataToload === 0) dataLoaded()
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ L.U.Map.include({
|
|||
},
|
||||
|
||||
ensurePanesOrder: function () {
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
this.eachDataLayer((datalayer) => {
|
||||
datalayer.bringToTop()
|
||||
})
|
||||
},
|
||||
|
@ -709,7 +709,7 @@ L.U.Map.include({
|
|||
|
||||
updateTileLayers: function () {
|
||||
var self = this,
|
||||
callback = function (tilelayer) {
|
||||
callback = (tilelayer) => {
|
||||
self.options.tilelayer = tilelayer.toJSON()
|
||||
self.isDirty = true
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ L.U.Map.include({
|
|||
UIFields.push('queryString.' + this.HIDDABLE_CONTROLS[i] + 'Control')
|
||||
}
|
||||
var iframeExporter = new L.U.IframeExporter(this)
|
||||
var buildIframeCode = function () {
|
||||
var buildIframeCode = () => {
|
||||
iframe.innerHTML = iframeExporter.build()
|
||||
}
|
||||
buildIframeCode()
|
||||
|
@ -787,7 +787,7 @@ L.U.Map.include({
|
|||
L._('Only visible features will be downloaded.')
|
||||
)
|
||||
exportCaveat.id = 'export_caveat_text'
|
||||
var toggleCaveat = function () {
|
||||
var toggleCaveat = () => {
|
||||
if (typeInput.value === 'umap') exportCaveat.style.display = 'none'
|
||||
else exportCaveat.style.display = 'inherit'
|
||||
}
|
||||
|
@ -855,7 +855,7 @@ L.U.Map.include({
|
|||
|
||||
toGeoJSON: function () {
|
||||
var features = []
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
this.eachDataLayer((datalayer) => {
|
||||
if (datalayer.isVisible()) {
|
||||
features = features.concat(datalayer.featuresToGeoJSON())
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ L.U.Map.include({
|
|||
var clearFlag = L.DomUtil.create('input', '', clearLabel)
|
||||
clearFlag.type = 'checkbox'
|
||||
clearFlag.name = 'clear'
|
||||
this.eachDataLayerReverse(function (datalayer) {
|
||||
this.eachDataLayerReverse((datalayer) => {
|
||||
if (datalayer.isLoaded() && !datalayer.isRemoteLayer()) {
|
||||
var id = L.stamp(datalayer)
|
||||
option = L.DomUtil.create('option', '', layerInput)
|
||||
|
@ -995,7 +995,7 @@ L.U.Map.include({
|
|||
L.DomEvent.on(
|
||||
fileInput,
|
||||
'change',
|
||||
function (e) {
|
||||
(e) => {
|
||||
var type = '',
|
||||
newType
|
||||
for (var i = 0; i < e.target.files.length; i++) {
|
||||
|
@ -1028,7 +1028,7 @@ L.U.Map.include({
|
|||
|
||||
if (importedData.geometry) this.options.center = this.latLng(importedData.geometry)
|
||||
var self = this
|
||||
importedData.layers.forEach(function (geojson) {
|
||||
importedData.layers.forEach((geojson) => {
|
||||
var dataLayer = self.createDataLayer()
|
||||
dataLayer.fromUmapGeoJSON(geojson)
|
||||
})
|
||||
|
@ -1036,7 +1036,7 @@ L.U.Map.include({
|
|||
this.initTileLayers()
|
||||
this.renderControls()
|
||||
this.handleLimitBounds()
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
this.eachDataLayer((datalayer) => {
|
||||
if (mustReindex) datalayer.reindex()
|
||||
datalayer.redraw()
|
||||
})
|
||||
|
@ -1048,7 +1048,7 @@ L.U.Map.include({
|
|||
var reader = new FileReader()
|
||||
reader.readAsText(file)
|
||||
var self = this
|
||||
reader.onload = function (e) {
|
||||
reader.onload = (e) => {
|
||||
var rawData = e.target.result
|
||||
try {
|
||||
self.importRaw(rawData)
|
||||
|
@ -1084,7 +1084,7 @@ L.U.Map.include({
|
|||
description.innerHTML = L.Util.toHTML(this.options.description)
|
||||
}
|
||||
var datalayerContainer = L.DomUtil.create('div', 'datalayer-container', container)
|
||||
this.eachVisibleDataLayer(function (datalayer) {
|
||||
this.eachVisibleDataLayer((datalayer) => {
|
||||
var p = L.DomUtil.create('p', '', datalayerContainer),
|
||||
color = L.DomUtil.create('span', 'datalayer-color', p),
|
||||
headline = L.DomUtil.create('strong', '', p),
|
||||
|
@ -1171,15 +1171,11 @@ L.U.Map.include({
|
|||
},
|
||||
|
||||
eachBrowsableDataLayer: function (method, context) {
|
||||
this.eachDataLayerReverse(method, context, function (d) {
|
||||
return d.allowBrowse()
|
||||
})
|
||||
this.eachDataLayerReverse(method, context, (d) => d.allowBrowse())
|
||||
},
|
||||
|
||||
eachVisibleDataLayer: function (method, context) {
|
||||
this.eachDataLayerReverse(method, context, function (d) {
|
||||
return d.isVisible()
|
||||
})
|
||||
this.eachDataLayerReverse(method, context, (d) => d.isVisible())
|
||||
},
|
||||
|
||||
findDataLayer: function (method, context) {
|
||||
|
@ -1198,7 +1194,7 @@ L.U.Map.include({
|
|||
if (this.editTools) this.editTools.stopDrawing()
|
||||
this.resetOptions()
|
||||
this.datalayers_index = [].concat(this._datalayers_index_bk)
|
||||
this.dirty_datalayers.slice().forEach(function (datalayer) {
|
||||
this.dirty_datalayers.slice().forEach((datalayer) => {
|
||||
if (datalayer.isDeleted) datalayer.connectToMap()
|
||||
datalayer.reset()
|
||||
})
|
||||
|
@ -1308,7 +1304,7 @@ L.U.Map.include({
|
|||
layers: [],
|
||||
}
|
||||
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
this.eachDataLayer((datalayer) => {
|
||||
umapfile.layers.push(datalayer.umapGeoJSON())
|
||||
})
|
||||
|
||||
|
@ -1414,7 +1410,7 @@ L.U.Map.include({
|
|||
) {
|
||||
return datalayer
|
||||
}
|
||||
datalayer = this.findDataLayer(function (datalayer) {
|
||||
datalayer = this.findDataLayer((datalayer) => {
|
||||
if (!datalayer.isRemoteLayer() && datalayer.canBrowse()) {
|
||||
fallback = datalayer
|
||||
if (datalayer.isVisible()) return true
|
||||
|
@ -1430,9 +1426,7 @@ L.U.Map.include({
|
|||
},
|
||||
|
||||
getDataLayerByUmapId: function (umap_id) {
|
||||
return this.findDataLayer(function (d) {
|
||||
return d.umap_id == umap_id
|
||||
})
|
||||
return this.findDataLayer((d) => d.umap_id == umap_id)
|
||||
},
|
||||
|
||||
_editControls: function (container) {
|
||||
|
@ -1478,7 +1472,7 @@ L.U.Map.include({
|
|||
|
||||
builder = new L.U.FormBuilder(this, shapeOptions, {
|
||||
callback: function (e) {
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
this.eachDataLayer((datalayer) => {
|
||||
datalayer.redraw()
|
||||
})
|
||||
},
|
||||
|
@ -1541,7 +1535,7 @@ L.U.Map.include({
|
|||
builder = new L.U.FormBuilder(this, optionsFields, {
|
||||
callback: function (e) {
|
||||
this.initCaptionBar()
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
this.eachDataLayer((datalayer) => {
|
||||
if (e.helper.field === 'options.sortKey') datalayer.reindex()
|
||||
datalayer.redraw()
|
||||
})
|
||||
|
@ -1571,7 +1565,7 @@ L.U.Map.include({
|
|||
e.helper.field === 'options.popupShape'
|
||||
)
|
||||
return
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
this.eachDataLayer((datalayer) => {
|
||||
datalayer.redraw()
|
||||
})
|
||||
},
|
||||
|
@ -2015,7 +2009,7 @@ L.U.Map.include({
|
|||
},
|
||||
|
||||
empty: function () {
|
||||
this.eachDataLayerReverse(function (datalayer) {
|
||||
this.eachDataLayerReverse((datalayer) => {
|
||||
datalayer._delete()
|
||||
})
|
||||
},
|
||||
|
|
|
@ -343,9 +343,7 @@ L.U.DataLayer = L.Evented.extend({
|
|||
|
||||
reindex: function () {
|
||||
var features = []
|
||||
this.eachFeature(function (feature) {
|
||||
features.push(feature)
|
||||
})
|
||||
this.eachFeature((feature) => features.push(feature))
|
||||
L.Util.sortFeatures(features, this.map.getOption('sortKey'))
|
||||
this._index = []
|
||||
for (var i = 0; i < features.length; i++) {
|
||||
|
@ -366,18 +364,17 @@ L.U.DataLayer = L.Evented.extend({
|
|||
}
|
||||
if (!this.options.remoteData.dynamic && this.hasDataLoaded()) return
|
||||
if (!this.isVisible()) return
|
||||
var self = this,
|
||||
url = this.map.localizeUrl(this.options.remoteData.url)
|
||||
var url = this.map.localizeUrl(this.options.remoteData.url)
|
||||
if (this.options.remoteData.proxy)
|
||||
url = this.map.proxyUrl(url, this.options.remoteData.ttl)
|
||||
this.map.ajax({
|
||||
uri: url,
|
||||
verb: 'GET',
|
||||
callback: function (raw) {
|
||||
self.clear()
|
||||
self.rawToGeoJSON(raw, self.options.remoteData.format, function (geojson) {
|
||||
self.fromGeoJSON(geojson)
|
||||
})
|
||||
callback: (raw) => {
|
||||
this.clear()
|
||||
this.rawToGeoJSON(raw, this.options.remoteData.format, (geojson) =>
|
||||
this.fromGeoJSON(geojson)
|
||||
)
|
||||
},
|
||||
})
|
||||
},
|
||||
|
@ -508,17 +505,11 @@ L.U.DataLayer = L.Evented.extend({
|
|||
},
|
||||
|
||||
addRawData: function (c, type) {
|
||||
var self = this
|
||||
this.rawToGeoJSON(c, type, function (geojson) {
|
||||
self.addData(geojson)
|
||||
})
|
||||
this.rawToGeoJSON(c, type, (geojson) => this.addData(geojson))
|
||||
},
|
||||
|
||||
rawToGeoJSON: function (c, type, callback) {
|
||||
var self = this
|
||||
var toDom = function (x) {
|
||||
return new DOMParser().parseFromString(x, 'text/xml')
|
||||
}
|
||||
var toDom = (x) => new DOMParser().parseFromString(x, 'text/xml')
|
||||
|
||||
// TODO add a duck typing guessType
|
||||
if (type === 'csv') {
|
||||
|
@ -528,7 +519,7 @@ L.U.DataLayer = L.Evented.extend({
|
|||
delimiter: 'auto',
|
||||
includeLatLon: false,
|
||||
},
|
||||
function (err, result) {
|
||||
(err, result) => {
|
||||
if (err) {
|
||||
var message
|
||||
if (err.type === 'Error') {
|
||||
|
@ -539,7 +530,7 @@ L.U.DataLayer = L.Evented.extend({
|
|||
message: err[0].message,
|
||||
})
|
||||
}
|
||||
self.map.ui.alert({ content: message, level: 'error', duration: 10000 })
|
||||
this.map.ui.alert({ content: message, level: 'error', duration: 10000 })
|
||||
console.log(err)
|
||||
}
|
||||
if (result && result.features.length) {
|
||||
|
@ -566,7 +557,7 @@ L.U.DataLayer = L.Evented.extend({
|
|||
var gj = JSON.parse(c)
|
||||
callback(gj)
|
||||
} catch (err) {
|
||||
self.map.ui.alert({ content: 'Invalid JSON file: ' + err })
|
||||
this.map.ui.alert({ content: 'Invalid JSON file: ' + err })
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -670,24 +661,18 @@ L.U.DataLayer = L.Evented.extend({
|
|||
},
|
||||
|
||||
importFromFile: function (f, type) {
|
||||
var reader = new FileReader(),
|
||||
self = this
|
||||
var reader = new FileReader()
|
||||
type = type || L.Util.detectFileType(f)
|
||||
reader.readAsText(f)
|
||||
reader.onload = function (e) {
|
||||
self.importRaw(e.target.result, type)
|
||||
}
|
||||
reader.onload = (e) => this.importRaw(e.target.result, type)
|
||||
},
|
||||
|
||||
importFromUrl: function (url, type) {
|
||||
url = this.map.localizeUrl(url)
|
||||
var self = this
|
||||
this.map.xhr._ajax({
|
||||
verb: 'GET',
|
||||
uri: url,
|
||||
callback: function (data) {
|
||||
self.importRaw(data, type)
|
||||
},
|
||||
callback: (data) => this.importRaw(data, type),
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -1034,9 +1019,7 @@ L.U.DataLayer = L.Evented.extend({
|
|||
|
||||
featuresToGeoJSON: function () {
|
||||
var features = []
|
||||
this.eachLayer(function (layer) {
|
||||
features.push(layer.toGeoJSON())
|
||||
})
|
||||
this.eachLayer((layer) => features.push(layer.toGeoJSON()))
|
||||
return features
|
||||
},
|
||||
|
||||
|
|
|
@ -140,9 +140,7 @@ L.U.MapPermissions = L.Class.extend({
|
|||
if (!this.isDirty) return this.map.continueSaving()
|
||||
var formData = new FormData()
|
||||
if (!this.isAnonymousMap() && this.options.editors) {
|
||||
var editors = this.options.editors.map(function (u) {
|
||||
return u.id
|
||||
})
|
||||
var editors = this.options.editors.map((u) => u.id)
|
||||
for (var i = 0; i < this.options.editors.length; i++)
|
||||
formData.append('editors', this.options.editors[i].id)
|
||||
}
|
||||
|
|
|
@ -136,10 +136,10 @@ L.U.PopupTemplate.Default = L.Class.extend({
|
|||
feature: prev.properties.name || L._('previous'),
|
||||
})
|
||||
zoomLi.title = L._('Zoom to this feature')
|
||||
L.DomEvent.on(nextLi, 'click', function () {
|
||||
L.DomEvent.on(nextLi, 'click', () => {
|
||||
if (next) next.zoomTo({ callback: next.view })
|
||||
})
|
||||
L.DomEvent.on(previousLi, 'click', function () {
|
||||
L.DomEvent.on(previousLi, 'click', () => {
|
||||
if (prev) prev.zoomTo({ callback: prev.view })
|
||||
})
|
||||
L.DomEvent.on(
|
||||
|
|
|
@ -62,9 +62,7 @@ L.U.Slideshow = L.Class.extend({
|
|||
},
|
||||
|
||||
defaultDatalayer: function () {
|
||||
return this.map.findDataLayer(function (d) {
|
||||
return d.allowBrowse() && d.hasData()
|
||||
})
|
||||
return this.map.findDataLayer((d) => d.allowBrowse() && d.hasData())
|
||||
},
|
||||
|
||||
timeSpinner: function () {
|
||||
|
|
|
@ -27,7 +27,7 @@ L.U.TableEditor = L.Class.extend({
|
|||
L._('Are you sure you want to delete this property on all the features?')
|
||||
)
|
||||
) {
|
||||
this.datalayer.eachLayer(function (feature) {
|
||||
this.datalayer.eachLayer((feature) => {
|
||||
feature.deleteProperty(property)
|
||||
})
|
||||
this.datalayer.deindexProperty(property)
|
||||
|
@ -38,7 +38,7 @@ L.U.TableEditor = L.Class.extend({
|
|||
var doRename = function () {
|
||||
var newName = prompt(L._('Please enter the new name of this property'), property)
|
||||
if (!newName || !this.validateName(newName)) return
|
||||
this.datalayer.eachLayer(function (feature) {
|
||||
this.datalayer.eachLayer((feature) => {
|
||||
feature.renameProperty(property, newName)
|
||||
})
|
||||
this.datalayer.deindexProperty(property)
|
||||
|
|
|
@ -6,7 +6,7 @@ L.U.Xhr = L.Evented.extend({
|
|||
_wrapper: function () {
|
||||
var wrapper
|
||||
if (window.XMLHttpRequest === undefined) {
|
||||
wrapper = function () {
|
||||
wrapper = () => {
|
||||
try {
|
||||
return new window.ActiveXObject('Microsoft.XMLHTTP.6.0')
|
||||
} catch (e1) {
|
||||
|
@ -28,7 +28,7 @@ L.U.Xhr = L.Evented.extend({
|
|||
id = Math.random(),
|
||||
self = this
|
||||
this.fire('dataloading', { id: id })
|
||||
var loaded = function () {
|
||||
var loaded = () => {
|
||||
self.fire('dataload', { id: id })
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ L.U.Xhr = L.Evented.extend({
|
|||
}
|
||||
}
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status == 200) {
|
||||
settings.callback.call(settings.context || xhr, xhr.responseText, xhr)
|
||||
|
@ -194,7 +194,7 @@ L.U.Xhr = L.Evented.extend({
|
|||
if (!form) return
|
||||
L.DomEvent.on(form, 'submit', L.DomEvent.stopPropagation)
|
||||
.on(form, 'submit', L.DomEvent.preventDefault)
|
||||
.on(form, 'submit', function () {
|
||||
.on(form, 'submit', () => {
|
||||
self.submit_form(form_id, options)
|
||||
})
|
||||
},
|
||||
|
@ -203,7 +203,7 @@ L.U.Xhr = L.Evented.extend({
|
|||
var link = L.DomUtil.get(link_id),
|
||||
self = this
|
||||
if (link) {
|
||||
L.DomEvent.on(link, 'click', L.DomEvent.stop).on(link, 'click', function () {
|
||||
L.DomEvent.on(link, 'click', L.DomEvent.stop).on(link, 'click', () => {
|
||||
if (options.confirm && !confirm(options.confirm)) {
|
||||
return
|
||||
}
|
||||
|
@ -252,12 +252,12 @@ L.U.Xhr = L.Evented.extend({
|
|||
// data.html: login form
|
||||
// args: args of the first _json call, to call again at process end
|
||||
var self = this
|
||||
var proceed = function () {
|
||||
var proceed = () => {
|
||||
self.ui.closePanel()
|
||||
if (typeof args !== 'undefined') self._json.apply(self, args)
|
||||
else self.default_callback(data, {})
|
||||
}
|
||||
var ask_for_login = function (data) {
|
||||
var ask_for_login = (data) => {
|
||||
self.ui.openPanel({ data: data, className: 'login-panel' })
|
||||
self.listen_form('login_form', {
|
||||
callback: function (data) {
|
||||
|
@ -267,12 +267,12 @@ L.U.Xhr = L.Evented.extend({
|
|||
})
|
||||
// Auth links
|
||||
var links = document.getElementsByClassName('umap-login-popup')
|
||||
Object.keys(links).forEach(function (el) {
|
||||
Object.keys(links).forEach((el) => {
|
||||
var link = links[el]
|
||||
L.DomEvent.on(link, 'click', L.DomEvent.stop).on(link, 'click', function () {
|
||||
L.DomEvent.on(link, 'click', L.DomEvent.stop).on(link, 'click', () => {
|
||||
self.ui.closePanel()
|
||||
var win = window.open(link.href)
|
||||
window.umap_proceed = function () {
|
||||
window.umap_proceed = () => {
|
||||
proceed()
|
||||
win.close()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue