umap-project 2.3.1__py3-none-any.whl → 2.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/locale/en/LC_MESSAGES/django.po +81 -31
- umap/locale/fr/LC_MESSAGES/django.mo +0 -0
- umap/locale/fr/LC_MESSAGES/django.po +117 -66
- umap/management/commands/run_websocket_server.py +23 -0
- umap/models.py +6 -1
- umap/settings/base.py +11 -3
- umap/static/umap/base.css +64 -184
- umap/static/umap/content.css +3 -2
- umap/static/umap/css/dialog.css +18 -0
- umap/static/umap/css/icon.css +8 -0
- umap/static/umap/css/importers.css +51 -0
- umap/static/umap/css/panel.css +18 -57
- umap/static/umap/css/tooltip.css +59 -0
- umap/static/umap/css/window.css +35 -0
- umap/static/umap/img/16-white.svg +1 -3
- umap/static/umap/img/alert-icon-error.svg +8 -0
- umap/static/umap/img/alert-icon-info.svg +4 -0
- umap/static/umap/img/alert-icon-success.svg +3 -0
- umap/static/umap/img/icon-external-link.svg +3 -0
- umap/static/umap/img/importers/communesfr.svg +5 -0
- umap/static/umap/img/importers/datasets.svg +13 -0
- umap/static/umap/img/importers/geodatamine.svg +10 -0
- umap/static/umap/img/importers/overpass.svg +7 -0
- umap/static/umap/img/importers/random.svg +18 -0
- umap/static/umap/img/importers/random1.svg +4 -0
- umap/static/umap/img/importers/random2.svg +4 -0
- umap/static/umap/img/source/16-white.svg +2 -4
- umap/static/umap/js/components/alerts/alert.css +160 -0
- umap/static/umap/js/components/alerts/alert.js +169 -0
- umap/static/umap/js/components/base.js +54 -0
- umap/static/umap/js/modules/autocomplete.js +347 -0
- umap/static/umap/js/modules/browser.js +6 -6
- umap/static/umap/js/modules/caption.js +5 -4
- umap/static/umap/js/modules/global.js +36 -12
- umap/static/umap/js/modules/help.js +255 -0
- umap/static/umap/js/modules/importer.js +308 -0
- umap/static/umap/js/modules/importers/communesfr.js +44 -0
- umap/static/umap/js/modules/importers/datasets.js +42 -0
- umap/static/umap/js/modules/importers/geodatamine.js +95 -0
- umap/static/umap/js/modules/importers/overpass.js +84 -0
- umap/static/umap/js/modules/request.js +12 -14
- umap/static/umap/js/modules/rules.js +241 -0
- umap/static/umap/js/modules/schema.js +63 -14
- umap/static/umap/js/modules/sync/engine.js +93 -0
- umap/static/umap/js/modules/sync/updaters.js +109 -0
- umap/static/umap/js/modules/sync/websocket.js +25 -0
- umap/static/umap/js/modules/ui/dialog.js +52 -0
- umap/static/umap/js/modules/{panel.js → ui/panel.js} +25 -14
- umap/static/umap/js/modules/ui/tooltip.js +116 -0
- umap/static/umap/js/modules/utils.js +25 -18
- umap/static/umap/js/umap.controls.js +13 -14
- umap/static/umap/js/umap.core.js +1 -324
- umap/static/umap/js/umap.features.js +77 -29
- umap/static/umap/js/umap.forms.js +9 -13
- umap/static/umap/js/umap.js +254 -215
- umap/static/umap/js/umap.layer.js +152 -74
- umap/static/umap/js/umap.permissions.js +5 -9
- umap/static/umap/js/umap.popup.js +1 -1
- umap/static/umap/js/umap.tableeditor.js +8 -8
- umap/static/umap/locale/am_ET.js +51 -16
- umap/static/umap/locale/am_ET.json +51 -16
- umap/static/umap/locale/ar.js +51 -16
- umap/static/umap/locale/ar.json +51 -16
- umap/static/umap/locale/ast.js +51 -16
- umap/static/umap/locale/ast.json +51 -16
- umap/static/umap/locale/bg.js +51 -16
- umap/static/umap/locale/bg.json +51 -16
- umap/static/umap/locale/br.js +55 -20
- umap/static/umap/locale/br.json +55 -20
- umap/static/umap/locale/ca.js +51 -16
- umap/static/umap/locale/ca.json +51 -16
- umap/static/umap/locale/cs_CZ.js +93 -58
- umap/static/umap/locale/cs_CZ.json +93 -58
- umap/static/umap/locale/da.js +51 -16
- umap/static/umap/locale/da.json +51 -16
- umap/static/umap/locale/de.js +56 -21
- umap/static/umap/locale/de.json +56 -21
- umap/static/umap/locale/el.js +51 -16
- umap/static/umap/locale/el.json +51 -16
- umap/static/umap/locale/en.js +52 -16
- umap/static/umap/locale/en.json +52 -16
- umap/static/umap/locale/en_US.json +51 -16
- umap/static/umap/locale/es.js +51 -16
- umap/static/umap/locale/es.json +51 -16
- umap/static/umap/locale/et.js +51 -16
- umap/static/umap/locale/et.json +51 -16
- umap/static/umap/locale/eu.js +51 -16
- umap/static/umap/locale/eu.json +51 -16
- umap/static/umap/locale/fa_IR.js +51 -16
- umap/static/umap/locale/fa_IR.json +51 -16
- umap/static/umap/locale/fi.js +51 -16
- umap/static/umap/locale/fi.json +51 -16
- umap/static/umap/locale/fr.js +61 -25
- umap/static/umap/locale/fr.json +61 -25
- umap/static/umap/locale/gl.js +51 -16
- umap/static/umap/locale/gl.json +51 -16
- umap/static/umap/locale/he.js +51 -16
- umap/static/umap/locale/he.json +51 -16
- umap/static/umap/locale/hr.js +51 -16
- umap/static/umap/locale/hr.json +51 -16
- umap/static/umap/locale/hu.js +51 -16
- umap/static/umap/locale/hu.json +51 -16
- umap/static/umap/locale/id.js +51 -16
- umap/static/umap/locale/id.json +51 -16
- umap/static/umap/locale/is.js +51 -16
- umap/static/umap/locale/is.json +51 -16
- umap/static/umap/locale/it.js +51 -16
- umap/static/umap/locale/it.json +51 -16
- umap/static/umap/locale/ja.js +51 -16
- umap/static/umap/locale/ja.json +51 -16
- umap/static/umap/locale/ko.js +51 -16
- umap/static/umap/locale/ko.json +51 -16
- umap/static/umap/locale/lt.js +51 -16
- umap/static/umap/locale/lt.json +51 -16
- umap/static/umap/locale/ms.js +51 -16
- umap/static/umap/locale/ms.json +51 -16
- umap/static/umap/locale/nl.js +51 -16
- umap/static/umap/locale/nl.json +51 -16
- umap/static/umap/locale/no.js +51 -16
- umap/static/umap/locale/no.json +51 -16
- umap/static/umap/locale/pl.js +93 -58
- umap/static/umap/locale/pl.json +93 -58
- umap/static/umap/locale/pl_PL.json +51 -16
- umap/static/umap/locale/pt.js +215 -180
- umap/static/umap/locale/pt.json +215 -180
- umap/static/umap/locale/pt_BR.js +51 -16
- umap/static/umap/locale/pt_BR.json +51 -16
- umap/static/umap/locale/pt_PT.js +51 -16
- umap/static/umap/locale/pt_PT.json +51 -16
- umap/static/umap/locale/ro.js +51 -16
- umap/static/umap/locale/ro.json +51 -16
- umap/static/umap/locale/ru.js +51 -16
- umap/static/umap/locale/ru.json +51 -16
- umap/static/umap/locale/si.js +51 -16
- umap/static/umap/locale/si.json +51 -16
- umap/static/umap/locale/sk_SK.js +51 -16
- umap/static/umap/locale/sk_SK.json +51 -16
- umap/static/umap/locale/sl.js +51 -16
- umap/static/umap/locale/sl.json +51 -16
- umap/static/umap/locale/sr.js +51 -16
- umap/static/umap/locale/sr.json +51 -16
- umap/static/umap/locale/sv.js +51 -16
- umap/static/umap/locale/sv.json +51 -16
- umap/static/umap/locale/th_TH.js +51 -16
- umap/static/umap/locale/th_TH.json +51 -16
- umap/static/umap/locale/tr.js +51 -16
- umap/static/umap/locale/tr.json +51 -16
- umap/static/umap/locale/uk_UA.js +51 -16
- umap/static/umap/locale/uk_UA.json +51 -16
- umap/static/umap/locale/vi.js +51 -16
- umap/static/umap/locale/vi.json +51 -16
- umap/static/umap/locale/vi_VN.json +51 -16
- umap/static/umap/locale/zh.js +51 -16
- umap/static/umap/locale/zh.json +51 -16
- umap/static/umap/locale/zh_CN.json +51 -16
- umap/static/umap/locale/zh_TW.Big5.json +51 -16
- umap/static/umap/locale/zh_TW.js +51 -16
- umap/static/umap/locale/zh_TW.json +51 -16
- umap/static/umap/map.css +40 -53
- umap/static/umap/unittests/sync.js +105 -0
- umap/static/umap/unittests/utils.js +78 -36
- umap/static/umap/vars.css +19 -1
- umap/static/umap/vendors/formbuilder/Leaflet.FormBuilder.js +2 -2
- umap/templates/umap/components/alerts/alert.html +89 -0
- umap/templates/umap/content.html +4 -3
- umap/templates/umap/css.html +4 -0
- umap/templates/umap/home.html +3 -0
- umap/templates/umap/js.html +0 -3
- umap/templates/umap/map_init.html +2 -8
- umap/templates/umap/messages.html +9 -11
- umap/templates/umap/search.html +3 -0
- umap/tests/base.py +2 -0
- umap/tests/integration/conftest.py +30 -0
- umap/tests/integration/test_anonymous_owned_map.py +8 -13
- umap/tests/integration/test_browser.py +77 -4
- umap/tests/integration/test_conditional_rules.py +201 -0
- umap/tests/integration/test_dashboard.py +1 -1
- umap/tests/integration/test_datalayer.py +2 -3
- umap/tests/integration/test_edit_datalayer.py +4 -4
- umap/tests/integration/test_edit_map.py +1 -1
- umap/tests/integration/test_facets_browser.py +3 -3
- umap/tests/integration/test_import.py +185 -49
- umap/tests/integration/test_map.py +31 -2
- umap/tests/integration/{test_collaborative_editing.py → test_optimistic_merge.py} +7 -7
- umap/tests/integration/test_owned_map.py +1 -1
- umap/tests/integration/test_picto.py +2 -2
- umap/tests/integration/test_statics.py +1 -1
- umap/tests/integration/test_view_marker.py +2 -2
- umap/tests/integration/test_websocket_sync.py +283 -0
- umap/tests/settings.py +5 -0
- umap/tests/test_datalayer_views.py +0 -1
- umap/tests/test_views.py +53 -0
- umap/urls.py +5 -0
- umap/views.py +40 -11
- umap/websocket_server.py +92 -0
- {umap_project-2.3.1.dist-info → umap_project-2.4.0.dist-info}/METADATA +10 -8
- {umap_project-2.3.1.dist-info → umap_project-2.4.0.dist-info}/RECORD +201 -167
- umap/static/umap/js/umap.autocomplete.js +0 -341
- umap/static/umap/js/umap.importer.js +0 -187
- umap/static/umap/js/umap.ui.js +0 -190
- {umap_project-2.3.1.dist-info → umap_project-2.4.0.dist-info}/WHEEL +0 -0
- {umap_project-2.3.1.dist-info → umap_project-2.4.0.dist-info}/entry_points.txt +0 -0
- {umap_project-2.3.1.dist-info → umap_project-2.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
U.AutoComplete = L.Class.extend({
|
|
2
|
-
options: {
|
|
3
|
-
placeholder: 'Start typing...',
|
|
4
|
-
emptyMessage: 'No result',
|
|
5
|
-
allowFree: true,
|
|
6
|
-
minChar: 2,
|
|
7
|
-
maxResults: 5,
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
CACHE: '',
|
|
11
|
-
RESULTS: [],
|
|
12
|
-
|
|
13
|
-
initialize: function (el, options) {
|
|
14
|
-
this.el = el
|
|
15
|
-
const ui = new U.UI(document.querySelector('header'))
|
|
16
|
-
this.server = new U.ServerRequest(ui)
|
|
17
|
-
L.setOptions(this, options)
|
|
18
|
-
let CURRENT = null
|
|
19
|
-
try {
|
|
20
|
-
Object.defineProperty(this, 'CURRENT', {
|
|
21
|
-
get: function () {
|
|
22
|
-
return CURRENT
|
|
23
|
-
},
|
|
24
|
-
set: function (index) {
|
|
25
|
-
if (typeof index === 'object') {
|
|
26
|
-
index = this.resultToIndex(index)
|
|
27
|
-
}
|
|
28
|
-
CURRENT = index
|
|
29
|
-
},
|
|
30
|
-
})
|
|
31
|
-
} catch (e) {
|
|
32
|
-
// Hello IE8
|
|
33
|
-
}
|
|
34
|
-
return this
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
createInput: function () {
|
|
38
|
-
this.input = L.DomUtil.element({
|
|
39
|
-
tagName: 'input',
|
|
40
|
-
type: 'text',
|
|
41
|
-
parent: this.el,
|
|
42
|
-
placeholder: this.options.placeholder,
|
|
43
|
-
autocomplete: 'off',
|
|
44
|
-
className: this.options.className,
|
|
45
|
-
})
|
|
46
|
-
L.DomEvent.on(this.input, 'keydown', this.onKeyDown, this)
|
|
47
|
-
L.DomEvent.on(this.input, 'keyup', this.onKeyUp, this)
|
|
48
|
-
L.DomEvent.on(this.input, 'blur', this.onBlur, this)
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
createContainer: function () {
|
|
52
|
-
this.container = L.DomUtil.element({
|
|
53
|
-
tagName: 'ul',
|
|
54
|
-
parent: document.body,
|
|
55
|
-
className: 'umap-autocomplete',
|
|
56
|
-
})
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
resizeContainer: function () {
|
|
60
|
-
const l = this.getLeft(this.input)
|
|
61
|
-
const t = this.getTop(this.input) + this.input.offsetHeight
|
|
62
|
-
this.container.style.left = `${l}px`
|
|
63
|
-
this.container.style.top = `${t}px`
|
|
64
|
-
const width = this.options.width ? this.options.width : this.input.offsetWidth - 2
|
|
65
|
-
this.container.style.width = `${width}px`
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
onKeyDown: function (e) {
|
|
69
|
-
switch (e.keyCode) {
|
|
70
|
-
case U.Keys.TAB:
|
|
71
|
-
if (this.CURRENT !== null) this.setChoice()
|
|
72
|
-
L.DomEvent.stop(e)
|
|
73
|
-
break
|
|
74
|
-
case U.Keys.ENTER:
|
|
75
|
-
L.DomEvent.stop(e)
|
|
76
|
-
this.setChoice()
|
|
77
|
-
break
|
|
78
|
-
case U.Keys.ESC:
|
|
79
|
-
L.DomEvent.stop(e)
|
|
80
|
-
this.hide()
|
|
81
|
-
break
|
|
82
|
-
case U.Keys.DOWN:
|
|
83
|
-
if (this.RESULTS.length > 0) {
|
|
84
|
-
if (this.CURRENT !== null && this.CURRENT < this.RESULTS.length - 1) {
|
|
85
|
-
// what if one result?
|
|
86
|
-
this.CURRENT++
|
|
87
|
-
this.highlight()
|
|
88
|
-
} else if (this.CURRENT === null) {
|
|
89
|
-
this.CURRENT = 0
|
|
90
|
-
this.highlight()
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
break
|
|
94
|
-
case U.Keys.UP:
|
|
95
|
-
if (this.CURRENT !== null) {
|
|
96
|
-
L.DomEvent.stop(e)
|
|
97
|
-
}
|
|
98
|
-
if (this.RESULTS.length > 0) {
|
|
99
|
-
if (this.CURRENT > 0) {
|
|
100
|
-
this.CURRENT--
|
|
101
|
-
this.highlight()
|
|
102
|
-
} else if (this.CURRENT === 0) {
|
|
103
|
-
this.CURRENT = null
|
|
104
|
-
this.highlight()
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
break
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
onKeyUp: function (e) {
|
|
112
|
-
const special = [
|
|
113
|
-
U.Keys.TAB,
|
|
114
|
-
U.Keys.ENTER,
|
|
115
|
-
U.Keys.LEFT,
|
|
116
|
-
U.Keys.RIGHT,
|
|
117
|
-
U.Keys.DOWN,
|
|
118
|
-
U.Keys.UP,
|
|
119
|
-
U.Keys.APPLE,
|
|
120
|
-
U.Keys.SHIFT,
|
|
121
|
-
U.Keys.ALT,
|
|
122
|
-
U.Keys.CTRL,
|
|
123
|
-
]
|
|
124
|
-
if (special.indexOf(e.keyCode) === -1) {
|
|
125
|
-
this.search()
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
onBlur: function () {
|
|
130
|
-
setTimeout(() => this.hide(), 100)
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
clear: function () {
|
|
134
|
-
this.RESULTS = []
|
|
135
|
-
this.CURRENT = null
|
|
136
|
-
this.CACHE = ''
|
|
137
|
-
this.container.innerHTML = ''
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
hide: function () {
|
|
141
|
-
this.clear()
|
|
142
|
-
this.container.style.display = 'none'
|
|
143
|
-
this.input.value = ''
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
setChoice: function (choice) {
|
|
147
|
-
choice = choice || this.RESULTS[this.CURRENT]
|
|
148
|
-
if (choice) {
|
|
149
|
-
this.input.value = choice.item.label
|
|
150
|
-
this.options.on_select(choice)
|
|
151
|
-
this.displaySelected(choice)
|
|
152
|
-
this.hide()
|
|
153
|
-
if (this.options.callback) {
|
|
154
|
-
L.Util.bind(this.options.callback, this)(choice)
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
search: async function () {
|
|
160
|
-
let val = this.input.value
|
|
161
|
-
if (val.length < this.options.minChar) {
|
|
162
|
-
this.clear()
|
|
163
|
-
return
|
|
164
|
-
}
|
|
165
|
-
if (`${val}` === `${this.CACHE}`) return
|
|
166
|
-
else this.CACHE = val
|
|
167
|
-
val = val.toLowerCase()
|
|
168
|
-
const [{ data }, response] = await this.server.get(
|
|
169
|
-
`/agnocomplete/AutocompleteUser/?q=${encodeURIComponent(val)}`
|
|
170
|
-
)
|
|
171
|
-
this.handleResults(data)
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
createResult: function (item) {
|
|
175
|
-
const el = L.DomUtil.element({
|
|
176
|
-
tagName: 'li',
|
|
177
|
-
parent: this.container,
|
|
178
|
-
textContent: item.label,
|
|
179
|
-
})
|
|
180
|
-
const result = {
|
|
181
|
-
item: item,
|
|
182
|
-
el: el,
|
|
183
|
-
}
|
|
184
|
-
L.DomEvent.on(
|
|
185
|
-
el,
|
|
186
|
-
'mouseover',
|
|
187
|
-
function () {
|
|
188
|
-
this.CURRENT = result
|
|
189
|
-
this.highlight()
|
|
190
|
-
},
|
|
191
|
-
this
|
|
192
|
-
)
|
|
193
|
-
L.DomEvent.on(
|
|
194
|
-
el,
|
|
195
|
-
'mousedown',
|
|
196
|
-
function () {
|
|
197
|
-
this.setChoice()
|
|
198
|
-
},
|
|
199
|
-
this
|
|
200
|
-
)
|
|
201
|
-
return result
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
resultToIndex: function (result) {
|
|
205
|
-
let out = null
|
|
206
|
-
this.forEach(this.RESULTS, (item, index) => {
|
|
207
|
-
if (item.item.value == result.item.value) {
|
|
208
|
-
out = index
|
|
209
|
-
return
|
|
210
|
-
}
|
|
211
|
-
})
|
|
212
|
-
return out
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
handleResults: function (data) {
|
|
216
|
-
this.clear()
|
|
217
|
-
this.container.style.display = 'block'
|
|
218
|
-
this.resizeContainer()
|
|
219
|
-
this.forEach(data, (item) => {
|
|
220
|
-
this.RESULTS.push(this.createResult(item))
|
|
221
|
-
})
|
|
222
|
-
this.CURRENT = 0
|
|
223
|
-
this.highlight()
|
|
224
|
-
//TODO manage no results
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
highlight: function () {
|
|
228
|
-
this.forEach(this.RESULTS, (result, index) => {
|
|
229
|
-
if (index === this.CURRENT) L.DomUtil.addClass(result.el, 'on')
|
|
230
|
-
else L.DomUtil.removeClass(result.el, 'on')
|
|
231
|
-
})
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
getLeft: function (el) {
|
|
235
|
-
let tmp = el.offsetLeft
|
|
236
|
-
el = el.offsetParent
|
|
237
|
-
while (el) {
|
|
238
|
-
tmp += el.offsetLeft
|
|
239
|
-
el = el.offsetParent
|
|
240
|
-
}
|
|
241
|
-
return tmp
|
|
242
|
-
},
|
|
243
|
-
|
|
244
|
-
getTop: function (el) {
|
|
245
|
-
let tmp = el.offsetTop
|
|
246
|
-
el = el.offsetParent
|
|
247
|
-
while (el) {
|
|
248
|
-
tmp += el.offsetTop
|
|
249
|
-
el = el.offsetParent
|
|
250
|
-
}
|
|
251
|
-
return tmp
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
forEach: function (els, callback) {
|
|
255
|
-
Array.prototype.forEach.call(els, callback)
|
|
256
|
-
},
|
|
257
|
-
})
|
|
258
|
-
|
|
259
|
-
U.AutoComplete.Ajax = U.AutoComplete.extend({
|
|
260
|
-
initialize: function (el, options) {
|
|
261
|
-
U.AutoComplete.prototype.initialize.call(this, el, options)
|
|
262
|
-
if (!this.el) return this
|
|
263
|
-
this.createInput()
|
|
264
|
-
this.createContainer()
|
|
265
|
-
this.selected_container = this.initSelectedContainer()
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
optionToResult: function (option) {
|
|
269
|
-
return {
|
|
270
|
-
value: option.value,
|
|
271
|
-
label: option.innerHTML,
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
})
|
|
275
|
-
|
|
276
|
-
U.AutoComplete.Ajax.SelectMultiple = U.AutoComplete.Ajax.extend({
|
|
277
|
-
initSelectedContainer: function () {
|
|
278
|
-
return L.DomUtil.after(
|
|
279
|
-
this.input,
|
|
280
|
-
L.DomUtil.element({ tagName: 'ul', className: 'umap-multiresult' })
|
|
281
|
-
)
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
displaySelected: function (result) {
|
|
285
|
-
const result_el = L.DomUtil.element({
|
|
286
|
-
tagName: 'li',
|
|
287
|
-
parent: this.selected_container,
|
|
288
|
-
})
|
|
289
|
-
result_el.textContent = result.item.label
|
|
290
|
-
const close = L.DomUtil.element({
|
|
291
|
-
tagName: 'span',
|
|
292
|
-
parent: result_el,
|
|
293
|
-
className: 'close',
|
|
294
|
-
textContent: '×',
|
|
295
|
-
})
|
|
296
|
-
L.DomEvent.on(
|
|
297
|
-
close,
|
|
298
|
-
'click',
|
|
299
|
-
function () {
|
|
300
|
-
this.selected_container.removeChild(result_el)
|
|
301
|
-
this.options.on_unselect(result)
|
|
302
|
-
},
|
|
303
|
-
this
|
|
304
|
-
)
|
|
305
|
-
this.hide()
|
|
306
|
-
},
|
|
307
|
-
})
|
|
308
|
-
|
|
309
|
-
U.AutoComplete.Ajax.Select = U.AutoComplete.Ajax.extend({
|
|
310
|
-
initSelectedContainer: function () {
|
|
311
|
-
return L.DomUtil.after(
|
|
312
|
-
this.input,
|
|
313
|
-
L.DomUtil.element({ tagName: 'div', className: 'umap-singleresult' })
|
|
314
|
-
)
|
|
315
|
-
},
|
|
316
|
-
|
|
317
|
-
displaySelected: function (result) {
|
|
318
|
-
const result_el = L.DomUtil.element({
|
|
319
|
-
tagName: 'div',
|
|
320
|
-
parent: this.selected_container,
|
|
321
|
-
})
|
|
322
|
-
result_el.textContent = result.item.label
|
|
323
|
-
const close = L.DomUtil.element({
|
|
324
|
-
tagName: 'span',
|
|
325
|
-
parent: result_el,
|
|
326
|
-
className: 'close',
|
|
327
|
-
textContent: '×',
|
|
328
|
-
})
|
|
329
|
-
this.input.style.display = 'none'
|
|
330
|
-
L.DomEvent.on(
|
|
331
|
-
close,
|
|
332
|
-
'click',
|
|
333
|
-
function () {
|
|
334
|
-
this.selected_container.innerHTML = ''
|
|
335
|
-
this.input.style.display = 'block'
|
|
336
|
-
},
|
|
337
|
-
this
|
|
338
|
-
)
|
|
339
|
-
this.hide()
|
|
340
|
-
},
|
|
341
|
-
})
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
U.Importer = L.Class.extend({
|
|
2
|
-
TYPES: ['geojson', 'csv', 'gpx', 'kml', 'osm', 'georss', 'umap'],
|
|
3
|
-
initialize: function (map) {
|
|
4
|
-
this.map = map
|
|
5
|
-
this.presets = map.options.importPresets
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
build: function () {
|
|
9
|
-
this.container = L.DomUtil.create('div', 'umap-upload')
|
|
10
|
-
this.title = L.DomUtil.createTitle(
|
|
11
|
-
this.container,
|
|
12
|
-
L._('Import data'),
|
|
13
|
-
'icon-upload'
|
|
14
|
-
)
|
|
15
|
-
this.presetBox = L.DomUtil.create('div', 'formbox', this.container)
|
|
16
|
-
this.presetSelect = L.DomUtil.create('select', '', this.presetBox)
|
|
17
|
-
this.fileBox = L.DomUtil.create('div', 'formbox', this.container)
|
|
18
|
-
this.fileInput = L.DomUtil.element({
|
|
19
|
-
tagName: 'input',
|
|
20
|
-
type: 'file',
|
|
21
|
-
parent: this.fileBox,
|
|
22
|
-
multiple: 'multiple',
|
|
23
|
-
autofocus: true,
|
|
24
|
-
})
|
|
25
|
-
this.urlInput = L.DomUtil.element({
|
|
26
|
-
tagName: 'input',
|
|
27
|
-
type: 'text',
|
|
28
|
-
parent: this.container,
|
|
29
|
-
placeholder: L._('Provide an URL here'),
|
|
30
|
-
})
|
|
31
|
-
this.rawInput = L.DomUtil.element({
|
|
32
|
-
tagName: 'textarea',
|
|
33
|
-
parent: this.container,
|
|
34
|
-
placeholder: L._('Paste your data here'),
|
|
35
|
-
})
|
|
36
|
-
this.typeLabel = L.DomUtil.add(
|
|
37
|
-
'label',
|
|
38
|
-
'',
|
|
39
|
-
this.container,
|
|
40
|
-
L._('Choose the format of the data to import')
|
|
41
|
-
)
|
|
42
|
-
this.layerLabel = L.DomUtil.add(
|
|
43
|
-
'label',
|
|
44
|
-
'',
|
|
45
|
-
this.container,
|
|
46
|
-
L._('Choose the layer to import in')
|
|
47
|
-
)
|
|
48
|
-
this.clearLabel = L.DomUtil.element({
|
|
49
|
-
tagName: 'label',
|
|
50
|
-
parent: this.container,
|
|
51
|
-
textContent: L._('Replace layer content'),
|
|
52
|
-
for: 'datalayer-clear-check',
|
|
53
|
-
})
|
|
54
|
-
this.submitInput = L.DomUtil.element({
|
|
55
|
-
tagName: 'input',
|
|
56
|
-
type: 'button',
|
|
57
|
-
parent: this.container,
|
|
58
|
-
value: L._('Import'),
|
|
59
|
-
className: 'button',
|
|
60
|
-
})
|
|
61
|
-
this.map.help.button(this.typeLabel, 'importFormats')
|
|
62
|
-
this.typeInput = L.DomUtil.element({
|
|
63
|
-
tagName: 'select',
|
|
64
|
-
name: 'format',
|
|
65
|
-
parent: this.typeLabel,
|
|
66
|
-
})
|
|
67
|
-
this.layerInput = L.DomUtil.element({
|
|
68
|
-
tagName: 'select',
|
|
69
|
-
name: 'datalayer',
|
|
70
|
-
parent: this.layerLabel,
|
|
71
|
-
})
|
|
72
|
-
this.clearFlag = L.DomUtil.element({
|
|
73
|
-
tagName: 'input',
|
|
74
|
-
type: 'checkbox',
|
|
75
|
-
name: 'clear',
|
|
76
|
-
id: 'datalayer-clear-check',
|
|
77
|
-
parent: this.clearLabel,
|
|
78
|
-
})
|
|
79
|
-
L.DomUtil.element({
|
|
80
|
-
tagName: 'option',
|
|
81
|
-
value: '',
|
|
82
|
-
textContent: L._('Choose the data format'),
|
|
83
|
-
parent: this.typeInput,
|
|
84
|
-
})
|
|
85
|
-
for (let i = 0; i < this.TYPES.length; i++) {
|
|
86
|
-
option = L.DomUtil.create('option', '', this.typeInput)
|
|
87
|
-
option.value = option.textContent = this.TYPES[i]
|
|
88
|
-
}
|
|
89
|
-
if (this.presets.length) {
|
|
90
|
-
const noPreset = L.DomUtil.create('option', '', this.presetSelect)
|
|
91
|
-
noPreset.value = noPreset.textContent = L._('Choose a preset')
|
|
92
|
-
for (let j = 0; j < this.presets.length; j++) {
|
|
93
|
-
option = L.DomUtil.create('option', '', presetSelect)
|
|
94
|
-
option.value = this.presets[j].url
|
|
95
|
-
option.textContent = this.presets[j].label
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
this.presetBox.style.display = 'none'
|
|
99
|
-
}
|
|
100
|
-
L.DomEvent.on(this.submitInput, 'click', this.submit, this)
|
|
101
|
-
L.DomEvent.on(
|
|
102
|
-
this.fileInput,
|
|
103
|
-
'change',
|
|
104
|
-
(e) => {
|
|
105
|
-
let type = '',
|
|
106
|
-
newType
|
|
107
|
-
for (let i = 0; i < e.target.files.length; i++) {
|
|
108
|
-
newType = U.Utils.detectFileType(e.target.files[i])
|
|
109
|
-
if (!type && newType) type = newType
|
|
110
|
-
if (type && newType !== type) {
|
|
111
|
-
type = ''
|
|
112
|
-
break
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
this.typeInput.value = type
|
|
116
|
-
},
|
|
117
|
-
this
|
|
118
|
-
)
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
open: function () {
|
|
122
|
-
if (!this.container) this.build()
|
|
123
|
-
const onLoad = this.map.editPanel.open({ content: this.container })
|
|
124
|
-
onLoad.then(() => {
|
|
125
|
-
this.fileInput.value = null
|
|
126
|
-
this.layerInput.innerHTML = ''
|
|
127
|
-
let option
|
|
128
|
-
this.map.eachDataLayerReverse((datalayer) => {
|
|
129
|
-
if (datalayer.isLoaded() && !datalayer.isRemoteLayer()) {
|
|
130
|
-
const id = L.stamp(datalayer)
|
|
131
|
-
option = L.DomUtil.add('option', '', this.layerInput, datalayer.options.name)
|
|
132
|
-
option.value = id
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
L.DomUtil.element({
|
|
136
|
-
tagName: 'option',
|
|
137
|
-
value: '',
|
|
138
|
-
textContent: L._('Import in a new layer'),
|
|
139
|
-
parent: this.layerInput,
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
openFiles: function () {
|
|
145
|
-
this.open()
|
|
146
|
-
this.fileInput.showPicker()
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
submit: function () {
|
|
150
|
-
let type = this.typeInput.value
|
|
151
|
-
const layerId = this.layerInput[this.layerInput.selectedIndex].value
|
|
152
|
-
let layer
|
|
153
|
-
if (type === 'umap') {
|
|
154
|
-
this.map.once('postsync', this.map._setDefaultCenter)
|
|
155
|
-
}
|
|
156
|
-
if (layerId) layer = this.map.datalayers[layerId]
|
|
157
|
-
if (layer && this.clearFlag.checked) layer.empty()
|
|
158
|
-
if (this.fileInput.files.length) {
|
|
159
|
-
for (let i = 0, file; (file = this.fileInput.files[i]); i++) {
|
|
160
|
-
this.map.processFileToImport(file, layer, type)
|
|
161
|
-
}
|
|
162
|
-
} else {
|
|
163
|
-
if (!type)
|
|
164
|
-
return this.map.ui.alert({
|
|
165
|
-
content: L._('Please choose a format'),
|
|
166
|
-
level: 'error',
|
|
167
|
-
})
|
|
168
|
-
if (this.rawInput.value && type === 'umap') {
|
|
169
|
-
try {
|
|
170
|
-
this.map.importRaw(this.rawInput.value, type)
|
|
171
|
-
} catch (e) {
|
|
172
|
-
this.ui.alert({ content: L._('Invalid umap data'), level: 'error' })
|
|
173
|
-
console.error(e)
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
if (!layer) layer = this.map.createDataLayer()
|
|
177
|
-
if (this.rawInput.value) layer.importRaw(this.rawInput.value, type)
|
|
178
|
-
else if (this.urlInput.value) layer.importFromUrl(this.urlInput.value, type)
|
|
179
|
-
else if (this.presetSelect.selectedIndex > 0)
|
|
180
|
-
layer.importFromUrl(
|
|
181
|
-
this.presetSelect[this.presetSelect.selectedIndex].value,
|
|
182
|
-
type
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
})
|
umap/static/umap/js/umap.ui.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Modals
|
|
3
|
-
*/
|
|
4
|
-
U.UI = L.Evented.extend({
|
|
5
|
-
ALERTS: Array(),
|
|
6
|
-
ALERT_ID: null,
|
|
7
|
-
TOOLTIP_ID: null,
|
|
8
|
-
|
|
9
|
-
initialize: function (parent) {
|
|
10
|
-
this.parent = parent
|
|
11
|
-
this.container = L.DomUtil.create('div', 'leaflet-ui-container', this.parent)
|
|
12
|
-
L.DomEvent.disableClickPropagation(this.container)
|
|
13
|
-
L.DomEvent.on(this.container, 'contextmenu', L.DomEvent.stopPropagation) // Do not activate our custom context menu.
|
|
14
|
-
L.DomEvent.on(this.container, 'wheel', L.DomEvent.stopPropagation)
|
|
15
|
-
L.DomEvent.on(this.container, 'MozMousePixelScroll', L.DomEvent.stopPropagation)
|
|
16
|
-
this._alert = L.DomUtil.create('div', 'with-transition', this.container)
|
|
17
|
-
this._alert.id = 'umap-alert-container'
|
|
18
|
-
this._tooltip = L.DomUtil.create('div', '', this.container)
|
|
19
|
-
this._tooltip.id = 'umap-tooltip-container'
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
alert: function (e) {
|
|
23
|
-
if (L.DomUtil.hasClass(this.parent, 'umap-alert')) this.ALERTS.push(e)
|
|
24
|
-
else this.popAlert(e)
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
popAlert: function (e) {
|
|
28
|
-
if (!e) {
|
|
29
|
-
if (this.ALERTS.length) e = this.ALERTS.pop()
|
|
30
|
-
else return
|
|
31
|
-
}
|
|
32
|
-
let timeoutID
|
|
33
|
-
const level_class = e.level && e.level == 'info' ? 'info' : 'error'
|
|
34
|
-
this._alert.innerHTML = ''
|
|
35
|
-
L.DomUtil.addClass(this.parent, 'umap-alert')
|
|
36
|
-
L.DomUtil.addClass(this._alert, level_class)
|
|
37
|
-
const close = () => {
|
|
38
|
-
if (timeoutID && timeoutID !== this.ALERT_ID) {
|
|
39
|
-
return
|
|
40
|
-
} // Another alert has been forced
|
|
41
|
-
this._alert.innerHTML = ''
|
|
42
|
-
L.DomUtil.removeClass(this.parent, 'umap-alert')
|
|
43
|
-
L.DomUtil.removeClass(this._alert, level_class)
|
|
44
|
-
if (timeoutID) window.clearTimeout(timeoutID)
|
|
45
|
-
this.popAlert()
|
|
46
|
-
}
|
|
47
|
-
const closeButton = L.DomUtil.createButton(
|
|
48
|
-
'umap-close-link',
|
|
49
|
-
this._alert,
|
|
50
|
-
'',
|
|
51
|
-
close,
|
|
52
|
-
this
|
|
53
|
-
)
|
|
54
|
-
L.DomUtil.create('i', 'umap-close-icon', closeButton)
|
|
55
|
-
const label = L.DomUtil.create('span', '', closeButton)
|
|
56
|
-
label.title = label.textContent = L._('Close')
|
|
57
|
-
L.DomUtil.element({ tagName: 'div', innerHTML: e.content, parent: this._alert })
|
|
58
|
-
if (e.actions) {
|
|
59
|
-
let action, el, input
|
|
60
|
-
const form = L.DomUtil.create('div', 'umap-alert-actions', this._alert)
|
|
61
|
-
for (let i = 0; i < e.actions.length; i++) {
|
|
62
|
-
action = e.actions[i]
|
|
63
|
-
if (action.input) {
|
|
64
|
-
input = L.DomUtil.element({
|
|
65
|
-
tagName: 'input',
|
|
66
|
-
parent: form,
|
|
67
|
-
className: 'umap-alert-input',
|
|
68
|
-
placeholder: action.input,
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
el = L.DomUtil.createButton(
|
|
72
|
-
'umap-action',
|
|
73
|
-
form,
|
|
74
|
-
action.label,
|
|
75
|
-
action.callback,
|
|
76
|
-
action.callbackContext || this.map
|
|
77
|
-
)
|
|
78
|
-
L.DomEvent.on(el, 'click', close, this)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (e.duration !== Infinity) {
|
|
82
|
-
this.ALERT_ID = timeoutID = window.setTimeout(
|
|
83
|
-
L.bind(close, this),
|
|
84
|
-
e.duration || 3000
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
tooltip: function (opts) {
|
|
90
|
-
function showIt() {
|
|
91
|
-
if (opts.anchor && opts.position === 'top') {
|
|
92
|
-
this.anchorTooltipTop(opts.anchor)
|
|
93
|
-
} else if (opts.anchor && opts.position === 'left') {
|
|
94
|
-
this.anchorTooltipLeft(opts.anchor)
|
|
95
|
-
} else if (opts.anchor && opts.position === 'bottom') {
|
|
96
|
-
this.anchorTooltipBottom(opts.anchor)
|
|
97
|
-
} else {
|
|
98
|
-
this.anchorTooltipAbsolute()
|
|
99
|
-
}
|
|
100
|
-
L.DomUtil.addClass(this.parent, 'umap-tooltip')
|
|
101
|
-
this._tooltip.innerHTML = U.Utils.escapeHTML(opts.content)
|
|
102
|
-
}
|
|
103
|
-
this.TOOLTIP_ID = window.setTimeout(L.bind(showIt, this), opts.delay || 0)
|
|
104
|
-
const id = this.TOOLTIP_ID
|
|
105
|
-
function closeIt() {
|
|
106
|
-
this.closeTooltip(id)
|
|
107
|
-
}
|
|
108
|
-
if (opts.anchor) {
|
|
109
|
-
L.DomEvent.once(opts.anchor, 'mouseout', closeIt, this)
|
|
110
|
-
}
|
|
111
|
-
if (opts.duration !== Infinity) {
|
|
112
|
-
window.setTimeout(L.bind(closeIt, this), opts.duration || 3000)
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
anchorTooltipAbsolute: function () {
|
|
117
|
-
this._tooltip.className = ''
|
|
118
|
-
const left =
|
|
119
|
-
this.parent.offsetLeft +
|
|
120
|
-
this.parent.clientWidth / 2 -
|
|
121
|
-
this._tooltip.clientWidth / 2,
|
|
122
|
-
top = this.parent.offsetTop + 75
|
|
123
|
-
this.setTooltipPosition({ top: top, left: left })
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
anchorTooltipTop: function (el) {
|
|
127
|
-
this._tooltip.className = 'tooltip-top'
|
|
128
|
-
const coords = this.getPosition(el)
|
|
129
|
-
this.setTooltipPosition({
|
|
130
|
-
left: coords.left - 10,
|
|
131
|
-
bottom: this.getDocHeight() - coords.top + 11,
|
|
132
|
-
})
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
anchorTooltipBottom: function (el) {
|
|
136
|
-
this._tooltip.className = 'tooltip-bottom'
|
|
137
|
-
const coords = this.getPosition(el)
|
|
138
|
-
this.setTooltipPosition({
|
|
139
|
-
left: coords.left,
|
|
140
|
-
top: coords.bottom + 11,
|
|
141
|
-
})
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
anchorTooltipLeft: function (el) {
|
|
145
|
-
this._tooltip.className = 'tooltip-left'
|
|
146
|
-
const coords = this.getPosition(el)
|
|
147
|
-
this.setTooltipPosition({
|
|
148
|
-
top: coords.top,
|
|
149
|
-
right: document.documentElement.offsetWidth - coords.left + 11,
|
|
150
|
-
})
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
closeTooltip: function (id) {
|
|
154
|
-
// Clear timetout even if a new tooltip has been added
|
|
155
|
-
// in the meantime. Eg. after a mouseout from the anchor.
|
|
156
|
-
window.clearTimeout(id)
|
|
157
|
-
if (id && id !== this.TOOLTIP_ID) return
|
|
158
|
-
this._tooltip.className = ''
|
|
159
|
-
this._tooltip.innerHTML = ''
|
|
160
|
-
this.setTooltipPosition({})
|
|
161
|
-
L.DomUtil.removeClass(this.parent, 'umap-tooltip')
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
getPosition: function (el) {
|
|
165
|
-
return el.getBoundingClientRect()
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
setTooltipPosition: function (coords) {
|
|
169
|
-
if (coords.left) this._tooltip.style.left = `${coords.left}px`
|
|
170
|
-
else this._tooltip.style.left = 'initial'
|
|
171
|
-
if (coords.right) this._tooltip.style.right = `${coords.right}px`
|
|
172
|
-
else this._tooltip.style.right = 'initial'
|
|
173
|
-
if (coords.top) this._tooltip.style.top = `${coords.top}px`
|
|
174
|
-
else this._tooltip.style.top = 'initial'
|
|
175
|
-
if (coords.bottom) this._tooltip.style.bottom = `${coords.bottom}px`
|
|
176
|
-
else this._tooltip.style.bottom = 'initial'
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
getDocHeight: function () {
|
|
180
|
-
const D = document
|
|
181
|
-
return Math.max(
|
|
182
|
-
D.body.scrollHeight,
|
|
183
|
-
D.documentElement.scrollHeight,
|
|
184
|
-
D.body.offsetHeight,
|
|
185
|
-
D.documentElement.offsetHeight,
|
|
186
|
-
D.body.clientHeight,
|
|
187
|
-
D.documentElement.clientHeight
|
|
188
|
-
)
|
|
189
|
-
},
|
|
190
|
-
})
|
|
File without changes
|
|
File without changes
|