umap-project 2.3.0__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.

Files changed (211) hide show
  1. umap/__init__.py +1 -1
  2. umap/locale/en/LC_MESSAGES/django.po +81 -31
  3. umap/locale/fr/LC_MESSAGES/django.mo +0 -0
  4. umap/locale/fr/LC_MESSAGES/django.po +117 -66
  5. umap/locale/pl/LC_MESSAGES/django.mo +0 -0
  6. umap/locale/pl/LC_MESSAGES/django.po +83 -78
  7. umap/locale/pt/LC_MESSAGES/django.mo +0 -0
  8. umap/locale/pt/LC_MESSAGES/django.po +129 -123
  9. umap/management/commands/run_websocket_server.py +23 -0
  10. umap/models.py +6 -1
  11. umap/settings/base.py +11 -3
  12. umap/static/umap/base.css +68 -186
  13. umap/static/umap/content.css +3 -2
  14. umap/static/umap/css/dialog.css +18 -0
  15. umap/static/umap/css/icon.css +8 -0
  16. umap/static/umap/css/importers.css +51 -0
  17. umap/static/umap/css/panel.css +18 -57
  18. umap/static/umap/css/tooltip.css +59 -0
  19. umap/static/umap/css/window.css +35 -0
  20. umap/static/umap/img/16-white.svg +1 -3
  21. umap/static/umap/img/alert-icon-error.svg +8 -0
  22. umap/static/umap/img/alert-icon-info.svg +4 -0
  23. umap/static/umap/img/alert-icon-success.svg +3 -0
  24. umap/static/umap/img/icon-external-link.svg +3 -0
  25. umap/static/umap/img/importers/communesfr.svg +5 -0
  26. umap/static/umap/img/importers/datasets.svg +13 -0
  27. umap/static/umap/img/importers/geodatamine.svg +10 -0
  28. umap/static/umap/img/importers/overpass.svg +7 -0
  29. umap/static/umap/img/importers/random.svg +18 -0
  30. umap/static/umap/img/importers/random1.svg +4 -0
  31. umap/static/umap/img/importers/random2.svg +4 -0
  32. umap/static/umap/img/source/16-white.svg +2 -4
  33. umap/static/umap/js/components/alerts/alert.css +160 -0
  34. umap/static/umap/js/components/alerts/alert.js +169 -0
  35. umap/static/umap/js/components/base.js +54 -0
  36. umap/static/umap/js/modules/autocomplete.js +347 -0
  37. umap/static/umap/js/modules/browser.js +14 -21
  38. umap/static/umap/js/modules/caption.js +119 -0
  39. umap/static/umap/js/modules/global.js +37 -11
  40. umap/static/umap/js/modules/help.js +255 -0
  41. umap/static/umap/js/modules/importer.js +308 -0
  42. umap/static/umap/js/modules/importers/communesfr.js +44 -0
  43. umap/static/umap/js/modules/importers/datasets.js +42 -0
  44. umap/static/umap/js/modules/importers/geodatamine.js +95 -0
  45. umap/static/umap/js/modules/importers/overpass.js +84 -0
  46. umap/static/umap/js/modules/request.js +12 -14
  47. umap/static/umap/js/modules/rules.js +241 -0
  48. umap/static/umap/js/modules/schema.js +63 -14
  49. umap/static/umap/js/modules/sync/engine.js +93 -0
  50. umap/static/umap/js/modules/sync/updaters.js +109 -0
  51. umap/static/umap/js/modules/sync/websocket.js +25 -0
  52. umap/static/umap/js/modules/ui/dialog.js +52 -0
  53. umap/static/umap/js/modules/{panel.js → ui/panel.js} +37 -20
  54. umap/static/umap/js/modules/ui/tooltip.js +116 -0
  55. umap/static/umap/js/modules/utils.js +25 -18
  56. umap/static/umap/js/umap.controls.js +37 -112
  57. umap/static/umap/js/umap.core.js +1 -327
  58. umap/static/umap/js/umap.features.js +77 -29
  59. umap/static/umap/js/umap.forms.js +17 -19
  60. umap/static/umap/js/umap.js +265 -228
  61. umap/static/umap/js/umap.layer.js +154 -76
  62. umap/static/umap/js/umap.permissions.js +5 -9
  63. umap/static/umap/js/umap.popup.js +2 -1
  64. umap/static/umap/js/umap.tableeditor.js +8 -8
  65. umap/static/umap/locale/am_ET.js +51 -16
  66. umap/static/umap/locale/am_ET.json +51 -16
  67. umap/static/umap/locale/ar.js +51 -16
  68. umap/static/umap/locale/ar.json +51 -16
  69. umap/static/umap/locale/ast.js +51 -16
  70. umap/static/umap/locale/ast.json +51 -16
  71. umap/static/umap/locale/bg.js +51 -16
  72. umap/static/umap/locale/bg.json +51 -16
  73. umap/static/umap/locale/br.js +55 -20
  74. umap/static/umap/locale/br.json +55 -20
  75. umap/static/umap/locale/ca.js +51 -16
  76. umap/static/umap/locale/ca.json +51 -16
  77. umap/static/umap/locale/cs_CZ.js +93 -58
  78. umap/static/umap/locale/cs_CZ.json +93 -58
  79. umap/static/umap/locale/da.js +51 -16
  80. umap/static/umap/locale/da.json +51 -16
  81. umap/static/umap/locale/de.js +56 -21
  82. umap/static/umap/locale/de.json +56 -21
  83. umap/static/umap/locale/el.js +51 -16
  84. umap/static/umap/locale/el.json +51 -16
  85. umap/static/umap/locale/en.js +52 -16
  86. umap/static/umap/locale/en.json +52 -16
  87. umap/static/umap/locale/en_US.json +51 -16
  88. umap/static/umap/locale/es.js +51 -16
  89. umap/static/umap/locale/es.json +51 -16
  90. umap/static/umap/locale/et.js +51 -16
  91. umap/static/umap/locale/et.json +51 -16
  92. umap/static/umap/locale/eu.js +51 -16
  93. umap/static/umap/locale/eu.json +51 -16
  94. umap/static/umap/locale/fa_IR.js +51 -16
  95. umap/static/umap/locale/fa_IR.json +51 -16
  96. umap/static/umap/locale/fi.js +51 -16
  97. umap/static/umap/locale/fi.json +51 -16
  98. umap/static/umap/locale/fr.js +61 -25
  99. umap/static/umap/locale/fr.json +61 -25
  100. umap/static/umap/locale/gl.js +51 -16
  101. umap/static/umap/locale/gl.json +51 -16
  102. umap/static/umap/locale/he.js +51 -16
  103. umap/static/umap/locale/he.json +51 -16
  104. umap/static/umap/locale/hr.js +51 -16
  105. umap/static/umap/locale/hr.json +51 -16
  106. umap/static/umap/locale/hu.js +51 -16
  107. umap/static/umap/locale/hu.json +51 -16
  108. umap/static/umap/locale/id.js +51 -16
  109. umap/static/umap/locale/id.json +51 -16
  110. umap/static/umap/locale/is.js +51 -16
  111. umap/static/umap/locale/is.json +51 -16
  112. umap/static/umap/locale/it.js +51 -16
  113. umap/static/umap/locale/it.json +51 -16
  114. umap/static/umap/locale/ja.js +51 -16
  115. umap/static/umap/locale/ja.json +51 -16
  116. umap/static/umap/locale/ko.js +51 -16
  117. umap/static/umap/locale/ko.json +51 -16
  118. umap/static/umap/locale/lt.js +51 -16
  119. umap/static/umap/locale/lt.json +51 -16
  120. umap/static/umap/locale/ms.js +51 -16
  121. umap/static/umap/locale/ms.json +51 -16
  122. umap/static/umap/locale/nl.js +51 -16
  123. umap/static/umap/locale/nl.json +51 -16
  124. umap/static/umap/locale/no.js +51 -16
  125. umap/static/umap/locale/no.json +51 -16
  126. umap/static/umap/locale/pl.js +93 -58
  127. umap/static/umap/locale/pl.json +93 -58
  128. umap/static/umap/locale/pl_PL.json +51 -16
  129. umap/static/umap/locale/pt.js +215 -180
  130. umap/static/umap/locale/pt.json +215 -180
  131. umap/static/umap/locale/pt_BR.js +51 -16
  132. umap/static/umap/locale/pt_BR.json +51 -16
  133. umap/static/umap/locale/pt_PT.js +51 -16
  134. umap/static/umap/locale/pt_PT.json +51 -16
  135. umap/static/umap/locale/ro.js +51 -16
  136. umap/static/umap/locale/ro.json +51 -16
  137. umap/static/umap/locale/ru.js +51 -16
  138. umap/static/umap/locale/ru.json +51 -16
  139. umap/static/umap/locale/si.js +51 -16
  140. umap/static/umap/locale/si.json +51 -16
  141. umap/static/umap/locale/sk_SK.js +51 -16
  142. umap/static/umap/locale/sk_SK.json +51 -16
  143. umap/static/umap/locale/sl.js +51 -16
  144. umap/static/umap/locale/sl.json +51 -16
  145. umap/static/umap/locale/sr.js +51 -16
  146. umap/static/umap/locale/sr.json +51 -16
  147. umap/static/umap/locale/sv.js +51 -16
  148. umap/static/umap/locale/sv.json +51 -16
  149. umap/static/umap/locale/th_TH.js +51 -16
  150. umap/static/umap/locale/th_TH.json +51 -16
  151. umap/static/umap/locale/tr.js +51 -16
  152. umap/static/umap/locale/tr.json +51 -16
  153. umap/static/umap/locale/uk_UA.js +51 -16
  154. umap/static/umap/locale/uk_UA.json +51 -16
  155. umap/static/umap/locale/vi.js +51 -16
  156. umap/static/umap/locale/vi.json +51 -16
  157. umap/static/umap/locale/vi_VN.json +51 -16
  158. umap/static/umap/locale/zh.js +51 -16
  159. umap/static/umap/locale/zh.json +51 -16
  160. umap/static/umap/locale/zh_CN.json +51 -16
  161. umap/static/umap/locale/zh_TW.Big5.json +51 -16
  162. umap/static/umap/locale/zh_TW.js +51 -16
  163. umap/static/umap/locale/zh_TW.json +51 -16
  164. umap/static/umap/map.css +40 -53
  165. umap/static/umap/unittests/sync.js +105 -0
  166. umap/static/umap/unittests/utils.js +78 -36
  167. umap/static/umap/vars.css +19 -1
  168. umap/static/umap/vendors/dompurify/purify.es.js +50 -15
  169. umap/static/umap/vendors/dompurify/purify.es.mjs.map +1 -1
  170. umap/static/umap/vendors/formbuilder/Leaflet.FormBuilder.js +2 -2
  171. umap/templates/umap/components/alerts/alert.html +89 -0
  172. umap/templates/umap/content.html +4 -3
  173. umap/templates/umap/css.html +4 -0
  174. umap/templates/umap/home.html +3 -0
  175. umap/templates/umap/js.html +0 -3
  176. umap/templates/umap/map_init.html +2 -8
  177. umap/templates/umap/messages.html +9 -11
  178. umap/templates/umap/search.html +3 -0
  179. umap/tests/base.py +3 -0
  180. umap/tests/integration/conftest.py +30 -0
  181. umap/tests/integration/test_anonymous_owned_map.py +8 -13
  182. umap/tests/integration/test_browser.py +81 -6
  183. umap/tests/integration/test_caption.py +27 -0
  184. umap/tests/integration/test_conditional_rules.py +201 -0
  185. umap/tests/integration/test_dashboard.py +1 -1
  186. umap/tests/integration/test_datalayer.py +2 -3
  187. umap/tests/integration/test_edit_datalayer.py +32 -3
  188. umap/tests/integration/test_edit_map.py +1 -1
  189. umap/tests/integration/test_facets_browser.py +7 -4
  190. umap/tests/integration/test_import.py +185 -49
  191. umap/tests/integration/test_map.py +31 -17
  192. umap/tests/integration/{test_collaborative_editing.py → test_optimistic_merge.py} +7 -7
  193. umap/tests/integration/test_owned_map.py +1 -1
  194. umap/tests/integration/test_picto.py +2 -2
  195. umap/tests/integration/test_statics.py +1 -1
  196. umap/tests/integration/test_view_marker.py +19 -2
  197. umap/tests/integration/test_websocket_sync.py +283 -0
  198. umap/tests/settings.py +5 -0
  199. umap/tests/test_datalayer_views.py +0 -1
  200. umap/tests/test_views.py +53 -0
  201. umap/urls.py +5 -0
  202. umap/views.py +40 -11
  203. umap/websocket_server.py +92 -0
  204. {umap_project-2.3.0.dist-info → umap_project-2.4.0.dist-info}/METADATA +13 -11
  205. {umap_project-2.3.0.dist-info → umap_project-2.4.0.dist-info}/RECORD +208 -172
  206. umap/static/umap/js/umap.autocomplete.js +0 -341
  207. umap/static/umap/js/umap.importer.js +0 -187
  208. umap/static/umap/js/umap.ui.js +0 -190
  209. {umap_project-2.3.0.dist-info → umap_project-2.4.0.dist-info}/WHEEL +0 -0
  210. {umap_project-2.3.0.dist-info → umap_project-2.4.0.dist-info}/entry_points.txt +0 -0
  211. {umap_project-2.3.0.dist-info → umap_project-2.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -84,7 +84,7 @@ U.UpdateExtentAction = U.BaseAction.extend({
84
84
  },
85
85
 
86
86
  addHooks: function () {
87
- this.map.updateExtent()
87
+ this.map.setCenterAndZoom()
88
88
  },
89
89
  })
