merge index.js with global.js

This commit is contained in:
Alexis Métaireau 2024-01-08 19:14:10 +01:00
parent 7c697f7529
commit 4b34a7d300
7 changed files with 63 additions and 68 deletions

View file

@ -1,5 +1,8 @@
import * as L from '../../vendors/leaflet/leaflet-src.esm.js' import * as L from '../../vendors/leaflet/leaflet-src.esm.js'
import URLs from './urls.js'
// Import modules and export them to the global scope.
// For the not yet module-compatible JS out there.
// Exposes the modules to the window global scope, it's expected by leaflet plugins // Copy the leaflet module, it's expected by leaflet plugins to be writeable.
// in a writeable form.
window.L = { ...L } window.L = { ...L }
window.umap = { URLs }

View file

@ -1,6 +0,0 @@
import URLs from './urls.js'
// expose the modules to the window.umap global scope
window.umap = { URLs }
export { URLs }

View file

@ -29,7 +29,6 @@
<script src="../vendors/iconlayers/iconLayers.js" defer></script> <script src="../vendors/iconlayers/iconLayers.js" defer></script>
<script src="../vendors/simple-statistics/simple-statistics.min.js" defer></script> <script src="../vendors/simple-statistics/simple-statistics.min.js" defer></script>
<script src="../vendors/colorbrewer/colorbrewer.js" defer></script> <script src="../vendors/colorbrewer/colorbrewer.js" defer></script>
<script type="module" src="../js/modules/index.js" defer></script>
<script src="../js/umap.core.js" defer></script> <script src="../js/umap.core.js" defer></script>
<script src="../js/umap.autocomplete.js" defer></script> <script src="../js/umap.autocomplete.js" defer></script>
<script src="../js/umap.popup.js" defer></script> <script src="../js/umap.popup.js" defer></script>

View file

