Manual lebab conversions

This commit is contained in:
David Larlet 2023-05-16 16:19:14 -04:00
parent 838bd73458
commit d88eee9ca4
2 changed files with 17 additions and 37 deletions

View file

@ -129,10 +129,7 @@ L.U.AutoComplete = L.Class.extend({
}, },
onBlur: function () { onBlur: function () {
var self = this setTimeout(() => this.hide(), 100)
setTimeout(() => {
self.hide()
}, 100)
}, },
clear: function () { clear: function () {
@ -217,12 +214,11 @@ L.U.AutoComplete = L.Class.extend({
}, },
handleResults: function (data) { handleResults: function (data) {
var self = this
this.clear() this.clear()
this.container.style.display = 'block' this.container.style.display = 'block'
this.resizeContainer() this.resizeContainer()
this.forEach(data, (item) => { this.forEach(data, (item) => {
self.RESULTS.push(self.createResult(item)) this.RESULTS.push(this.createResult(item))
}) })
this.CURRENT = 0 this.CURRENT = 0
this.highlight() this.highlight()
@ -230,9 +226,8 @@ L.U.AutoComplete = L.Class.extend({
}, },
highlight: function () { highlight: function () {
var self = this
this.forEach(this.RESULTS, (result, index) => { this.forEach(this.RESULTS, (result, index) => {
if (index === self.CURRENT) L.DomUtil.addClass(result.el, 'on') if (index === this.CURRENT) L.DomUtil.addClass(result.el, 'on')
else L.DomUtil.removeClass(result.el, 'on') else L.DomUtil.removeClass(result.el, 'on')
}) })
}, },

View file

@ -343,9 +343,7 @@ L.U.DataLayer = L.Evented.extend({
reindex: function () { reindex: function () {
var features = [] var features = []
this.eachFeature((feature) => { this.eachFeature((feature) => features.push(feature))
features.push(feature)
})
L.Util.sortFeatures(features, this.map.getOption('sortKey')) L.Util.sortFeatures(features, this.map.getOption('sortKey'))
this._index = [] this._index = []
for (var i = 0; i < features.length; i++) { 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.options.remoteData.dynamic && this.hasDataLoaded()) return
if (!this.isVisible()) return if (!this.isVisible()) return
var self = this, var url = this.map.localizeUrl(this.options.remoteData.url)
url = this.map.localizeUrl(this.options.remoteData.url)
if (this.options.remoteData.proxy) if (this.options.remoteData.proxy)
url = this.map.proxyUrl(url, this.options.remoteData.ttl) url = this.map.proxyUrl(url, this.options.remoteData.ttl)
this.map.ajax({ this.map.ajax({
uri: url, uri: url,
verb: 'GET', verb: 'GET',
callback: function (raw) { callback: (raw) => {
self.clear() this.clear()
self.rawToGeoJSON(raw, self.options.remoteData.format, (geojson) => { this.rawToGeoJSON(raw, this.options.remoteData.format, (geojson) =>
self.fromGeoJSON(geojson) this.fromGeoJSON(geojson)
}) )
}, },
}) })
}, },
@ -508,14 +505,10 @@ L.U.DataLayer = L.Evented.extend({
}, },
addRawData: function (c, type) { addRawData: function (c, type) {
var self = this this.rawToGeoJSON(c, type, (geojson) => this.addData(geojson))
this.rawToGeoJSON(c, type, (geojson) => {
self.addData(geojson)
})
}, },
rawToGeoJSON: function (c, type, callback) { rawToGeoJSON: function (c, type, callback) {
var self = this
var toDom = (x) => new DOMParser().parseFromString(x, 'text/xml') var toDom = (x) => new DOMParser().parseFromString(x, 'text/xml')
// TODO add a duck typing guessType // TODO add a duck typing guessType
@ -537,7 +530,7 @@ L.U.DataLayer = L.Evented.extend({
message: err[0].message, 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) console.log(err)
} }
if (result && result.features.length) { if (result && result.features.length) {
@ -564,7 +557,7 @@ L.U.DataLayer = L.Evented.extend({
var gj = JSON.parse(c) var gj = JSON.parse(c)
callback(gj) callback(gj)
} catch (err) { } catch (err) {
self.map.ui.alert({ content: 'Invalid JSON file: ' + err }) this.map.ui.alert({ content: 'Invalid JSON file: ' + err })
return return
} }
} }
@ -668,24 +661,18 @@ L.U.DataLayer = L.Evented.extend({
}, },
importFromFile: function (f, type) { importFromFile: function (f, type) {
var reader = new FileReader(), var reader = new FileReader()
self = this
type = type || L.Util.detectFileType(f) type = type || L.Util.detectFileType(f)
reader.readAsText(f) reader.readAsText(f)
reader.onload = (e) => { reader.onload = (e) => this.importRaw(e.target.result, type)
self.importRaw(e.target.result, type)
}
}, },
importFromUrl: function (url, type) { importFromUrl: function (url, type) {
url = this.map.localizeUrl(url) url = this.map.localizeUrl(url)
var self = this
this.map.xhr._ajax({ this.map.xhr._ajax({
verb: 'GET', verb: 'GET',
uri: url, uri: url,
callback: function (data) { callback: (data) => this.importRaw(data, type),
self.importRaw(data, type)
},
}) })
}, },
@ -1032,9 +1019,7 @@ L.U.DataLayer = L.Evented.extend({
featuresToGeoJSON: function () { featuresToGeoJSON: function () {
var features = [] var features = []
this.eachLayer((layer) => { this.eachLayer((layer) => features.push(layer.toGeoJSON()))
features.push(layer.toGeoJSON())
})
return features return features
}, },