90
90
 
@@ -394,7 +394,7 @@ U.EditControl = L.Control.extend({
394
394
  enableEditing,
395
395
  'mouseover',
396
396
  function () {
397
- map.ui.tooltip({
397
+ map.tooltip.open({
398
398
  content: map.help.displayLabel('TOGGLE_EDIT'),
399
399
  anchor: enableEditing,
400
400
  position: 'bottom',
@@ -510,7 +510,7 @@ U.DataLayersControl = L.Control.Button.extend({
510
510
  options: {
511
511
  position: 'topleft',
512
512
  className: 'umap-control-browse',
513
- title: L._('See layers'),
513
+ title: L._('Open browser'),
514
514
  },
515
515
 
516
516
  afterAdd: function (container) {
@@ -530,7 +530,7 @@ U.CaptionControl = L.Control.Button.extend({
530
530
  },
531
531
 
532
532
  onClick: function () {
533
- this.map.displayCaption()
533
+ this.map.openCaption()
534
534
  },
535
535
  })
536
536
 
@@ -607,15 +607,14 @@ U.DataLayer.include({
607
607
  if (!this.isVisible()) return
608
608
  if (!confirm(L._('Are you sure you want to delete this layer?'))) return
609
609
  this._delete()
610
- this.map.editPanel.close()
611
610
  },
612
611
  this
613
612
  )
614
613
  }
615
614
  L.DomEvent.on(toggle, 'click', this.toggle, this)
616
615
  L.DomEvent.on(zoomTo, 'click', this.zoomTo, this)
617
- L.DomUtil.addClass(container, this.getHidableClass())
618
- L.DomUtil.classIf(container, 'off', !this.isVisible())
616
+ container.classList.add(this.getHidableClass())
617
+ container.classList.toggle('off', !this.isVisible())
619
618
  },
620
619
 
621
620
  getHidableElements: function () {
@@ -626,10 +625,17 @@ U.DataLayer.include({
626
625
  return `show_with_datalayer_${L.stamp(this)}`
627
626
  },
628
627
 
628
+ propagateDelete: function () {
629
+ const els = this.getHidableElements()
630
+ for (const el of els) {
631
+ L.DomUtil.remove(el)
632
+ }
633
+ },
634
+
629
635
  propagateRemote: function () {
630
636
  const els = this.getHidableElements()
631
- for (let i = 0; i < els.length; i++) {
632
- L.DomUtil.classIf(els[i], 'remotelayer', this.isRemoteLayer())
637
+ for (const el of els) {
638
+ el.classList.toggle('remotelayer', this.isRemoteLayer())
633
639
  }
634
640
  },
635
641
 
@@ -653,6 +659,7 @@ U.DataLayer.include({
653
659
  U.DataLayer.addInitHook(function () {
654
660
  this.on('hide', this.propagateHide)
655
661
  this.on('show', this.propagateShow)
662
+ this.on('erase', this.propagateDelete)
656
663
  if (this.isVisible()) this.propagateShow()
657
664
  })
658
665
 
@@ -671,96 +678,6 @@ const ControlsMixin = {
671
678
  'tilelayers',
672
679
  ],
673
680
 
674
- displayCaption: function () {
675
- const container = L.DomUtil.create('div', 'umap-caption')
676
- L.DomUtil.createTitle(container, this.options.name, 'icon-caption')
677
- this.permissions.addOwnerLink('h5', container)
678
- if (this.options.description) {
679
- const description = L.DomUtil.element({
680
- tagName: 'div',
681
- className: 'umap-map-description',
682
- safeHTML: U.Utils.toHTML(this.options.description),
683
- parent: container,
684
- })
685
- }
686
- const datalayerContainer = L.DomUtil.create('div', 'datalayer-container', container)
687
- this.eachVisibleDataLayer((datalayer) => {
688
- if (!datalayer.options.inCaption) return
689
- const p = L.DomUtil.create('p', 'datalayer-legend', datalayerContainer),
690
- legend = L.DomUtil.create('span', '', p),
691
- headline = L.DomUtil.create('strong', '', p)
692
- datalayer.onceLoaded(function () {
693
- datalayer.renderLegend(legend)
694
- if (datalayer.options.description) {
695
- L.DomUtil.element({
696
- tagName: 'span',
697
- parent: p,
698
- safeHTML: U.Utils.toHTML(datalayer.options.description),
699
- })
700
- }
701
- })
702
- datalayer.renderToolbox(headline)
703
- L.DomUtil.add('span', '', headline, `${datalayer.options.name} `)
704
- })
705
- const creditsContainer = L.DomUtil.create('div', 'credits-container', container),
706
- credits = L.DomUtil.createFieldset(creditsContainer, L._('Credits'))
707
- title = L.DomUtil.add('h5', '', credits, L._('User content credits'))
708
- if (this.options.shortCredit || this.options.longCredit) {
709
- L.DomUtil.element({
710
- tagName: 'p',
711
- parent: credits,
712
- safeHTML: U.Utils.toHTML(this.options.longCredit || this.options.shortCredit),
713
- })
714
- }
715
- if (this.options.licence) {
716
- const licence = L.DomUtil.add(
717
- 'p',
718
- '',
719
- credits,
720
- `${L._('Map user content has been published under licence')} `
721
- )
722
- L.DomUtil.createLink(
723
- '',
724
- licence,
725
- this.options.licence.name,
726
- this.options.licence.url
727
- )
728
- } else {
729
- L.DomUtil.add('p', '', credits, L._('No licence has been set'))
730
- }
731
- title = L.DomUtil.create('h5', '', credits)
732
- title.textContent = L._('Map background credits')
733
- const tilelayerCredit = L.DomUtil.create('p', '', credits)
734
- L.DomUtil.element({
735
- tagName: 'strong',
736
- parent: tilelayerCredit,
737
- textContent: `${this.selected_tilelayer.options.name} `,
738
- })
739
- L.DomUtil.element({
740
- tagName: 'span',
741
- parent: tilelayerCredit,
742
- safeHTML: this.selected_tilelayer.getAttribution(),
743
- })
744
- const urls = {
745
- leaflet: 'http://leafletjs.com',
746
- django: 'https://www.djangoproject.com',
747
- umap: 'http://wiki.openstreetmap.org/wiki/UMap',
748
- changelog: 'https://umap-project.readthedocs.io/en/master/changelog/',
749
- version: this.options.umap_version,
750
- }
751
- const creditHTML = L._(
752
- `
753
- Powered by <a href="{leaflet}">Leaflet</a> and
754
- <a href="{django}">Django</a>,
755
- glued by <a href="{umap}">uMap project</a>
756
- (version <a href="{changelog}">{version}</a>).
757
- `,
758
- urls
759
- )
760
- L.DomUtil.element({ tagName: 'p', innerHTML: creditHTML, parent: credits })
761
- this.panel.open({ content: container })
762
- },
763
-
764
681
  renderEditToolbar: function () {
765
682
  const container = L.DomUtil.create(
766
683
  'div',
@@ -776,7 +693,7 @@ const ControlsMixin = {
776
693
  nameButton,
777
694
  'mouseover',
778
695
  function () {
779
- this.ui.tooltip({
696
+ this.tooltip.open({
780
697
  content: L._('Edit the title of the map'),
781
698
  anchor: nameButton,
782
699
  position: 'bottom',
@@ -797,7 +714,7 @@ const ControlsMixin = {
797
714
  shareStatusButton,
798
715
  'mouseover',
799
716
  function () {
800
- this.ui.tooltip({
717
+ this.tooltip.open({
801
718
  content: L._('Update who can see and edit the map'),
802
719
  anchor: shareStatusButton,
803
720
  position: 'bottom',
@@ -846,7 +763,7 @@ const ControlsMixin = {
846
763
  controlEditCancel,
847
764
  'mouseover',
848
765
  function () {
849
- this.ui.tooltip({
766
+ this.tooltip.open({
850
767
  content: this.help.displayLabel('CANCEL'),
851
768
  anchor: controlEditCancel,
852
769
  position: 'bottom',
@@ -867,7 +784,7 @@ const ControlsMixin = {
867
784
  controlEditDisable,
868
785
  'mouseover',
869
786
  function () {
870
- this.ui.tooltip({
787
+ this.tooltip.open({
871
788
  content: this.help.displayLabel('PREVIEW'),
872
789
  anchor: controlEditDisable,
873
790
  position: 'bottom',
@@ -888,7 +805,7 @@ const ControlsMixin = {
888
805
  controlEditSave,
889
806
  'mouseover',
890
807
  function () {
891
- this.ui.tooltip({
808
+ this.tooltip.open({
892
809
  content: this.help.displayLabel('SAVE'),
893
810
  anchor: controlEditSave,
894
811
  position: 'bottom',
@@ -910,7 +827,7 @@ const ControlsMixin = {
910
827
  L.DomUtil.createIcon(row, 'icon-drag', L._('Drag to reorder'))
911
828
  datalayer.renderToolbox(row)
912
829
  const title = L.DomUtil.add('span', '', row, datalayer.options.name)
913
- L.DomUtil.classIf(row, 'off', !datalayer.isVisible())
830
+ row.classList.toggle('off', !datalayer.isVisible())
914
831
  title.textContent = datalayer.options.name
915
832
  row.dataset.id = L.stamp(datalayer)
916
833
  })
@@ -1075,9 +992,9 @@ U.AttributionControl = L.Control.Attribution.extend({
1075
992
  })
1076
993
  }
1077
994
  if (captionMenus) {
1078
- const link = L.DomUtil.add('a', '', container, ` — ${L._('About')}`)
995
+ const link = L.DomUtil.add('a', '', container, ` — ${L._('Open caption')}`)
1079
996
  L.DomEvent.on(link, 'click', L.DomEvent.stop)
1080
- .on(link, 'click', this._map.displayCaption, this._map)
997
+ .on(link, 'click', this._map.openCaption, this._map)
1081
998
  .on(link, 'dblclick', L.DomEvent.stop)
1082
999
  }
1083
1000
  if (window.top === window.self && captionMenus) {
@@ -1121,7 +1038,15 @@ U.Locate = L.Control.Locate.extend({
1121
1038
  _activate: function () {
1122
1039
  this._map = this.map
1123
1040
  L.Control.Locate.prototype._activate.call(this)
1124
- this._map = null
1041
+ },
1042
+
1043
+ remove: function () {
1044
+ // Prevent to call remove if the control is not really added to the map
1045
+ // This occurs because we do create the control and call its activate
1046
+ // method before adding the control button itself to the map, in the
1047
+ // case where the map defaultView is set to "location"
1048
+ if (!this._container || !this._container.parentNode) return
1049
+ return L.Control.Locate.prototype.remove.call(this)
1125
1050
  },
1126
1051
  })
1127
1052
 
@@ -1161,7 +1086,7 @@ U.Search = L.PhotonSearch.extend({
1161
1086
  if (latlng.isValid()) {
1162
1087
  this.reverse.doReverse(latlng)
1163
1088
  } else {
1164
- this.map.ui.alert({ content: 'Invalid latitude or longitude', mode: 'error' })
1089
+ U.Alert.error(L._('Invalid latitude or longitude'))
1165
1090
  }
1166
1091
  return
1167
1092
  }
@@ -1324,7 +1249,7 @@ U.Editable = L.Editable.extend({
1324
1249
  L.Editable.prototype.initialize.call(this, map, options)
1325
1250
  this.on('editable:drawing:click editable:drawing:move', this.drawingTooltip)
1326
1251
  this.on('editable:drawing:end', (e) => {
1327
- this.closeTooltip()
1252
+ this.map.tooltip.close()
1328
1253
  // Leaflet.Editable will delete the drawn shape if invalid
1329
1254
  // (eg. line has only one drawn point)
1330
1255
  // So let's check if the layer has no more shape
@@ -1388,7 +1313,7 @@ U.Editable = L.Editable.extend({
1388
1313
 
1389
1314
  drawingTooltip: function (e) {
1390
1315
  if (e.layer instanceof L.Marker && e.type == 'editable:drawing:start') {
1391
- this.map.ui.tooltip({ content: L._('Click to add a marker') })
1316
+ this.map.tooltip.open({ content: L._('Click to add a marker') })
1392
1317
  }
1393
1318
  if (!(e.layer instanceof L.Polyline)) {
1394
1319
  // only continue with Polylines and Polygons
@@ -1431,7 +1356,7 @@ U.Editable = L.Editable.extend({
1431
1356
  }
1432
1357
  }
1433
1358
  if (content) {
1434
- this.map.ui.tooltip({ content: content })
1359
+ this.map.tooltip.open({ content: content })
1435
1360
  }
1436
1361
  },
1437
1362
 
@@ -139,7 +139,7 @@ L.DomUtil.createButtonIcon = (parent, className, title, size = 16) => {
139
139
 
140
140
  L.DomUtil.createTitle = (parent, text, className, tag = 'h3') => {
141
141
  const title = L.DomUtil.create(tag, '', parent)
142
- L.DomUtil.createIcon(title, className)
142
+ if (className) L.DomUtil.createIcon(title, className)
143
143
  L.DomUtil.add('span', '', title, text)
144
144
  return title
145
145
  }
@@ -162,11 +162,6 @@ L.DomUtil.createCopiableInput = (parent, label, value) => {
162
162
  return input
163
163
  }
164
164
 
165
- L.DomUtil.classIf = (el, className, bool) => {
166
- if (bool) L.DomUtil.addClass(el, className)
167
- else L.DomUtil.removeClass(el, className)
168
- }
169
-
170
165
  L.DomUtil.element = ({ tagName, parent, ...attrs }) => {
171
166
  const el = document.createElement(tagName)
172
167
  if (attrs.innerHTML) {
@@ -250,327 +245,6 @@ L.DomEvent.once = (el, types, fn, context) => {
250
245
  return L.DomEvent.on(el, types, fn, context).on(el, types, handler, context)
251
246
  }
252
247
 
253
- /*
254
- * Global events
255
- */
256
- U.Keys = {
257
- LEFT: 37,
258
- UP: 38,
259
- RIGHT: 39,
260
- DOWN: 40,
261
- TAB: 9,
262
- ENTER: 13,
263
- ESC: 27,
264
- APPLE: 91,
265
- SHIFT: 16,
266
- ALT: 17,
267
- CTRL: 18,
268
- E: 69,
269
- F: 70,
270
- H: 72,
271
- I: 73,
272
- L: 76,
273
- M: 77,
274
- O: 79,
275
- P: 80,
276
- S: 83,
277
- Z: 90,
278
- }
279
-
280
- U.Help = L.Class.extend({
281
- SHORTCUTS: {
282
- DRAW_MARKER: {
283
- shortcut: 'Modifier+M',
284
- label: L._('Draw a marker'),
285
- },
286
- DRAW_LINE: {
287
- shortcut: 'Modifier+L',
288
- label: L._('Draw a polyline'),
289
- },
290
- DRAW_POLYGON: {
291
- shortcut: 'Modifier+P',
292
- label: L._('Draw a polygon'),
293
- },
294
- TOGGLE_EDIT: {
295
- shortcut: 'Modifier+E',
296
- label: L._('Toggle edit mode'),
297
- },
298
- STOP_EDIT: {
299
- shortcut: 'Modifier+E',
300
- label: L._('Stop editing'),
301
- },
302
- SAVE_MAP: {
303
- shortcut: 'Modifier+S',
304
- label: L._('Save map'),
305
- },
306
- IMPORT_PANEL: {
307
- shortcut: 'Modifier+I',
308
- label: L._('Import data'),
309
- },
310
- SEARCH: {
311
- shortcut: 'Modifier+F',
312
- label: L._('Search location'),
313
- },
314
- CANCEL: {
315
- shortcut: 'Modifier+Z',
316
- label: L._('Cancel edits'),
317
- },
318
- PREVIEW: {
319
- shortcut: 'Modifier+E',
320
- label: L._('Back to preview'),
321
- },
322
- SAVE: {
323
- shortcut: 'Modifier+S',
324
- label: L._('Save current edits'),
325
- },
326
- EDIT_FEATURE_LAYER: {
327
- shortcut: 'Modifier+⇧+Click',
328
- label: L._("Edit feature's layer"),
329
- },
330
- CONTINUE_LINE: {
331
- shortcut: 'Modifier+Click',
332
- label: L._('Continue line'),
333
- },
334
- },
335
-
336
- displayLabel: function (action, withKbdTag = true) {
337
- let { shortcut, label } = this.SHORTCUTS[action]
338
- const modifier = this.isMacOS ? 'Cmd' : 'Ctrl'
339
- shortcut = shortcut.replace('Modifier', modifier)
340
- if (withKbdTag) {
341
- shortcut = shortcut
342
- .split('+')
343
- .map((el) => `<kbd>${el}</kbd>`)
344
- .join('+')
345
- label += ` ${shortcut}`
346
- } else {
347
- label += ` (${shortcut})`
348
- }
349
- return label
350
- },
351
-
352
- initialize: function (map) {
353
- this.map = map
354
- this.box = L.DomUtil.create(
355
- 'div',
356
- 'umap-help-box with-transition dark',
357
- document.body
358
- )
359
- const closeButton = L.DomUtil.createButton(
360
- 'umap-close-link',
361
- this.box,
362
- '',
363
- this.hide,
364
- this
365
- )
366
- L.DomUtil.add('i', 'umap-close-icon', closeButton)
367
- const label = L.DomUtil.create('span', '', closeButton)
368
- label.title = label.textContent = L._('Close')
369
- this.content = L.DomUtil.create('div', 'umap-help-content', this.box)
370
- this.isMacOS = /mac/i.test(
371
- // eslint-disable-next-line compat/compat -- Fallback available.
372
- navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform
373
- )
374
- },
375
-
376
- onKeyDown: function (e) {
377
- const key = e.keyCode,
378
- ESC = 27
379
- if (key === ESC) {
380
- this.hide()
381
- }
382
- },
383
-
384
- show: function () {
385
- this.content.innerHTML = ''
386
- for (let i = 0, name; i < arguments.length; i++) {
387
- name = arguments[i]
388
- L.DomUtil.add('div', 'umap-help-entry', this.content, this.resolve(name))
389
- }
390
- L.DomUtil.addClass(document.body, 'umap-help-on')
391
- },
392
-
393
- hide: function () {
394
- L.DomUtil.removeClass(document.body, 'umap-help-on')
395
- },
396
-
397
- visible: function () {
398
- return L.DomUtil.hasClass(document.body, 'umap-help-on')
399
- },
400
-
401
- resolve: function (name) {
402
- return typeof this[name] === 'function' ? this[name]() : this[name]
403
- },
404
-
405
- button: function (container, entries, classname) {
406
- const helpButton = L.DomUtil.createButton(
407
- classname || 'umap-help-button',
408
- container,
409
- L._('Help')
410
- )
411
- if (entries) {
412
- L.DomEvent.on(helpButton, 'click', L.DomEvent.stop).on(
413
- helpButton,
414
- 'click',
415
- function (e) {
416
- const args = typeof entries === 'string' ? [entries] : entries
417
- this.show.apply(this, args)
418
- },
419
- this
420
- )
421
- }
422
- return helpButton
423
- },
424
-
425
- link: function (container, entries) {
426
- const helpButton = this.button(container, entries, 'umap-help-link')
427
- helpButton.textContent = L._('Help')
428
- return helpButton
429
- },
430
-
431
- edit: function () {
432
- const container = L.DomUtil.create('div', ''),
433
- self = this,
434
- title = L.DomUtil.create('h3', '', container),
435
- actionsContainer = L.DomUtil.create('ul', 'umap-edit-actions', container)
436
- const addAction = (action) => {
437
- const actionContainer = L.DomUtil.add('li', '', actionsContainer)
438
- L.DomUtil.add('i', action.options.className, actionContainer),
439
- L.DomUtil.add('span', '', actionContainer, action.options.tooltip)
440
- L.DomEvent.on(actionContainer, 'click', action.addHooks, action)
441
- L.DomEvent.on(actionContainer, 'click', self.hide, self)
442
- }
443
- title.textContent = L._('Where do we go from here?')
444
- for (const id in this.map.helpMenuActions) {
445
- addAction(this.map.helpMenuActions[id])
446
- }
447
- return container
448
- },
449
-
450
- importFormats: function () {
451
- const container = L.DomUtil.create('div')
452
- L.DomUtil.add('h3', '', container, 'GeojSON')
453
- L.DomUtil.add('p', '', container, L._('All properties are imported.'))
454
- L.DomUtil.add('h3', '', container, 'GPX')
455
- L.DomUtil.add('p', '', container, `${L._('Properties imported:')}name, desc`)
456
- L.DomUtil.add('h3', '', container, 'KML')
457
- L.DomUtil.add('p', '', container, `${L._('Properties imported:')}name, description`)
458
- L.DomUtil.add('h3', '', container, 'CSV')
459
- L.DomUtil.add(
460
- 'p',
461
- '',
462
- container,
463
- L._(
464
- 'Comma, tab or semi-colon separated values. SRS WGS84 is implied. Only Point geometries are imported. The import will look at the column headers for any mention of «lat» and «lon» at the begining of the header, case insensitive. All other column are imported as properties.'
465
- )
466
- )
467
- L.DomUtil.add('h3', '', container, 'uMap')
468
- L.DomUtil.add(
469
- 'p',
470
- '',
471
- container,
472
- L._('Imports all umap data, including layers and settings.')
473
- )
474
- return container
475
- },
476
-
477
- textFormatting: function () {
478
- const container = L.DomUtil.create('div'),
479
- title = L.DomUtil.add('h3', '', container, L._('Text formatting')),
480
- elements = L.DomUtil.create('ul', '', container)
481
- L.DomUtil.add('li', '', elements, L._('*single star for italic*'))
482
- L.DomUtil.add('li', '', elements, L._('**double star for bold**'))
483
- L.DomUtil.add('li', '', elements, L._('# one hash for main heading'))
484
- L.DomUtil.add('li', '', elements, L._('## two hashes for second heading'))
485
- L.DomUtil.add('li', '', elements, L._('### three hashes for third heading'))
486
- L.DomUtil.add('li', '', elements, L._('Simple link: [[http://example.com]]'))
487
- L.DomUtil.add(
488
- 'li',
489
- '',
490
- elements,
491
- L._('Link with text: [[http://example.com|text of the link]]')
492
- )
493
- L.DomUtil.add('li', '', elements, L._('Image: {{http://image.url.com}}'))
494
- L.DomUtil.add(
495
- 'li',
496
- '',
497
- elements,
498
- L._('Image with custom width (in px): {{http://image.url.com|width}}')
499
- )
500
- L.DomUtil.add('li', '', elements, L._('Iframe: {{{http://iframe.url.com}}}'))
501
- L.DomUtil.add(
502
- 'li',
503
- '',
504
- elements,
505
- L._('Iframe with custom height (in px): {{{http://iframe.url.com|height}}}')
506
- )
507
- L.DomUtil.add(
508
- 'li',
509
- '',
510
- elements,
511
- L._(
512
- 'Iframe with custom height and width (in px): {{{http://iframe.url.com|height*width}}}'
513
- )
514
- )
515
- L.DomUtil.add('li', '', elements, L._('--- for a horizontal rule'))
516
- return container
517
- },
518
-
519
- dynamicProperties: function () {
520
- const container = L.DomUtil.create('div')
521
- L.DomUtil.add('h3', '', container, L._('Dynamic properties'))
522
- L.DomUtil.add(
523
- 'p',
524
- '',
525
- container,
526
- L._(
527
- 'Use placeholders with feature properties between brackets, eg. &#123;name&#125;, they will be dynamically replaced by the corresponding values.'
528
- )
529
- )
530
- return container
531
- },
532
-
533
- formatURL: `${L._(
534
- 'Supported variables that will be dynamically replaced'
535
- )}: {bbox}, {lat}, {lng}, {zoom}, {east}, {north}..., {left}, {top}..., locale, lang`,
536
- colorValue: L._('Must be a valid CSS value (eg.: DarkBlue or #123456)'),
537
- smoothFactor: L._(
538
- 'How much to simplify the polyline on each zoom level (more = better performance and smoother look, less = more accurate)'
539
- ),
540
- dashArray: L._(
541
- 'A comma separated list of numbers that defines the stroke dash pattern. Ex.: "5, 10, 15".'
542
- ),
543
- zoomTo: L._('Zoom level for automatic zooms'),
544
- labelKey: L._(
545
- 'The name of the property to use as feature label (eg.: "nom"). You can also use properties inside brackets to use more than one or mix with static content (eg.: "&lcub;name&rcub; in &lcub;place&rcub;")'
546
- ),
547
- stroke: L._('Whether to display or not polygons paths.'),
548
- fill: L._('Whether to fill polygons with color.'),
549
- fillColor: L._('Optional. Same as color if not set.'),
550
- shortCredit: L._('Will be displayed in the bottom right corner of the map'),
551
- longCredit: L._('Will be visible in the caption of the map'),
552
- permanentCredit: L._(
553
- 'Will be permanently visible in the bottom left corner of the map'
554
- ),
555
- sortKey: L._(
556
- 'Comma separated list of properties to use for sorting features. To reverse the sort, put a minus sign (-) before. Eg. mykey,-otherkey.'
557
- ),
558
- slugKey: L._('The name of the property to use as feature unique identifier.'),
559
- filterKey: L._('Comma separated list of properties to use when filtering features by text input'),
560
- facetKey: L._(
561
- 'Comma separated list of properties to use for filters (eg.: mykey,otherkey). To control label, add it after a | (eg.: mykey|My Key,otherkey|Other Key). To control input field type, add it after another | (eg.: mykey|My Key|checkbox,otherkey|Other Key|datetime). Allowed values for the input field type are checkbox (default), radio, number, date and datetime.'
562
- ),
563
- interactive: L._(
564
- 'If false, the polygon or line will act as a part of the underlying map.'
565
- ),
566
- outlink: L._('Define link to open in a new window on polygon click.'),
567
- dynamicRemoteData: L._('Fetch data each time map view changes.'),
568
- proxyRemoteData: L._("To use if remote server doesn't allow cross domain (slower)"),
569
- browsable: L._(
570
- 'Set it to false to hide this layer from the slideshow, the data browser, the popup navigation…'
571
- ),
572
- })
573
-
574
248
  L.LatLng.prototype.isValid = function () {
575
249
  return (
576
250
  isFinite(this.lat) &&