@ -38,7 +38,7 @@
{% block bottom_js %} {% block bottom_js %}
{{ block.super }} {{ block.super }}
<script type="text/javascript"> <script type="text/javascript">
window.addEventListener('load', (event => { window.addEventListener('DOMContentLoaded', (event => {
!(function () { !(function () {
const ui = new L.U.UI(document.querySelector('header')) const ui = new L.U.UI(document.querySelector('header'))

View file

@ -1,62 +1,61 @@
{% load compress %} {% load compress %}
{% compress js %} {% compress js %}
<script type="module" src="{{ STATIC_URL }}umap/js/modules/global.js" defer></script> <script type="module" src="{{ STATIC_URL }}umap/js/modules/global.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/editable/Path.Drag.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/editable/Path.Drag.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/editable/Leaflet.Editable.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/editable/Leaflet.Editable.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/hash/leaflet-hash.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/hash/leaflet-hash.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/i18n/Leaflet.i18n.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/i18n/Leaflet.i18n.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/editinosm/Leaflet.EditInOSM.js" <script src="{{ STATIC_URL }}umap/vendors/editinosm/Leaflet.EditInOSM.js"
defer></script> defer></script>
<script src="{{ STATIC_URL }}umap/vendors/minimap/Control.MiniMap.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/minimap/Control.MiniMap.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/csv2geojson/csv2geojson.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/csv2geojson/csv2geojson.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/togeojson/togeojson.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/togeojson/togeojson.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/osmtogeojson/osmtogeojson.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/osmtogeojson/osmtogeojson.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/loading/Control.Loading.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/loading/Control.Loading.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/markercluster/leaflet.markercluster-src.js" <script src="{{ STATIC_URL }}umap/vendors/markercluster/leaflet.markercluster-src.js"
defer></script> defer></script>
<script src="{{ STATIC_URL }}umap/vendors/contextmenu/leaflet.contextmenu.js" <script src="{{ STATIC_URL }}umap/vendors/contextmenu/leaflet.contextmenu.js"
defer></script> defer></script>
<script src="{{ STATIC_URL }}umap/vendors/photon/leaflet.photon.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/photon/leaflet.photon.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/georsstogeojson/GeoRSSToGeoJSON.js" <script src="{{ STATIC_URL }}umap/vendors/georsstogeojson/GeoRSSToGeoJSON.js"
defer></script> defer></script>
<script src="{{ STATIC_URL }}umap/vendors/heat/leaflet-heat.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/heat/leaflet-heat.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/fullscreen/Leaflet.fullscreen.js" <script src="{{ STATIC_URL }}umap/vendors/fullscreen/Leaflet.fullscreen.js"
defer></script> defer></script>
<script src="{{ STATIC_URL }}umap/vendors/toolbar/leaflet.toolbar-src.js" <script src="{{ STATIC_URL }}umap/vendors/toolbar/leaflet.toolbar-src.js"
defer></script> defer></script>
<script src="{{ STATIC_URL }}umap/vendors/formbuilder/Leaflet.FormBuilder.js" <script src="{{ STATIC_URL }}umap/vendors/formbuilder/Leaflet.FormBuilder.js"
defer></script> defer></script>
<script src="{{ STATIC_URL }}umap/vendors/measurable/Leaflet.Measurable.js" <script src="{{ STATIC_URL }}umap/vendors/measurable/Leaflet.Measurable.js"
defer></script> defer></script>
<script src="{{ STATIC_URL }}umap/vendors/togpx/togpx.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/togpx/togpx.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/iconlayers/iconLayers.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/iconlayers/iconLayers.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/tokml/tokml.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/tokml/tokml.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/locatecontrol/L.Control.Locate.js" <script src="{{ STATIC_URL }}umap/vendors/locatecontrol/L.Control.Locate.js"
defer></script> defer></script>
<script src="{{ STATIC_URL }}umap/vendors/dompurify/purify.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/dompurify/purify.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/colorbrewer/colorbrewer.js" defer></script> <script src="{{ STATIC_URL }}umap/vendors/colorbrewer/colorbrewer.js" defer></script>
<script src="{{ STATIC_URL }}umap/vendors/simple-statistics/simple-statistics.min.js" <script src="{{ STATIC_URL }}umap/vendors/simple-statistics/simple-statistics.min.js"
defer></script> defer></script>
{% endcompress %} {% endcompress %}
{% if locale %}<script src="{{ STATIC_URL }}umap/locale/{{ locale }}.js" defer></script>{% endif %} {% if locale %}<script src="{{ STATIC_URL }}umap/locale/{{ locale }}.js" defer></script>{% endif %}
{% compress js %} {% compress js %}
<script type="module" src="{{ STATIC_URL }}umap/js/modules/index.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.core.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.core.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.autocomplete.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.autocomplete.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.popup.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.popup.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.xhr.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.xhr.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.forms.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.forms.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.icon.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.icon.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.features.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.features.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.permissions.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.permissions.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.datalayer.permissions.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.datalayer.permissions.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.layer.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.layer.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.controls.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.controls.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.slideshow.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.slideshow.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.tableeditor.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.tableeditor.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.browser.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.browser.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.importer.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.importer.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.share.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.share.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.js" defer></script> <script src="{{ STATIC_URL }}umap/js/umap.ui.js" defer></script>
<script src="{{ STATIC_URL }}umap/js/umap.ui.js" defer></script>
{% endcompress %} {% endcompress %}

View file

@ -3,7 +3,7 @@
<!-- djlint:off --> <!-- djlint:off -->
<script type="text/javascript"> <script type="text/javascript">
// Wait for JS modules to be loaded // Wait for JS modules to be loaded
window.addEventListener('load', (event) => { window.addEventListener('DOMContentLoaded', (event) => {
new L.U.Map("{{ unique_id }}", {{ map_settings|notag|safe }}) new L.U.Map("{{ unique_id }}", {{ map_settings|notag|safe }})
}); });
</script> </script>

View file

@ -2,7 +2,7 @@
<div id="map"></div> <div id="map"></div>
<!-- djlint:off --> <!-- djlint:off -->
<script defer type="text/javascript"> <script defer type="text/javascript">
window.addEventListener('load', (event) => { window.addEventListener('DOMContentLoaded', (event) => {
let MAP = new L.U.Map("map", {{ map_settings|notag|safe }}); let MAP = new L.U.Map("map", {{ map_settings|notag|safe }});
}); });
</script> </script>