diff --git a/umap/static/umap/js/modules/global.js b/umap/static/umap/js/modules/global.js index d73356d4..85fff749 100644 --- a/umap/static/umap/js/modules/global.js +++ b/umap/static/umap/js/modules/global.js @@ -7,4 +7,4 @@ import { Request, ServerRequest, RequestError, HTTPError, NOKError } from './req // Copy the leaflet module, it's expected by leaflet plugins to be writeable. window.L = { ...L } -window.umap = { URLs, Request, ServerRequest, RequestError, HTTPError, NOKError, Browser } +window.L.U = { URLs, Request, ServerRequest, RequestError, HTTPError, NOKError, Browser } diff --git a/umap/static/umap/js/umap.autocomplete.js b/umap/static/umap/js/umap.autocomplete.js index cbc43153..f86c93a0 100644 --- a/umap/static/umap/js/umap.autocomplete.js +++ b/umap/static/umap/js/umap.autocomplete.js @@ -13,7 +13,7 @@ L.U.AutoComplete = L.Class.extend({ initialize: function (el, options) { this.el = el const ui = new L.U.UI(document.querySelector('header')) - this.server = new window.umap.ServerRequest(ui) + this.server = new L.U.ServerRequest(ui) L.setOptions(this, options) let CURRENT = null try { diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 0b0817b2..60c3999c 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -739,7 +739,19 @@ L.U.DataLayer.addInitHook(function () { if (this.isVisible()) this.propagateShow() }) -L.U.Map.include({ +const ControlsMixin = { + HIDDABLE_CONTROLS: [ + 'zoom', + 'search', + 'fullscreen', + 'embed', + 'locate', + 'measure', + 'editinosm', + 'datalayers', + 'star', + 'tilelayers', + ], _openFacet: function () { const container = L.DomUtil.create('div', 'umap-facet-search'), title = L.DomUtil.add('h3', 'umap-filter-title', container, L._('Facet search')), @@ -1043,7 +1055,7 @@ L.U.Map.include({ this ) }, -}) +} /* Used in view mode to define the current tilelayer */ L.U.TileLayerControl = L.Control.IconLayers.extend({ @@ -1065,7 +1077,10 @@ L.U.TileLayerControl = L.Control.IconLayers.extend({ // when the tilelayer is actually added to the map (needs this._tileZoom // to be defined) // Fixme when https://github.com/Leaflet/Leaflet/pull/9201 is released - const icon = L.Util.template(layer.options.url_template, this.map.demoTileInfos) + const icon = L.Util.template( + layer.options.url_template, + this.map.demoTileInfos + ) layers.push({ title: layer.options.name, layer: layer, diff --git a/umap/static/umap/js/umap.core.js b/umap/static/umap/js/umap.core.js index 2f5a845f..d7f0f859 100644 --- a/umap/static/umap/js/umap.core.js +++ b/umap/static/umap/js/umap.core.js @@ -1,9 +1,3 @@ -/* Poor man pub/sub handler, enough for now */ - -L.UmapSingleton = L.Evented.extend({}) -L.U = new L.UmapSingleton() -L.U.Map = L.Map.extend({}) - /* * Utils */ diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index cee3d54d..8efca54d 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -55,20 +55,8 @@ L.Map.mergeOptions({ featuresHaveOwner: false, }) -L.U.Map.include({ - HIDDABLE_CONTROLS: [ - 'zoom', - 'search', - 'fullscreen', - 'embed', - 'locate', - 'measure', - 'editinosm', - 'datalayers', - 'star', - 'tilelayers', - ], - +L.U.Map = L.Map.extend({ + includes: [ControlsMixin], editableOptions: { 'zoom': undefined, 'scrollWheelZoom': Boolean, @@ -154,13 +142,13 @@ L.U.Map.include({ // After calling parent initialize, as we are doing initCenter our-selves if (geojson.geometry) this.options.center = this.latLng(geojson.geometry) - this.urls = new window.umap.URLs(this.options.urls) + this.urls = new L.U.URLs(this.options.urls) this.ui = new L.U.UI(this._container) this.ui.on('dataloading', (e) => this.fire('dataloading', e)) this.ui.on('dataload', (e) => this.fire('dataload', e)) - this.server = new window.umap.ServerRequest(this.ui) - this.request = new window.umap.Request(this.ui) + this.server = new L.U.ServerRequest(this.ui) + this.request = new L.U.Request(this.ui) this.initLoader() this.name = this.options.name diff --git a/umap/templates/umap/content.html b/umap/templates/umap/content.html index bf414571..8b987860 100644 --- a/umap/templates/umap/content.html +++ b/umap/templates/umap/content.html @@ -39,7 +39,7 @@