umap-project 2.4.1__py3-none-any.whl → 2.5.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.
Files changed (199) hide show
  1. umap/__init__.py +1 -1
  2. umap/locale/el/LC_MESSAGES/django.mo +0 -0
  3. umap/locale/el/LC_MESSAGES/django.po +145 -90
  4. umap/locale/en/LC_MESSAGES/django.po +13 -13
  5. umap/locale/eu/LC_MESSAGES/django.mo +0 -0
  6. umap/locale/eu/LC_MESSAGES/django.po +145 -89
  7. umap/locale/hu/LC_MESSAGES/django.mo +0 -0
  8. umap/locale/hu/LC_MESSAGES/django.po +100 -50
  9. umap/static/umap/base.css +5 -2
  10. umap/static/umap/content.css +2 -2
  11. umap/static/umap/css/contextmenu.css +11 -0
  12. umap/static/umap/css/dialog.css +25 -4
  13. umap/static/umap/css/importers.css +2 -0
  14. umap/static/umap/css/panel.css +6 -4
  15. umap/static/umap/css/slideshow.css +69 -0
  16. umap/static/umap/css/tableeditor.css +69 -0
  17. umap/static/umap/css/tooltip.css +3 -3
  18. umap/static/umap/img/16-white.svg +4 -0
  19. umap/static/umap/img/source/16-white.svg +5 -1
  20. umap/static/umap/js/components/alerts/alert.css +11 -11
  21. umap/static/umap/js/components/alerts/alert.js +1 -1
  22. umap/static/umap/js/modules/autocomplete.js +27 -5
  23. umap/static/umap/js/modules/browser.js +20 -14
  24. umap/static/umap/js/modules/caption.js +4 -4
  25. umap/static/umap/js/modules/dompurify.js +2 -3
  26. umap/static/umap/js/modules/facets.js +53 -17
  27. umap/static/umap/js/modules/formatter.js +153 -0
  28. umap/static/umap/js/modules/global.js +25 -16
  29. umap/static/umap/js/modules/help.js +26 -26
  30. umap/static/umap/js/modules/importer.js +10 -10
  31. umap/static/umap/js/modules/importers/communesfr.js +3 -1
  32. umap/static/umap/js/modules/importers/datasets.js +8 -6
  33. umap/static/umap/js/modules/importers/geodatamine.js +14 -14
  34. umap/static/umap/js/modules/importers/overpass.js +19 -15
  35. umap/static/umap/js/modules/orderable.js +2 -2
  36. umap/static/umap/js/modules/request.js +1 -1
  37. umap/static/umap/js/modules/rules.js +26 -11
  38. umap/static/umap/js/modules/schema.js +16 -12
  39. umap/static/umap/js/{umap.share.js → modules/share.js} +58 -103
  40. umap/static/umap/js/modules/slideshow.js +141 -0
  41. umap/static/umap/js/modules/sync/engine.js +3 -3
  42. umap/static/umap/js/modules/sync/updaters.js +10 -11
  43. umap/static/umap/js/modules/sync/websocket.js +1 -1
  44. umap/static/umap/js/modules/tableeditor.js +329 -0
  45. umap/static/umap/js/modules/ui/base.js +93 -0
  46. umap/static/umap/js/modules/ui/contextmenu.js +50 -0
  47. umap/static/umap/js/modules/ui/dialog.js +169 -31
  48. umap/static/umap/js/modules/ui/panel.js +7 -5
  49. umap/static/umap/js/modules/ui/tooltip.js +7 -77
  50. umap/static/umap/js/modules/urls.js +1 -2
  51. umap/static/umap/js/modules/utils.js +36 -16
  52. umap/static/umap/js/umap.controls.js +27 -29
  53. umap/static/umap/js/umap.core.js +19 -15
  54. umap/static/umap/js/umap.datalayer.permissions.js +15 -18
  55. umap/static/umap/js/umap.features.js +113 -131
  56. umap/static/umap/js/umap.forms.js +203 -228
  57. umap/static/umap/js/umap.icon.js +17 -22
  58. umap/static/umap/js/umap.js +117 -107
  59. umap/static/umap/js/umap.layer.js +374 -324
  60. umap/static/umap/js/umap.permissions.js +7 -10
  61. umap/static/umap/js/umap.popup.js +20 -20
  62. umap/static/umap/locale/am_ET.js +22 -5
  63. umap/static/umap/locale/am_ET.json +22 -5
  64. umap/static/umap/locale/ar.js +22 -5
  65. umap/static/umap/locale/ar.json +22 -5
  66. umap/static/umap/locale/ast.js +22 -5
  67. umap/static/umap/locale/ast.json +22 -5
  68. umap/static/umap/locale/bg.js +22 -5
  69. umap/static/umap/locale/bg.json +22 -5
  70. umap/static/umap/locale/br.js +22 -5
  71. umap/static/umap/locale/br.json +22 -5
  72. umap/static/umap/locale/ca.js +56 -39
  73. umap/static/umap/locale/ca.json +56 -39
  74. umap/static/umap/locale/cs_CZ.js +22 -5
  75. umap/static/umap/locale/cs_CZ.json +22 -5
  76. umap/static/umap/locale/da.js +22 -5
  77. umap/static/umap/locale/da.json +22 -5
  78. umap/static/umap/locale/de.js +22 -5
  79. umap/static/umap/locale/de.json +22 -5
  80. umap/static/umap/locale/el.js +27 -10
  81. umap/static/umap/locale/el.json +27 -10
  82. umap/static/umap/locale/en.js +22 -6
  83. umap/static/umap/locale/en.json +22 -6
  84. umap/static/umap/locale/en_US.json +22 -5
  85. umap/static/umap/locale/es.js +22 -6
  86. umap/static/umap/locale/es.json +22 -6
  87. umap/static/umap/locale/et.js +22 -5
  88. umap/static/umap/locale/et.json +22 -5
  89. umap/static/umap/locale/eu.js +167 -150
  90. umap/static/umap/locale/eu.json +167 -150
  91. umap/static/umap/locale/fa_IR.js +22 -5
  92. umap/static/umap/locale/fa_IR.json +22 -5
  93. umap/static/umap/locale/fi.js +22 -5
  94. umap/static/umap/locale/fi.json +22 -5
  95. umap/static/umap/locale/fr.js +22 -6
  96. umap/static/umap/locale/fr.json +22 -6
  97. umap/static/umap/locale/gl.js +22 -5
  98. umap/static/umap/locale/gl.json +22 -5
  99. umap/static/umap/locale/he.js +22 -5
  100. umap/static/umap/locale/he.json +22 -5
  101. umap/static/umap/locale/hr.js +22 -5
  102. umap/static/umap/locale/hr.json +22 -5
  103. umap/static/umap/locale/hu.js +89 -72
  104. umap/static/umap/locale/hu.json +89 -72
  105. umap/static/umap/locale/id.js +22 -5
  106. umap/static/umap/locale/id.json +22 -5
  107. umap/static/umap/locale/is.js +22 -5
  108. umap/static/umap/locale/is.json +22 -5
  109. umap/static/umap/locale/it.js +22 -5
  110. umap/static/umap/locale/it.json +22 -5
  111. umap/static/umap/locale/ja.js +22 -5
  112. umap/static/umap/locale/ja.json +22 -5
  113. umap/static/umap/locale/ko.js +22 -5
  114. umap/static/umap/locale/ko.json +22 -5
  115. umap/static/umap/locale/lt.js +22 -5
  116. umap/static/umap/locale/lt.json +22 -5
  117. umap/static/umap/locale/ms.js +22 -5
  118. umap/static/umap/locale/ms.json +22 -5
  119. umap/static/umap/locale/nl.js +22 -5
  120. umap/static/umap/locale/nl.json +22 -5
  121. umap/static/umap/locale/no.js +22 -5
  122. umap/static/umap/locale/no.json +22 -5
  123. umap/static/umap/locale/pl.js +22 -5
  124. umap/static/umap/locale/pl.json +22 -5
  125. umap/static/umap/locale/pl_PL.json +22 -5
  126. umap/static/umap/locale/pt.js +22 -6
  127. umap/static/umap/locale/pt.json +22 -6
  128. umap/static/umap/locale/pt_BR.js +22 -5
  129. umap/static/umap/locale/pt_BR.json +22 -5
  130. umap/static/umap/locale/pt_PT.js +22 -5
  131. umap/static/umap/locale/pt_PT.json +22 -5
  132. umap/static/umap/locale/ro.js +22 -5
  133. umap/static/umap/locale/ro.json +22 -5
  134. umap/static/umap/locale/ru.js +22 -5
  135. umap/static/umap/locale/ru.json +22 -5
  136. umap/static/umap/locale/sk_SK.js +22 -5
  137. umap/static/umap/locale/sk_SK.json +22 -5
  138. umap/static/umap/locale/sl.js +22 -5
  139. umap/static/umap/locale/sl.json +22 -5
  140. umap/static/umap/locale/sr.js +22 -5
  141. umap/static/umap/locale/sr.json +22 -5
  142. umap/static/umap/locale/sv.js +22 -5
  143. umap/static/umap/locale/sv.json +22 -5
  144. umap/static/umap/locale/th_TH.js +22 -5
  145. umap/static/umap/locale/th_TH.json +22 -5
  146. umap/static/umap/locale/tr.js +22 -5
  147. umap/static/umap/locale/tr.json +22 -5
  148. umap/static/umap/locale/uk_UA.js +22 -5
  149. umap/static/umap/locale/uk_UA.json +22 -5
  150. umap/static/umap/locale/vi.js +22 -5
  151. umap/static/umap/locale/vi.json +22 -5
  152. umap/static/umap/locale/vi_VN.json +22 -5
  153. umap/static/umap/locale/zh.js +22 -5
  154. umap/static/umap/locale/zh.json +22 -5
  155. umap/static/umap/locale/zh_CN.json +22 -5
  156. umap/static/umap/locale/zh_TW.Big5.json +22 -5
  157. umap/static/umap/locale/zh_TW.js +22 -5
  158. umap/static/umap/locale/zh_TW.json +22 -5
  159. umap/static/umap/map.css +9 -153
  160. umap/static/umap/vars.css +15 -0
  161. umap/static/umap/vendors/dompurify/purify.es.js +5 -59
  162. umap/static/umap/vendors/dompurify/purify.es.mjs.map +1 -1
  163. umap/static/umap/vendors/formbuilder/Leaflet.FormBuilder.js +410 -428
  164. umap/static/umap/vendors/geojson-to-gpx/index.js +155 -0
  165. umap/static/umap/vendors/osmtogeojson/osmtogeojson.js +1 -2
  166. umap/static/umap/vendors/togeojson/togeojson.es.js +1109 -0
  167. umap/static/umap/vendors/togeojson/{togeojson.umd.js.map → togeojson.es.mjs.map} +1 -1
  168. umap/static/umap/vendors/tokml/tokml.es.js +895 -0
  169. umap/static/umap/vendors/tokml/tokml.es.mjs.map +1 -0
  170. umap/storage.py +6 -2
  171. umap/templates/umap/components/alerts/alert.html +3 -3
  172. umap/templates/umap/css.html +3 -0
  173. umap/templates/umap/js.html +0 -6
  174. umap/tests/fixtures/categorized_highway.geojson +1 -0
  175. umap/tests/fixtures/test_import_osm_relation.json +130 -0
  176. umap/tests/integration/conftest.py +8 -1
  177. umap/tests/integration/test_browser.py +3 -2
  178. umap/tests/integration/test_categorized_layer.py +141 -0
  179. umap/tests/integration/test_conditional_rules.py +21 -0
  180. umap/tests/integration/test_datalayer.py +9 -4
  181. umap/tests/integration/test_edit_datalayer.py +1 -0
  182. umap/tests/integration/test_edit_polygon.py +1 -1
  183. umap/tests/integration/test_export_map.py +2 -3
  184. umap/tests/integration/test_import.py +22 -0
  185. umap/tests/integration/test_map_preview.py +36 -2
  186. umap/tests/integration/test_tableeditor.py +158 -4
  187. umap/tests/integration/test_websocket_sync.py +2 -2
  188. umap/tests/test_views.py +2 -2
  189. umap/views.py +3 -2
  190. {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/METADATA +8 -8
  191. {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/RECORD +194 -184
  192. umap/static/umap/js/umap.slideshow.js +0 -165
  193. umap/static/umap/js/umap.tableeditor.js +0 -118
  194. umap/static/umap/vendors/togeojson/togeojson.umd.js +0 -2
  195. umap/static/umap/vendors/togpx/togpx.js +0 -547
  196. umap/static/umap/vendors/tokml/tokml.js +0 -343
  197. {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/WHEEL +0 -0
  198. {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/entry_points.txt +0 -0
  199. {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
1
- import { DomUtil, DomEvent } from '../../../vendors/leaflet/leaflet-src.esm.js'
1
+ import { DomEvent, DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js'
2
2
  import { translate } from '../i18n.js'
3
3
 
4
4
  export class Panel {
@@ -9,7 +9,7 @@ export class Panel {
9
9
  // This will be set once according to the panel configurated at load
10
10
  // or by using panels as popups
11
11
  this.mode = null
12
- this.classname = 'left'
12
+ this.className = 'left'
13
13
  DomEvent.disableClickPropagation(this.container)
14
14
  DomEvent.on(this.container, 'contextmenu', DomEvent.stopPropagation) // Do not activate our custom context menu.
15
15
  DomEvent.on(this.container, 'wheel', DomEvent.stopPropagation)
@@ -25,9 +25,10 @@ export class Panel {
25
25
  }
26
26
 
27
27
  open({ content, className, actions = [] } = {}) {
28
- this.container.className = `with-transition panel window ${this.classname} ${
28
+ this.container.className = `with-transition panel window ${this.className} ${
29
29
  this.mode || ''
30
30
  }`
31
+ document.body.classList.add(`panel-${this.className.split(' ')[0]}-on`)
31
32
  this.container.innerHTML = ''
32
33
  const actionsContainer = DomUtil.create('ul', 'buttons', this.container)
33
34
  const body = DomUtil.create('div', 'body', this.container)
@@ -69,6 +70,7 @@ export class Panel {
69
70
  }
70
71
 
71
72
  close() {
73
+ document.body.classList.remove(`panel-${this.className.split(' ')[0]}-on`)
72
74
  if (DomUtil.hasClass(this.container, 'on')) {
73
75
  DomUtil.removeClass(this.container, 'on')
74
76
  this.map.invalidateSize({ pan: false })
@@ -80,14 +82,14 @@ export class Panel {
80
82
  export class EditPanel extends Panel {
81
83
  constructor(map) {
82
84
  super(map)
83
- this.classname = 'right dark'
85
+ this.className = 'right dark'
84
86
  }
85
87
  }
86
88
 
87
89
  export class FullPanel extends Panel {
88
90
  constructor(map) {
89
91
  super(map)
90
- this.classname = 'full dark'
92
+ this.className = 'full dark'
91
93
  this.mode = 'expanded'
92
94
  }
93
95
  }
@@ -1,8 +1,10 @@
1
- import { DomUtil, DomEvent } from '../../../vendors/leaflet/leaflet-src.esm.js'
1
+ import { DomEvent, DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js'
2
2
  import { translate } from '../i18n.js'
3
+ import { Positioned } from './base.js'
3
4
 
4
- export default class Tooltip {
5
+ export default class Tooltip extends Positioned {
5
6
  constructor(parent) {
7
+ super()
6
8
  this.parent = parent
7
9
  this.container = DomUtil.create('div', 'with-transition', this.parent)
8
10
  this.container.id = 'umap-tooltip-container'
@@ -13,16 +15,8 @@ export default class Tooltip {
13
15
  }
14
16
 
15
17
  open(opts) {
16
- function showIt() {
17
- if (opts.anchor && opts.position === 'top') {
18
- this.anchorTop(opts.anchor)
19
- } else if (opts.anchor && opts.position === 'left') {
20
- this.anchorLeft(opts.anchor)
21
- } else if (opts.anchor && opts.position === 'bottom') {
22
- this.anchorBottom(opts.anchor)
23
- } else {
24
- this.anchorAbsolute()
25
- }
18
+ const showIt = () => {
19
+ this.openAt(opts)
26
20
  L.DomUtil.addClass(this.parent, 'umap-tooltip')
27
21
  this.container.innerHTML = U.Utils.escapeHTML(opts.content)
28
22
  }
@@ -34,48 +28,11 @@ export default class Tooltip {
34
28
  if (opts.anchor) {
35
29
  L.DomEvent.once(opts.anchor, 'mouseout', closeIt)
36
30
  }
37
- if (opts.duration !== Infinity) {
31
+ if (opts.duration !== Number.POSITIVE_INFINITY) {
38
32
  window.setTimeout(closeIt, opts.duration || 3000)
39
33
  }
40
34
  }
41
35
 
42
- anchorAbsolute() {
43
- this.container.className = ''
44
- const left =
45
- this.parent.offsetLeft +
46
- this.parent.clientWidth / 2 -
47
- this.container.clientWidth / 2,
48
- top = this.parent.offsetTop + 75
49
- this.setPosition({ top: top, left: left })
50
- }
51
-
52
- anchorTop(el) {
53
- this.container.className = 'tooltip-top'
54
- const coords = this.getPosition(el)
55
- this.setPosition({
56
- left: coords.left - 10,
57
- bottom: this.getDocHeight() - coords.top + 11,
58
- })
59
- }
60
-
61
- anchorBottom(el) {
62
- this.container.className = 'tooltip-bottom'
63
- const coords = this.getPosition(el)
64
- this.setPosition({
65
- left: coords.left,
66
- top: coords.bottom + 11,
67
- })
68
- }
69
-
70
- anchorLeft(el) {
71
- this.container.className = 'tooltip-left'
72
- const coords = this.getPosition(el)
73
- this.setPosition({
74
- top: coords.top,
75
- right: document.documentElement.offsetWidth - coords.left + 11,
76
- })
77
- }
78
-
79
36
  close(id) {
80
37
  // Clear timetout even if a new tooltip has been added
81
38
  // in the meantime. Eg. after a mouseout from the anchor.
@@ -86,31 +43,4 @@ export default class Tooltip {
86
43
  this.setPosition({})
87
44
  L.DomUtil.removeClass(this.parent, 'umap-tooltip')
88
45
  }
89
-
90
- getPosition(el) {
91
- return el.getBoundingClientRect()
92
- }
93
-
94
- setPosition(coords) {
95
- if (coords.left) this.container.style.left = `${coords.left}px`
96
- else this.container.style.left = 'initial'
97
- if (coords.right) this.container.style.right = `${coords.right}px`
98
- else this.container.style.right = 'initial'
99
- if (coords.top) this.container.style.top = `${coords.top}px`
100
- else this.container.style.top = 'initial'
101
- if (coords.bottom) this.container.style.bottom = `${coords.bottom}px`
102
- else this.container.style.bottom = 'initial'
103
- }
104
-
105
- getDocHeight() {
106
- const D = document
107
- return Math.max(
108
- D.body.scrollHeight,
109
- D.documentElement.scrollHeight,
110
- D.body.offsetHeight,
111
- D.documentElement.offsetHeight,
112
- D.body.clientHeight,
113
- D.documentElement.clientHeight
114
- )
115
- }
116
46
  }
@@ -10,9 +10,8 @@ export default class URLs {
10
10
 
11
11
  if (this.urls.hasOwnProperty(urlName)) {
12
12
  return template(this.urls[urlName], params)
13
- } else {
14
- throw `Unable to find a URL for route ${urlName}`
15
13
  }
14
+ throw `Unable to find a URL for route ${urlName}`
16
15
  }
17
16
 
18
17
  // Update if map_id is passed, create otherwise.
@@ -36,7 +36,7 @@ export function checkId(string) {
36
36
  */
37
37
  export function getImpactsFromSchema(fields, schema) {
38
38
  schema = schema || U.SCHEMA
39
- let impacted = fields
39
+ const impacted = fields
40
40
  .map((field) => {
41
41
  // remove the option prefix for fields
42
42
  // And only keep the first part in case of a subfield
@@ -63,9 +63,8 @@ export function getImpactsFromSchema(fields, schema) {
63
63
  export default function getPurify() {
64
64
  if (typeof window === 'undefined') {
65
65
  return DOMPurifyInitializer(new global.JSDOM('').window)
66
- } else {
67
- return DOMPurifyInitializer(window)
68
66
  }
67
+ return DOMPurifyInitializer(window)
69
68
  }
70
69
 
71
70
  export function escapeHTML(s) {
@@ -114,13 +113,13 @@ export function escapeHTML(s) {
114
113
 
115
114
  export function toHTML(r, options) {
116
115
  if (!r) return ''
117
- const target = (options && options.target) || 'blank'
116
+ const target = options?.target || 'blank'
118
117
 
119
118
  // unordered lists
120
119
  r = r.replace(/^\*\* (.*)/gm, '<ul><ul><li>$1</li></ul></ul>')
121
120
  r = r.replace(/^\* (.*)/gm, '<ul><li>$1</li></ul>')
122
121
  for (let ii = 0; ii < 3; ii++) {
123
- r = r.replace(new RegExp(`</ul>(\r\n|\r|\n)<ul>`, 'g'), '')
122
+ r = r.replace(/<\/ul>(\r\n|\r|\n)<ul>/g, '')
124
123
  }
125
124
 
126
125
  // headings and hr
@@ -271,8 +270,8 @@ export function sortFeatures(features, sortKey, lang) {
271
270
  const sortKeys = (sortKey || 'name').split(',')
272
271
 
273
272
  const sort = (a, b, i) => {
274
- let sortKey = sortKeys[i],
275
- reverse = 1
273
+ let sortKey = sortKeys[i]
274
+ let reverse = 1
276
275
  if (sortKey[0] === '-') {
277
276
  reverse = -1
278
277
  sortKey = sortKey.substring(1)
@@ -315,19 +314,19 @@ export function getBaseUrl() {
315
314
  }
316
315
 
317
316
  export function hasVar(value) {
318
- return typeof value === 'string' && value.indexOf('{') != -1
317
+ return typeof value === 'string' && value.indexOf('{') !== -1
319
318
  }
320
319
 
321
320
  export function isPath(value) {
322
- return value && value.length && value.startsWith('/')
321
+ return value?.length && value.startsWith('/')
323
322
  }
324
323
 
325
324
  export function isRemoteUrl(value) {
326
- return value && value.length && value.startsWith('http')
325
+ return value?.length && value.startsWith('http')
327
326
  }
328
327
 
329
328
  export function isDataImage(value) {
330
- return value && value.length && value.startsWith('data:image')
329
+ return value?.length && value.startsWith('data:image')
331
330
  }
332
331
 
333
332
  /**
@@ -349,15 +348,16 @@ export function normalize(s) {
349
348
 
350
349
  // Vendorized from leaflet.utils
351
350
  // https://github.com/Leaflet/Leaflet/blob/108c6717b70f57c63645498f9bd66b6677758786/src/core/Util.js#L132-L151
352
- var templateRe = /\{ *([\w_ -]+) *\}/g
351
+ const templateRe = /\{ *([\w_ -]+) *\}/g
353
352
 
354
353
  export function template(str, data) {
355
- return str.replace(templateRe, function (str, key) {
356
- var value = data[key]
354
+ return str.replace(templateRe, (str, key) => {
355
+ let value = data[key]
357
356
 
358
357
  if (value === undefined) {
359
- throw new Error('No value provided for variable ' + str)
360
- } else if (typeof value === 'function') {
358
+ throw new Error(`No value provided for variable ${str}`)
359
+ }
360
+ if (typeof value === 'function') {
361
361
  value = value(data)
362
362
  }
363
363
  return value
@@ -377,3 +377,23 @@ export function toggleBadge(element, value) {
377
377
  if (value) element.dataset.badge = value === true ? ' ' : value
378
378
  else delete element.dataset.badge
379
379
  }
380
+
381
+ export function loadTemplate(html) {
382
+ const template = document.createElement('template')
383
+ template.innerHTML = html
384
+ .split('\n')
385
+ .map((line) => line.trim())
386
+ .join('')
387
+ return template.content.firstElementChild
388
+ }
389
+
390
+ export class WithTemplate {
391
+ loadTemplate(html) {
392
+ this.element = loadTemplate(html)
393
+ this.elements = {}
394
+ for (const element of this.element.querySelectorAll('[data-ref]')) {
395
+ this.elements[element.dataset.ref] = element
396
+ }
397
+ return this.element
398
+ }
399
+ }
@@ -162,7 +162,7 @@ U.BaseFeatureAction = L.ToolbarAction.extend({
162
162
  this.postInit()
163
163
  },
164
164
 
165
- postInit: function () {},
165
+ postInit: () => {},
166
166
 
167
167
  hideToolbar: function () {
168
168
  this.map.removeLayer(this.toolbar)
@@ -356,7 +356,7 @@ U.DropControl = L.Class.extend({
356
356
  this.dropzone.classList.add('umap-dragover')
357
357
  },
358
358
 
359
- dragover: function (e) {
359
+ dragover: (e) => {
360
360
  L.DomEvent.stop(e)
361
361
  },
362
362
 
@@ -393,7 +393,7 @@ U.EditControl = L.Control.extend({
393
393
  L.DomEvent.on(
394
394
  enableEditing,
395
395
  'mouseover',
396
- function () {
396
+ () => {
397
397
  map.tooltip.open({
398
398
  content: map.help.displayLabel('TOGGLE_EDIT'),
399
399
  anchor: enableEditing,
@@ -434,9 +434,9 @@ U.MoreControls = L.Control.extend({
434
434
  },
435
435
 
436
436
  toggle: function () {
437
- const pos = this.getPosition(),
438
- corner = this._map._controlCorners[pos],
439
- className = 'umap-more-controls'
437
+ const pos = this.getPosition()
438
+ const corner = this._map._controlCorners[pos]
439
+ const className = 'umap-more-controls'
440
440
  if (L.DomUtil.hasClass(corner, className)) L.DomUtil.removeClass(corner, className)
441
441
  else L.DomUtil.addClass(corner, className)
442
442
  },
@@ -454,10 +454,10 @@ U.PermanentCreditsControl = L.Control.extend({
454
454
 
455
455
  onAdd: function () {
456
456
  const paragraphContainer = L.DomUtil.create(
457
- 'div',
458
- 'umap-permanent-credits-container'
459
- ),
460
- creditsParagraph = L.DomUtil.create('p', '', paragraphContainer)
457
+ 'div',
458
+ 'umap-permanent-credits-container'
459
+ )
460
+ const creditsParagraph = L.DomUtil.create('p', '', paragraphContainer)
461
461
 
462
462
  this.paragraphContainer = paragraphContainer
463
463
  this.setCredits()
@@ -503,7 +503,7 @@ L.Control.Button = L.Control.extend({
503
503
  return container
504
504
  },
505
505
 
506
- afterAdd: function (container) {},
506
+ afterAdd: (container) => {},
507
507
  })
508
508
 
509
509
  U.DataLayersControl = L.Control.Button.extend({
@@ -745,13 +745,13 @@ const ControlsMixin = {
745
745
  L.DomUtil.createLink(
746
746
  'umap-user',
747
747
  rightContainer,
748
- L._(`My Dashboard ({username})`, {
748
+ L._('My Dashboard ({username})', {
749
749
  username: this.options.user.name,
750
750
  }),
751
751
  this.options.user.url
752
752
  )
753
753
  }
754
- this.help.link(rightContainer, 'edit')
754
+ this.help.getStartedLink(rightContainer)
755
755
  const controlEditCancel = L.DomUtil.createButton(
756
756
  'leaflet-control-edit-cancel',
757
757
  rightContainer,
@@ -832,10 +832,10 @@ const ControlsMixin = {
832
832
  row.dataset.id = L.stamp(datalayer)
833
833
  })
834
834
  const onReorder = (src, dst, initialIndex, finalIndex) => {
835
- const layer = this.datalayers[src.dataset.id],
836
- other = this.datalayers[dst.dataset.id],
837
- minIndex = Math.min(layer.getRank(), other.getRank()),
838
- maxIndex = Math.max(layer.getRank(), other.getRank())
835
+ const layer = this.datalayers[src.dataset.id]
836
+ const other = this.datalayers[dst.dataset.id]
837
+ const minIndex = Math.min(layer.getRank(), other.getRank())
838
+ const maxIndex = Math.max(layer.getRank(), other.getRank())
839
839
  if (finalIndex === 0) layer.bringToTop()
840
840
  else if (finalIndex > initialIndex) layer.insertBefore(other)
841
841
  else layer.insertAfter(other)
@@ -948,10 +948,10 @@ U.TileLayerChooser = L.Control.extend({
948
948
  },
949
949
 
950
950
  addTileLayerElement: function (tilelayer, options) {
951
- const selectedClass = this.map.hasLayer(tilelayer) ? 'selected' : '',
952
- el = L.DomUtil.create('li', selectedClass, this._tilelayers_container),
953
- img = L.DomUtil.create('img', '', el),
954
- name = L.DomUtil.create('div', '', el)
951
+ const selectedClass = this.map.hasLayer(tilelayer) ? 'selected' : ''
952
+ const el = L.DomUtil.create('li', selectedClass, this._tilelayers_container)
953
+ const img = L.DomUtil.create('img', '', el)
954
+ const name = L.DomUtil.create('div', '', el)
955
955
  img.src = U.Utils.template(tilelayer.options.url_template, this.map.demoTileInfos)
956
956
  img.loading = 'lazy'
957
957
  name.textContent = tilelayer.options.name
@@ -961,7 +961,7 @@ U.TileLayerChooser = L.Control.extend({
961
961
  function () {
962
962
  this.map.selectTileLayer(tilelayer)
963
963
  this.map._controls.tilelayers.setLayers()
964
- if (options && options.callback) options.callback(tilelayer)
964
+ if (options?.callback) options.callback(tilelayer)
965
965
  },
966
966
  this
967
967
  )
@@ -982,8 +982,8 @@ U.AttributionControl = L.Control.Attribution.extend({
982
982
  this._container.innerHTML = ''
983
983
  const container = L.DomUtil.create('div', 'attribution-container', this._container)
984
984
  container.innerHTML = credits
985
- const shortCredit = this._map.getOption('shortCredit'),
986
- captionMenus = this._map.getOption('captionMenus')
985
+ const shortCredit = this._map.getOption('shortCredit')
986
+ const captionMenus = this._map.getOption('captionMenus')
987
987
  if (shortCredit) {
988
988
  L.DomUtil.element({
989
989
  tagName: 'span',
@@ -1205,9 +1205,7 @@ L.Control.MiniMap.include({
1205
1205
  this._miniMap.addLayer(this._layer)
1206
1206
  },
1207
1207
 
1208
- _cloneLayer: function (layer) {
1209
- return new L.TileLayer(layer._url, L.Util.extend({}, layer.options))
1210
- },
1208
+ _cloneLayer: (layer) => new L.TileLayer(layer._url, L.Util.extend({}, layer.options)),
1211
1209
  })
1212
1210
 
1213
1211
  L.Control.Loading.include({
@@ -1312,7 +1310,7 @@ U.Editable = L.Editable.extend({
1312
1310
  },
1313
1311
 
1314
1312
  drawingTooltip: function (e) {
1315
- if (e.layer instanceof L.Marker && e.type == 'editable:drawing:start') {
1313
+ if (e.layer instanceof L.Marker && e.type === 'editable:drawing:start') {
1316
1314
  this.map.tooltip.open({ content: L._('Click to add a marker') })
1317
1315
  }
1318
1316
  if (!(e.layer instanceof L.Polyline)) {
@@ -1364,7 +1362,7 @@ U.Editable = L.Editable.extend({
1364
1362
  this.map.ui.closeTooltip()
1365
1363
  },
1366
1364
 
1367
- onVertexRawClick: function (e) {
1365
+ onVertexRawClick: (e) => {
1368
1366
  e.layer.onVertexRawClick(e)
1369
1367
  L.DomEvent.stop(e)
1370
1368
  e.cancel()
@@ -1,4 +1,4 @@
1
- L.Util.copyToClipboard = function (textToCopy) {
1
+ L.Util.copyToClipboard = (textToCopy) => {
2
2
  // https://stackoverflow.com/a/65996386
3
3
  // Navigator clipboard api needs a secure context (https)
4
4
  if (navigator.clipboard && window.isSecureContext) {
@@ -25,10 +25,10 @@ L.Util.copyToClipboard = function (textToCopy) {
25
25
  }
26
26
  }
27
27
 
28
- L.Util.queryString = function (name, fallback) {
28
+ L.Util.queryString = (name, fallback) => {
29
29
  const decode = (s) => decodeURIComponent(s.replace(/\+/g, ' '))
30
- const qs = window.location.search.slice(1).split('&'),
31
- qa = {}
30
+ const qs = window.location.search.slice(1).split('&')
31
+ const qa = {}
32
32
  for (const i in qs) {
33
33
  const key = qs[i].split('=')
34
34
  if (!key) continue
@@ -37,27 +37,27 @@ L.Util.queryString = function (name, fallback) {
37
37
  return qa[name] || fallback
38
38
  }
39
39
 
40
- L.Util.booleanFromQueryString = function (name) {
40
+ L.Util.booleanFromQueryString = (name) => {
41
41
  const value = L.Util.queryString(name)
42
42
  return value === '1' || value === 'true'
43
43
  }
44
44
 
45
- L.Util.setFromQueryString = function (options, name) {
45
+ L.Util.setFromQueryString = (options, name) => {
46
46
  const value = L.Util.queryString(name)
47
47
  if (typeof value !== 'undefined') options[name] = value
48
48
  }
49
49
 
50
- L.Util.setBooleanFromQueryString = function (options, name) {
50
+ L.Util.setBooleanFromQueryString = (options, name) => {
51
51
  const value = L.Util.queryString(name)
52
- if (typeof value !== 'undefined') options[name] = value == '1' || value == 'true'
52
+ if (typeof value !== 'undefined') options[name] = value === '1' || value === 'true'
53
53
  }
54
54
 
55
- L.Util.setNumberFromQueryString = function (options, name) {
55
+ L.Util.setNumberFromQueryString = (options, name) => {
56
56
  const value = +L.Util.queryString(name)
57
- if (!isNaN(value)) options[name] = value
57
+ if (!Number.isNaN(value)) options[name] = value
58
58
  }
59
59
 
60
- L.Util.setNullableBooleanFromQueryString = function (options, name) {
60
+ L.Util.setNullableBooleanFromQueryString = (options, name) => {
61
61
  let value = L.Util.queryString(name)
62
62
  if (typeof value !== 'undefined') {
63
63
  if (value === 'null') value = null
@@ -192,7 +192,7 @@ L.DomUtil.after = (target, el) => {
192
192
  // convert colour in range 0-255 to the modifier used within luminance calculation
193
193
  L.DomUtil.colourMod = (colour) => {
194
194
  const sRGB = colour / 255
195
- let mod = Math.pow((sRGB + 0.055) / 1.055, 2.4)
195
+ let mod = ((sRGB + 0.055) / 1.055) ** 2.4
196
196
  if (sRGB < 0.03928) mod = sRGB / 12.92
197
197
  return mod
198
198
  }
@@ -222,7 +222,11 @@ L.DomUtil.contrastedColor = (el, bgcolor) => {
222
222
  let rgb = window.getComputedStyle(el).getPropertyValue('background-color')
223
223
  rgb = L.DomUtil.RGBRegex.exec(rgb)
224
224
  if (!rgb || rgb.length !== 4) return out
225
- rgb = [parseInt(rgb[1], 10), parseInt(rgb[2], 10), parseInt(rgb[3], 10)]
225
+ rgb = [
226
+ Number.parseInt(rgb[1], 10),
227
+ Number.parseInt(rgb[2], 10),
228
+ Number.parseInt(rgb[3], 10),
229
+ ]
226
230
  out = L.DomUtil.contrastWCAG21(rgb)
227
231
  if (bgcolor) _CACHE_CONSTRAST[bgcolor] = out
228
232
  return out
@@ -247,9 +251,9 @@ L.DomEvent.once = (el, types, fn, context) => {
247
251
 
248
252
  L.LatLng.prototype.isValid = function () {
249
253
  return (
250
- isFinite(this.lat) &&
254
+ Number.isFinite(this.lat) &&
251
255
  Math.abs(this.lat) <= 90 &&
252
- isFinite(this.lng) &&
256
+ Number.isFinite(this.lng) &&
253
257
  Math.abs(this.lng) <= 180
254
258
  )
255
259
  }
@@ -7,15 +7,12 @@ U.DataLayerPermissions = L.Class.extend({
7
7
  this.options = L.Util.setOptions(this, datalayer.options.permissions)
8
8
  this.datalayer = datalayer
9
9
  let isDirty = false
10
- const self = this
11
10
  try {
12
11
  Object.defineProperty(this, 'isDirty', {
13
- get: function () {
14
- return isDirty
15
- },
16
- set: function (status) {
12
+ get: () => isDirty,
13
+ set: (status) => {
17
14
  isDirty = status
18
- if (status) self.datalayer.isDirty = status
15
+ if (status) this.datalayer.isDirty = status
19
16
  },
20
17
  })
21
18
  } catch (e) {
@@ -29,19 +26,19 @@ U.DataLayerPermissions = L.Class.extend({
29
26
 
30
27
  edit: function (container) {
31
28
  const fields = [
32
- [
33
- 'options.edit_status',
34
- {
35
- handler: 'IntSelect',
36
- label: L._('Who can edit "{layer}"', { layer: this.datalayer.getName() }),
37
- selectOptions: this.datalayer.map.options.datalayer_edit_statuses,
38
- },
39
- ],
29
+ [
30
+ 'options.edit_status',
31
+ {
32
+ handler: 'IntSelect',
33
+ label: L._('Who can edit "{layer}"', { layer: this.datalayer.getName() }),
34
+ selectOptions: this.datalayer.map.options.datalayer_edit_statuses,
35
+ },
40
36
  ],
41
- builder = new U.FormBuilder(this, fields, {
42
- className: 'umap-form datalayer-permissions',
43
- }),
44
- form = builder.build()
37
+ ]
38
+ const builder = new U.FormBuilder(this, fields, {
39
+ className: 'umap-form datalayer-permissions',
40
+ })
41
+ const form = builder.build()
45
42
  container.appendChild(form)
46
43
  },
47
44