Merge pull request #1587 from umap-project/use-global-l

chore: do not introduce a new global, use L and L.U already there
This commit is contained in:
Yohan Boniface 2024-02-09 18:04:48 +01:00 committed by GitHub
commit a0634e5f55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 359 additions and 362 deletions

View file

@ -1,6 +1,6 @@
class UmapFragment extends HTMLElement { class UmapFragment extends HTMLElement {
connectedCallback() { connectedCallback() {
new L.U.Map(this.firstElementChild.id, JSON.parse(this.dataset.settings)) new U.Map(this.firstElementChild.id, JSON.parse(this.dataset.settings))
} }
} }

View file

@ -22,7 +22,7 @@ export default class Browser {
colorBox = DomUtil.create('i', 'feature-color', feature_li), colorBox = DomUtil.create('i', 'feature-color', feature_li),
title = DomUtil.create('span', 'feature-title', feature_li), title = DomUtil.create('span', 'feature-title', feature_li),
symbol = feature._getIconUrl symbol = feature._getIconUrl
? L.U.Icon.prototype.formatUrl(feature._getIconUrl(), feature) ? U.Icon.prototype.formatUrl(feature._getIconUrl(), feature)
: null : null
zoom_to.title = L._('Bring feature to center') zoom_to.title = L._('Bring feature to center')
edit.title = L._('Edit this feature') edit.title = L._('Edit this feature')
@ -31,8 +31,8 @@ export default class Browser {
const bgcolor = feature.getDynamicOption('color') const bgcolor = feature.getDynamicOption('color')
colorBox.style.backgroundColor = bgcolor colorBox.style.backgroundColor = bgcolor
if (symbol && symbol !== this.map.options.default_iconUrl) { if (symbol && symbol !== this.map.options.default_iconUrl) {
const icon = L.U.Icon.makeIconElement(symbol, colorBox) const icon = U.Icon.makeIconElement(symbol, colorBox)
L.U.Icon.setIconContrast(icon, colorBox, symbol, bgcolor) U.Icon.setIconContrast(icon, colorBox, symbol, bgcolor)
} }
DomEvent.on( DomEvent.on(
zoom_to, zoom_to,
@ -141,7 +141,7 @@ export default class Browser {
['options.filter', { handler: 'Input', placeholder: L._('Filter') }], ['options.filter', { handler: 'Input', placeholder: L._('Filter') }],
['options.inBbox', { handler: 'Switch', label: L._('Current map view') }], ['options.inBbox', { handler: 'Switch', label: L._('Current map view') }],
] ]
const builder = new L.U.FormBuilder(this, fields, { const builder = new U.FormBuilder(this, fields, {
makeDirty: false, makeDirty: false,
callback: () => this.onFormChange(), callback: () => this.onFormChange(),
}) })

View file

@ -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. // Copy the leaflet module, it's expected by leaflet plugins to be writeable.
window.L = { ...L } window.L = { ...L }
window.umap = { URLs, Request, ServerRequest, RequestError, HTTPError, NOKError, Browser } window.U = { URLs, Request, ServerRequest, RequestError, HTTPError, NOKError, Browser }

View file

@ -1,4 +1,4 @@
L.U.AutoComplete = L.Class.extend({ U.AutoComplete = L.Class.extend({
options: { options: {
placeholder: 'Start typing...', placeholder: 'Start typing...',
emptyMessage: 'No result', emptyMessage: 'No result',
@ -12,8 +12,8 @@ L.U.AutoComplete = L.Class.extend({
initialize: function (el, options) { initialize: function (el, options) {
this.el = el this.el = el
const ui = new L.U.UI(document.querySelector('header')) const ui = new U.UI(document.querySelector('header'))
this.server = new window.umap.ServerRequest(ui) this.server = new U.ServerRequest(ui)
L.setOptions(this, options) L.setOptions(this, options)
let CURRENT = null let CURRENT = null
try { try {
@ -69,19 +69,19 @@ L.U.AutoComplete = L.Class.extend({
onKeyDown: function (e) { onKeyDown: function (e) {
switch (e.keyCode) { switch (e.keyCode) {
case L.U.Keys.TAB: case U.Keys.TAB:
if (this.CURRENT !== null) this.setChoice() if (this.CURRENT !== null) this.setChoice()
L.DomEvent.stop(e) L.DomEvent.stop(e)
break break
case L.U.Keys.ENTER: case U.Keys.ENTER:
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.setChoice() this.setChoice()
break break
case L.U.Keys.ESC: case U.Keys.ESC:
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.hide() this.hide()
break break
case L.U.Keys.DOWN: case U.Keys.DOWN:
if (this.RESULTS.length > 0) { if (this.RESULTS.length > 0) {
if (this.CURRENT !== null && this.CURRENT < this.RESULTS.length - 1) { if (this.CURRENT !== null && this.CURRENT < this.RESULTS.length - 1) {
// what if one result? // what if one result?
@ -93,7 +93,7 @@ L.U.AutoComplete = L.Class.extend({
} }
} }
break break
case L.U.Keys.UP: case U.Keys.UP:
if (this.CURRENT !== null) { if (this.CURRENT !== null) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
} }
@ -112,16 +112,16 @@ L.U.AutoComplete = L.Class.extend({
onKeyUp: function (e) { onKeyUp: function (e) {
const special = [ const special = [
L.U.Keys.TAB, U.Keys.TAB,
L.U.Keys.ENTER, U.Keys.ENTER,
L.U.Keys.LEFT, U.Keys.LEFT,
L.U.Keys.RIGHT, U.Keys.RIGHT,
L.U.Keys.DOWN, U.Keys.DOWN,
L.U.Keys.UP, U.Keys.UP,
L.U.Keys.APPLE, U.Keys.APPLE,
L.U.Keys.SHIFT, U.Keys.SHIFT,
L.U.Keys.ALT, U.Keys.ALT,
L.U.Keys.CTRL, U.Keys.CTRL,
] ]
if (special.indexOf(e.keyCode) === -1) { if (special.indexOf(e.keyCode) === -1) {
this.search() this.search()
@ -255,9 +255,9 @@ L.U.AutoComplete = L.Class.extend({
}, },
}) })
L.U.AutoComplete.Ajax = L.U.AutoComplete.extend({ U.AutoComplete.Ajax = U.AutoComplete.extend({
initialize: function (el, options) { initialize: function (el, options) {
L.U.AutoComplete.prototype.initialize.call(this, el, options) U.AutoComplete.prototype.initialize.call(this, el, options)
if (!this.el) return this if (!this.el) return this
this.createInput() this.createInput()
this.createContainer() this.createContainer()
@ -272,7 +272,7 @@ L.U.AutoComplete.Ajax = L.U.AutoComplete.extend({
}, },
}) })
L.U.AutoComplete.Ajax.SelectMultiple = L.U.AutoComplete.Ajax.extend({ U.AutoComplete.Ajax.SelectMultiple = U.AutoComplete.Ajax.extend({
initSelectedContainer: function () { initSelectedContainer: function () {
return L.DomUtil.after( return L.DomUtil.after(
this.input, this.input,
@ -298,7 +298,7 @@ L.U.AutoComplete.Ajax.SelectMultiple = L.U.AutoComplete.Ajax.extend({
}, },
}) })
L.U.AutoComplete.Ajax.Select = L.U.AutoComplete.Ajax.extend({ U.AutoComplete.Ajax.Select = U.AutoComplete.Ajax.extend({
initSelectedContainer: function () { initSelectedContainer: function () {
return L.DomUtil.after( return L.DomUtil.after(
this.input, this.input,

View file

@ -1,4 +1,4 @@
L.U.BaseAction = L.ToolbarAction.extend({ U.BaseAction = L.ToolbarAction.extend({
initialize: function (map) { initialize: function (map) {
this.map = map this.map = map
if (this.options.label) { if (this.options.label) {
@ -17,7 +17,7 @@ L.U.BaseAction = L.ToolbarAction.extend({
}, },
}) })
L.U.ImportAction = L.U.BaseAction.extend({ U.ImportAction = U.BaseAction.extend({
options: { options: {
helpMenu: true, helpMenu: true,
className: 'upload-data dark', className: 'upload-data dark',
@ -29,7 +29,7 @@ L.U.ImportAction = L.U.BaseAction.extend({
}, },
}) })
L.U.EditPropertiesAction = L.U.BaseAction.extend({ U.EditPropertiesAction = U.BaseAction.extend({
options: { options: {
helpMenu: true, helpMenu: true,
className: 'update-map-settings dark', className: 'update-map-settings dark',
@ -41,7 +41,7 @@ L.U.EditPropertiesAction = L.U.BaseAction.extend({
}, },
}) })
L.U.ChangeTileLayerAction = L.U.BaseAction.extend({ U.ChangeTileLayerAction = U.BaseAction.extend({
options: { options: {
helpMenu: true, helpMenu: true,
className: 'dark update-map-tilelayers', className: 'dark update-map-tilelayers',
@ -53,7 +53,7 @@ L.U.ChangeTileLayerAction = L.U.BaseAction.extend({
}, },
}) })
L.U.ManageDatalayersAction = L.U.BaseAction.extend({ U.ManageDatalayersAction = U.BaseAction.extend({
options: { options: {
className: 'dark manage-datalayers', className: 'dark manage-datalayers',
tooltip: L._('Manage layers'), tooltip: L._('Manage layers'),
@ -64,7 +64,7 @@ L.U.ManageDatalayersAction = L.U.BaseAction.extend({
}, },
}) })
L.U.UpdateExtentAction = L.U.BaseAction.extend({ U.UpdateExtentAction = U.BaseAction.extend({
options: { options: {
className: 'update-map-extent dark', className: 'update-map-extent dark',
tooltip: L._('Save this center and zoom'), tooltip: L._('Save this center and zoom'),
@ -75,7 +75,7 @@ L.U.UpdateExtentAction = L.U.BaseAction.extend({
}, },
}) })
L.U.UpdatePermsAction = L.U.BaseAction.extend({ U.UpdatePermsAction = U.BaseAction.extend({
options: { options: {
className: 'update-map-permissions dark', className: 'update-map-permissions dark',
tooltip: L._('Update permissions and editors'), tooltip: L._('Update permissions and editors'),
@ -86,7 +86,7 @@ L.U.UpdatePermsAction = L.U.BaseAction.extend({
}, },
}) })
L.U.DrawMarkerAction = L.U.BaseAction.extend({ U.DrawMarkerAction = U.BaseAction.extend({
options: { options: {
helpMenu: true, helpMenu: true,
className: 'umap-draw-marker dark', className: 'umap-draw-marker dark',
@ -98,7 +98,7 @@ L.U.DrawMarkerAction = L.U.BaseAction.extend({
}, },
}) })
L.U.DrawPolylineAction = L.U.BaseAction.extend({ U.DrawPolylineAction = U.BaseAction.extend({
options: { options: {
helpMenu: true, helpMenu: true,
className: 'umap-draw-polyline dark', className: 'umap-draw-polyline dark',
@ -110,7 +110,7 @@ L.U.DrawPolylineAction = L.U.BaseAction.extend({
}, },
}) })
L.U.DrawPolygonAction = L.U.BaseAction.extend({ U.DrawPolygonAction = U.BaseAction.extend({
options: { options: {
helpMenu: true, helpMenu: true,
className: 'umap-draw-polygon dark', className: 'umap-draw-polygon dark',
@ -122,7 +122,7 @@ L.U.DrawPolygonAction = L.U.BaseAction.extend({
}, },
}) })
L.U.AddPolylineShapeAction = L.U.BaseAction.extend({ U.AddPolylineShapeAction = U.BaseAction.extend({
options: { options: {
className: 'umap-draw-polyline-multi dark', className: 'umap-draw-polyline-multi dark',
tooltip: L._('Add a line to the current multi'), tooltip: L._('Add a line to the current multi'),
@ -133,14 +133,14 @@ L.U.AddPolylineShapeAction = L.U.BaseAction.extend({
}, },
}) })
L.U.AddPolygonShapeAction = L.U.AddPolylineShapeAction.extend({ U.AddPolygonShapeAction = U.AddPolylineShapeAction.extend({
options: { options: {
className: 'umap-draw-polygon-multi dark', className: 'umap-draw-polygon-multi dark',
tooltip: L._('Add a polygon to the current multi'), tooltip: L._('Add a polygon to the current multi'),
}, },
}) })
L.U.BaseFeatureAction = L.ToolbarAction.extend({ U.BaseFeatureAction = L.ToolbarAction.extend({
initialize: function (map, feature, latlng) { initialize: function (map, feature, latlng) {
this.map = map this.map = map
this.feature = feature this.feature = feature
@ -161,7 +161,7 @@ L.U.BaseFeatureAction = L.ToolbarAction.extend({
}, },
}) })
L.U.CreateHoleAction = L.U.BaseFeatureAction.extend({ U.CreateHoleAction = U.BaseFeatureAction.extend({
options: { options: {
toolbarIcon: { toolbarIcon: {
className: 'umap-new-hole', className: 'umap-new-hole',
@ -174,7 +174,7 @@ L.U.CreateHoleAction = L.U.BaseFeatureAction.extend({
}, },
}) })
L.U.ToggleEditAction = L.U.BaseFeatureAction.extend({ U.ToggleEditAction = U.BaseFeatureAction.extend({
options: { options: {
toolbarIcon: { toolbarIcon: {
className: 'umap-toggle-edit', className: 'umap-toggle-edit',
@ -188,7 +188,7 @@ L.U.ToggleEditAction = L.U.BaseFeatureAction.extend({
}, },
}) })
L.U.DeleteFeatureAction = L.U.BaseFeatureAction.extend({ U.DeleteFeatureAction = U.BaseFeatureAction.extend({
options: { options: {
toolbarIcon: { toolbarIcon: {
className: 'umap-delete-all', className: 'umap-delete-all',
@ -206,7 +206,7 @@ L.U.DeleteFeatureAction = L.U.BaseFeatureAction.extend({
}, },
}) })
L.U.DeleteShapeAction = L.U.BaseFeatureAction.extend({ U.DeleteShapeAction = U.BaseFeatureAction.extend({
options: { options: {
toolbarIcon: { toolbarIcon: {
className: 'umap-delete-one-of-multi', className: 'umap-delete-one-of-multi',
@ -219,7 +219,7 @@ L.U.DeleteShapeAction = L.U.BaseFeatureAction.extend({
}, },
}) })
L.U.ExtractShapeFromMultiAction = L.U.BaseFeatureAction.extend({ U.ExtractShapeFromMultiAction = U.BaseFeatureAction.extend({
options: { options: {
toolbarIcon: { toolbarIcon: {
className: 'umap-extract-shape-from-multi', className: 'umap-extract-shape-from-multi',
@ -232,14 +232,14 @@ L.U.ExtractShapeFromMultiAction = L.U.BaseFeatureAction.extend({
}, },
}) })
L.U.BaseVertexAction = L.U.BaseFeatureAction.extend({ U.BaseVertexAction = U.BaseFeatureAction.extend({
initialize: function (map, feature, latlng, vertex) { initialize: function (map, feature, latlng, vertex) {
this.vertex = vertex this.vertex = vertex
L.U.BaseFeatureAction.prototype.initialize.call(this, map, feature, latlng) U.BaseFeatureAction.prototype.initialize.call(this, map, feature, latlng)
}, },
}) })
L.U.DeleteVertexAction = L.U.BaseVertexAction.extend({ U.DeleteVertexAction = U.BaseVertexAction.extend({
options: { options: {
toolbarIcon: { toolbarIcon: {
className: 'umap-delete-vertex', className: 'umap-delete-vertex',
@ -252,7 +252,7 @@ L.U.DeleteVertexAction = L.U.BaseVertexAction.extend({
}, },
}) })
L.U.SplitLineAction = L.U.BaseVertexAction.extend({ U.SplitLineAction = U.BaseVertexAction.extend({
options: { options: {
toolbarIcon: { toolbarIcon: {
className: 'umap-split-line', className: 'umap-split-line',
@ -265,7 +265,7 @@ L.U.SplitLineAction = L.U.BaseVertexAction.extend({
}, },
}) })
L.U.ContinueLineAction = L.U.BaseVertexAction.extend({ U.ContinueLineAction = U.BaseVertexAction.extend({
options: { options: {
toolbarIcon: { toolbarIcon: {
className: 'umap-continue-line', className: 'umap-continue-line',
@ -279,13 +279,13 @@ L.U.ContinueLineAction = L.U.BaseVertexAction.extend({
}) })
// Leaflet.Toolbar doesn't allow twice same toolbar class… // Leaflet.Toolbar doesn't allow twice same toolbar class…
L.U.SettingsToolbar = L.Toolbar.Control.extend({ U.SettingsToolbar = L.Toolbar.Control.extend({
addTo: function (map) { addTo: function (map) {
if (map.options.editMode !== 'advanced') return if (map.options.editMode !== 'advanced') return
L.Toolbar.Control.prototype.addTo.call(this, map) L.Toolbar.Control.prototype.addTo.call(this, map)
}, },
}) })
L.U.DrawToolbar = L.Toolbar.Control.extend({ U.DrawToolbar = L.Toolbar.Control.extend({
initialize: function (options) { initialize: function (options) {
L.Toolbar.Control.prototype.initialize.call(this, options) L.Toolbar.Control.prototype.initialize.call(this, options)
this.map = this.options.map this.map = this.options.map
@ -295,18 +295,18 @@ L.U.DrawToolbar = L.Toolbar.Control.extend({
appendToContainer: function (container) { appendToContainer: function (container) {
this.options.actions = [] this.options.actions = []
if (this.map.options.enableMarkerDraw) { if (this.map.options.enableMarkerDraw) {
this.options.actions.push(L.U.DrawMarkerAction) this.options.actions.push(U.DrawMarkerAction)
} }
if (this.map.options.enablePolylineDraw) { if (this.map.options.enablePolylineDraw) {
this.options.actions.push(L.U.DrawPolylineAction) this.options.actions.push(U.DrawPolylineAction)
if (this.map.editedFeature && this.map.editedFeature instanceof L.U.Polyline) { if (this.map.editedFeature && this.map.editedFeature instanceof U.Polyline) {
this.options.actions.push(L.U.AddPolylineShapeAction) this.options.actions.push(U.AddPolylineShapeAction)
} }
} }
if (this.map.options.enablePolygonDraw) { if (this.map.options.enablePolygonDraw) {
this.options.actions.push(L.U.DrawPolygonAction) this.options.actions.push(U.DrawPolygonAction)
if (this.map.editedFeature && this.map.editedFeature instanceof L.U.Polygon) { if (this.map.editedFeature && this.map.editedFeature instanceof U.Polygon) {
this.options.actions.push(L.U.AddPolygonShapeAction) this.options.actions.push(U.AddPolygonShapeAction)
} }
} }
L.Toolbar.Control.prototype.appendToContainer.call(this, container) L.Toolbar.Control.prototype.appendToContainer.call(this, container)
@ -319,7 +319,7 @@ L.U.DrawToolbar = L.Toolbar.Control.extend({
}, },
}) })
L.U.DropControl = L.Class.extend({ U.DropControl = L.Class.extend({
initialize: function (map) { initialize: function (map) {
this.map = map this.map = map
this.dropzone = map._container this.dropzone = map._container
@ -365,7 +365,7 @@ L.U.DropControl = L.Class.extend({
}, },
}) })
L.U.EditControl = L.Control.extend({ U.EditControl = L.Control.extend({
options: { options: {
position: 'topright', position: 'topright',
}, },
@ -418,7 +418,7 @@ L.Control.Embed = L.Control.extend({
}, },
}) })
L.U.MoreControls = L.Control.extend({ U.MoreControls = L.Control.extend({
options: { options: {
position: 'topleft', position: 'topleft',
}, },
@ -451,7 +451,7 @@ L.U.MoreControls = L.Control.extend({
}, },
}) })
L.U.PermanentCreditsControl = L.Control.extend({ U.PermanentCreditsControl = L.Control.extend({
options: { options: {
position: 'bottomleft', position: 'bottomleft',
}, },
@ -488,7 +488,7 @@ L.U.PermanentCreditsControl = L.Control.extend({
}, },
}) })
L.U.DataLayersControl = L.Control.extend({ U.DataLayersControl = L.Control.extend({
options: { options: {
position: 'topleft', position: 'topleft',
}, },
@ -626,7 +626,7 @@ L.U.DataLayersControl = L.Control.extend({
this.map.eachDataLayerReverse(function (datalayer) { this.map.eachDataLayerReverse(function (datalayer) {
this.addDataLayer(container, datalayer, true) this.addDataLayer(container, datalayer, true)
}, this) }, this)
const orderable = new L.U.Orderable(container) const orderable = new U.Orderable(container)
orderable.on( orderable.on(
'drop', 'drop',
function (e) { function (e) {
@ -659,7 +659,7 @@ L.U.DataLayersControl = L.Control.extend({
}, },
}) })
L.U.DataLayer.include({ U.DataLayer.include({
renderLegend: function (container) { renderLegend: function (container) {
if (this.layer.renderLegend) return this.layer.renderLegend(container) if (this.layer.renderLegend) return this.layer.renderLegend(container)
const color = L.DomUtil.create('span', 'datalayer-color', container) const color = L.DomUtil.create('span', 'datalayer-color', container)
@ -733,13 +733,25 @@ L.U.DataLayer.include({
}, },
}) })
L.U.DataLayer.addInitHook(function () { U.DataLayer.addInitHook(function () {
this.on('hide', this.propagateHide) this.on('hide', this.propagateHide)
this.on('show', this.propagateShow) this.on('show', this.propagateShow)
if (this.isVisible()) this.propagateShow() 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 () { _openFacet: function () {
const container = L.DomUtil.create('div', 'umap-facet-search'), const container = L.DomUtil.create('div', 'umap-facet-search'),
title = L.DomUtil.add('h3', 'umap-filter-title', container, L._('Facet search')), title = L.DomUtil.add('h3', 'umap-filter-title', container, L._('Facet search')),
@ -782,7 +794,7 @@ L.U.Map.include({
label: this.getFacetKeys()[current], label: this.getFacetKeys()[current],
}, },
]) ])
const builder = new L.U.FormBuilder(this, fields, { const builder = new U.FormBuilder(this, fields, {
makeDirty: false, makeDirty: false,
callback: filterFeatures, callback: filterFeatures,
callbackContext: this, callbackContext: this,
@ -1043,10 +1055,10 @@ L.U.Map.include({
this this
) )
}, },
}) }
/* Used in view mode to define the current tilelayer */ /* Used in view mode to define the current tilelayer */
L.U.TileLayerControl = L.Control.IconLayers.extend({ U.TileLayerControl = L.Control.IconLayers.extend({
initialize: function (map, options) { initialize: function (map, options) {
this.map = map this.map = map
L.Control.IconLayers.prototype.initialize.call(this, { L.Control.IconLayers.prototype.initialize.call(this, {
@ -1065,7 +1077,10 @@ L.U.TileLayerControl = L.Control.IconLayers.extend({
// when the tilelayer is actually added to the map (needs this._tileZoom // when the tilelayer is actually added to the map (needs this._tileZoom
// to be defined) // to be defined)
// Fixme when https://github.com/Leaflet/Leaflet/pull/9201 is released // 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({ layers.push({
title: layer.options.name, title: layer.options.name,
layer: layer, layer: layer,
@ -1084,7 +1099,7 @@ L.U.TileLayerControl = L.Control.IconLayers.extend({
}) })
/* Used in edit mode to define the default tilelayer */ /* Used in edit mode to define the default tilelayer */
L.U.TileLayerChooser = L.Control.extend({ U.TileLayerChooser = L.Control.extend({
options: { options: {
position: 'topleft', position: 'topleft',
}, },
@ -1151,7 +1166,7 @@ L.U.TileLayerChooser = L.Control.extend({
}, },
}) })
L.U.AttributionControl = L.Control.Attribution.extend({ U.AttributionControl = L.Control.Attribution.extend({
options: { options: {
prefix: '', prefix: '',
}, },
@ -1199,7 +1214,7 @@ L.U.AttributionControl = L.Control.Attribution.extend({
}, },
}) })
L.U.StarControl = L.Control.extend({ U.StarControl = L.Control.extend({
options: { options: {
position: 'topleft', position: 'topleft',
}, },
@ -1222,7 +1237,7 @@ L.U.StarControl = L.Control.extend({
}, },
}) })
L.U.Search = L.PhotonSearch.extend({ U.Search = L.PhotonSearch.extend({
initialize: function (map, input, options) { initialize: function (map, input, options) {
this.options.placeholder = L._('Type a place name or coordinates') this.options.placeholder = L._('Type a place name or coordinates')
L.PhotonSearch.prototype.initialize.call(this, map, input, options) L.PhotonSearch.prototype.initialize.call(this, map, input, options)
@ -1309,7 +1324,7 @@ L.U.Search = L.PhotonSearch.extend({
}, },
}) })
L.U.SearchControl = L.Control.extend({ U.SearchControl = L.Control.extend({
options: { options: {
position: 'topleft', position: 'topleft',
}, },
@ -1342,7 +1357,7 @@ L.U.SearchControl = L.Control.extend({
title.textContent = L._('Search location') title.textContent = L._('Search location')
const input = L.DomUtil.create('input', 'photon-input', container) const input = L.DomUtil.create('input', 'photon-input', container)
const resultsContainer = L.DomUtil.create('div', 'photon-autocomplete', container) const resultsContainer = L.DomUtil.create('div', 'photon-autocomplete', container)
this.search = new L.U.Search(map, input, options) this.search = new U.Search(map, input, options)
const id = Math.random() const id = Math.random()
this.search.on('ajax:send', () => { this.search.on('ajax:send', () => {
map.fire('dataloading', { id: id }) map.fire('dataloading', { id: id })
@ -1398,7 +1413,7 @@ L.Control.Loading.include({
/* /*
* Make it dynamic * Make it dynamic
*/ */
L.U.ContextMenu = L.Map.ContextMenu.extend({ U.ContextMenu = L.Map.ContextMenu.extend({
_createItems: function (e) { _createItems: function (e) {
this._map.setContextMenuItems(e) this._map.setContextMenuItems(e)
L.Map.ContextMenu.prototype._createItems.call(this) L.Map.ContextMenu.prototype._createItems.call(this)
@ -1412,7 +1427,7 @@ L.U.ContextMenu = L.Map.ContextMenu.extend({
}, },
}) })
L.U.Editable = L.Editable.extend({ U.Editable = L.Editable.extend({
initialize: function (map, options) { initialize: function (map, options) {
L.Editable.prototype.initialize.call(this, map, options) L.Editable.prototype.initialize.call(this, map, options)
this.on( this.on(
@ -1428,7 +1443,7 @@ L.U.Editable = L.Editable.extend({
}) })
// Layer for items added by users // Layer for items added by users
this.on('editable:drawing:cancel', (e) => { this.on('editable:drawing:cancel', (e) => {
if (e.layer instanceof L.U.Marker) e.layer.del() if (e.layer instanceof U.Marker) e.layer.del()
}) })
this.on('editable:drawing:commit', function (e) { this.on('editable:drawing:commit', function (e) {
e.layer.isDirty = true e.layer.isDirty = true
@ -1454,15 +1469,15 @@ L.U.Editable = L.Editable.extend({
}, },
createPolyline: function (latlngs) { createPolyline: function (latlngs) {
return new L.U.Polyline(this.map, latlngs, this._getDefaultProperties()) return new U.Polyline(this.map, latlngs, this._getDefaultProperties())
}, },
createPolygon: function (latlngs) { createPolygon: function (latlngs) {
return new L.U.Polygon(this.map, latlngs, this._getDefaultProperties()) return new U.Polygon(this.map, latlngs, this._getDefaultProperties())
}, },
createMarker: function (latlng) { createMarker: function (latlng) {
return new L.U.Marker(this.map, latlng, this._getDefaultProperties()) return new U.Marker(this.map, latlng, this._getDefaultProperties())
}, },
_getDefaultProperties: function () { _getDefaultProperties: function () {

View file

@ -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 * Utils
*/ */
@ -441,7 +435,7 @@ L.DomEvent.once = (el, types, fn, context) => {
/* /*
* Global events * Global events
*/ */
L.U.Keys = { U.Keys = {
LEFT: 37, LEFT: 37,
UP: 38, UP: 38,
RIGHT: 39, RIGHT: 39,
@ -465,7 +459,7 @@ L.U.Keys = {
Z: 90, Z: 90,
} }
L.U.Help = L.Class.extend({ U.Help = L.Class.extend({
SHORTCUTS: { SHORTCUTS: {
DRAW_MARKER: { DRAW_MARKER: {
shortcut: 'Modifier+M', shortcut: 'Modifier+M',
@ -754,7 +748,7 @@ L.U.Help = L.Class.extend({
), ),
}) })
L.U.Orderable = L.Evented.extend({ U.Orderable = L.Evented.extend({
options: { options: {
selector: 'li', selector: 'li',
color: '#374E75', color: '#374E75',

View file

@ -1,4 +1,4 @@
L.U.DataLayerPermissions = L.Class.extend({ U.DataLayerPermissions = L.Class.extend({
options: { options: {
edit_status: null, edit_status: null,
}, },
@ -38,7 +38,7 @@ L.U.DataLayerPermissions = L.Class.extend({
}, },
], ],
], ],
builder = new L.U.FormBuilder(this, fields, { builder = new U.FormBuilder(this, fields, {
className: 'umap-form datalayer-permissions', className: 'umap-form datalayer-permissions',
}), }),
form = builder.build() form = builder.build()

View file

@ -1,4 +1,4 @@
L.U.FeatureMixin = { U.FeatureMixin = {
staticOptions: { mainColor: 'color' }, staticOptions: { mainColor: 'color' },
initialize: function (map, latlng, options) { initialize: function (map, latlng, options) {
@ -94,7 +94,7 @@ L.U.FeatureMixin = {
L._('Feature properties') L._('Feature properties')
) )
let builder = new L.U.FormBuilder(this, ['datalayer'], { let builder = new U.FormBuilder(this, ['datalayer'], {
callback: function () { callback: function () {
this.edit(e) this.edit(e)
}, // removeLayer step will close the edit panel, let's reopen it }, // removeLayer step will close the edit panel, let's reopen it
@ -113,7 +113,7 @@ L.U.FeatureMixin = {
// We always want name and description for now (properties management to come) // We always want name and description for now (properties management to come)
properties.unshift('properties.description') properties.unshift('properties.description')
properties.unshift('properties.name') properties.unshift('properties.name')
builder = new L.U.FormBuilder(this, properties, { builder = new U.FormBuilder(this, properties, {
id: 'umap-feature-properties', id: 'umap-feature-properties',
callback: this._redraw, // In case we have dynamic options… callback: this._redraw, // In case we have dynamic options…
}) })
@ -144,7 +144,7 @@ L.U.FeatureMixin = {
appendEditFieldsets: function (container) { appendEditFieldsets: function (container) {
const optionsFields = this.getShapeOptions() const optionsFields = this.getShapeOptions()
let builder = new L.U.FormBuilder(this, optionsFields, { let builder = new U.FormBuilder(this, optionsFields, {
id: 'umap-feature-shape-properties', id: 'umap-feature-shape-properties',
callback: this._redraw, callback: this._redraw,
}) })
@ -152,7 +152,7 @@ L.U.FeatureMixin = {
shapeProperties.appendChild(builder.build()) shapeProperties.appendChild(builder.build())
const advancedOptions = this.getAdvancedOptions() const advancedOptions = this.getAdvancedOptions()
builder = new L.U.FormBuilder(this, advancedOptions, { builder = new U.FormBuilder(this, advancedOptions, {
id: 'umap-feature-advanced-properties', id: 'umap-feature-advanced-properties',
callback: this._redraw, callback: this._redraw,
}) })
@ -163,7 +163,7 @@ L.U.FeatureMixin = {
advancedProperties.appendChild(builder.build()) advancedProperties.appendChild(builder.build())
const interactionOptions = this.getInteractionOptions() const interactionOptions = this.getInteractionOptions()
builder = new L.U.FormBuilder(this, interactionOptions, { builder = new U.FormBuilder(this, interactionOptions, {
callback: this._redraw, callback: this._redraw,
}) })
const popupFieldset = L.DomUtil.createFieldset( const popupFieldset = L.DomUtil.createFieldset(
@ -205,7 +205,7 @@ L.U.FeatureMixin = {
getPopupClass: function () { getPopupClass: function () {
const old = this.getOption('popupTemplate') // Retrocompat. const old = this.getOption('popupTemplate') // Retrocompat.
return L.U.Popup[this.getOption('popupShape') || old] || L.U.Popup return U.Popup[this.getOption('popupShape') || old] || U.Popup
}, },
attachPopup: function () { attachPopup: function () {
@ -382,7 +382,7 @@ L.U.FeatureMixin = {
}, },
getInplaceToolbarActions: function (e) { getInplaceToolbarActions: function (e) {
return [L.U.ToggleEditAction, L.U.DeleteFeatureAction] return [U.ToggleEditAction, U.DeleteFeatureAction]
}, },
_showContextMenu: function (e) { _showContextMenu: function (e) {
@ -502,7 +502,7 @@ L.U.FeatureMixin = {
}, },
getVertexActions: function () { getVertexActions: function () {
return [L.U.DeleteVertexAction] return [U.DeleteVertexAction]
}, },
isMulti: function () { isMulti: function () {
@ -539,9 +539,9 @@ L.U.FeatureMixin = {
}, },
} }
L.U.Marker = L.Marker.extend({ U.Marker = L.Marker.extend({
parentClass: L.Marker, parentClass: L.Marker,
includes: [L.U.FeatureMixin], includes: [U.FeatureMixin],
preInit: function () { preInit: function () {
this.setIcon(this.getIcon()) this.setIcon(this.getIcon())
@ -556,7 +556,7 @@ L.U.Marker = L.Marker.extend({
}, },
addInteractions: function () { addInteractions: function () {
L.U.FeatureMixin.addInteractions.call(this) U.FeatureMixin.addInteractions.call(this)
this.on( this.on(
'dragend', 'dragend',
function (e) { function (e) {
@ -639,7 +639,7 @@ L.U.Marker = L.Marker.extend({
disconnectFromDataLayer: function (datalayer) { disconnectFromDataLayer: function (datalayer) {
this.options.icon.datalayer = null this.options.icon.datalayer = null
L.U.FeatureMixin.disconnectFromDataLayer.call(this, datalayer) U.FeatureMixin.disconnectFromDataLayer.call(this, datalayer)
}, },
_getIconUrl: function (name) { _getIconUrl: function (name) {
@ -652,7 +652,7 @@ L.U.Marker = L.Marker.extend({
}, },
getIcon: function () { getIcon: function () {
const Class = L.U.Icon[this.getIconClass()] || L.U.Icon.Default const Class = U.Icon[this.getIconClass()] || U.Icon.Default
return new Class(this.map, { feature: this }) return new Class(this.map, { feature: this })
}, },
@ -678,12 +678,12 @@ L.U.Marker = L.Marker.extend({
}, },
appendEditFieldsets: function (container) { appendEditFieldsets: function (container) {
L.U.FeatureMixin.appendEditFieldsets.call(this, container) U.FeatureMixin.appendEditFieldsets.call(this, container)
const coordinatesOptions = [ const coordinatesOptions = [
['_latlng.lat', { handler: 'FloatInput', label: L._('Latitude') }], ['_latlng.lat', { handler: 'FloatInput', label: L._('Latitude') }],
['_latlng.lng', { handler: 'FloatInput', label: L._('Longitude') }], ['_latlng.lng', { handler: 'FloatInput', label: L._('Longitude') }],
] ]
const builder = new L.U.FormBuilder(this, coordinatesOptions, { const builder = new U.FormBuilder(this, coordinatesOptions, {
callback: function () { callback: function () {
if (!this._latlng.isValid()) { if (!this._latlng.isValid()) {
this.map.ui.alert({ this.map.ui.alert({
@ -707,7 +707,7 @@ L.U.Marker = L.Marker.extend({
// callback is mandatory for zoomToShowLayer // callback is mandatory for zoomToShowLayer
this.datalayer.layer.zoomToShowLayer(this, e.callback || (() => {})) this.datalayer.layer.zoomToShowLayer(this, e.callback || (() => {}))
} else { } else {
L.U.FeatureMixin.zoomTo.call(this, e) U.FeatureMixin.zoomTo.call(this, e)
} }
}, },
@ -721,13 +721,13 @@ L.U.Marker = L.Marker.extend({
}, },
}) })
L.U.PathMixin = { U.PathMixin = {
hasGeom: function () { hasGeom: function () {
return !this.isEmpty() return !this.isEmpty()
}, },
connectToDataLayer: function (datalayer) { connectToDataLayer: function (datalayer) {
L.U.FeatureMixin.connectToDataLayer.call(this, datalayer) U.FeatureMixin.connectToDataLayer.call(this, datalayer)
// We keep markers on their own layer on top of the paths. // We keep markers on their own layer on top of the paths.
this.options.pane = this.datalayer.pane this.options.pane = this.datalayer.pane
}, },
@ -735,7 +735,7 @@ L.U.PathMixin = {
edit: function (e) { edit: function (e) {
if (this.map.editEnabled) { if (this.map.editEnabled) {
if (!this.editEnabled()) this.enableEdit() if (!this.editEnabled()) this.enableEdit()
L.U.FeatureMixin.edit.call(this, e) U.FeatureMixin.edit.call(this, e)
} }
}, },
@ -816,7 +816,7 @@ L.U.PathMixin = {
// this.map.off('showmeasure', this.showMeasureTooltip, this); // this.map.off('showmeasure', this.showMeasureTooltip, this);
// this.map.off('hidemeasure', this.removeTooltip, this); // this.map.off('hidemeasure', this.removeTooltip, this);
if (this.editing && this.editing.enabled()) this.editing.removeHooks() if (this.editing && this.editing.enabled()) this.editing.removeHooks()
L.U.FeatureMixin.onRemove.call(this, map) U.FeatureMixin.onRemove.call(this, map)
}, },
getBestZoom: function () { getBestZoom: function () {
@ -825,7 +825,7 @@ L.U.PathMixin = {
endEdit: function () { endEdit: function () {
this.disableEdit() this.disableEdit()
L.U.FeatureMixin.endEdit.call(this) U.FeatureMixin.endEdit.call(this)
}, },
highlightPath: function () { highlightPath: function () {
@ -845,7 +845,7 @@ L.U.PathMixin = {
}, },
addInteractions: function () { addInteractions: function () {
L.U.FeatureMixin.addInteractions.call(this) U.FeatureMixin.addInteractions.call(this)
this.on('mouseover', this._onMouseOver) this.on('mouseover', this._onMouseOver)
this.on('edit', this.makeDirty) this.on('edit', this.makeDirty)
this.on('drag editable:drag', this._onDrag) this.on('drag editable:drag', this._onDrag)
@ -871,7 +871,7 @@ L.U.PathMixin = {
this.disableEdit() this.disableEdit()
if (!shape) return if (!shape) return
const properties = this.cloneProperties() const properties = this.cloneProperties()
const other = new (this instanceof L.U.Polyline ? L.U.Polyline : L.U.Polygon)( const other = new (this instanceof U.Polyline ? U.Polyline : U.Polygon)(
this.map, this.map,
shape, shape,
{ geojson: { properties: properties } } { geojson: { properties: properties } }
@ -882,7 +882,7 @@ L.U.PathMixin = {
}, },
getContextMenuItems: function (e) { getContextMenuItems: function (e) {
let items = L.U.FeatureMixin.getContextMenuItems.call(this, e) let items = U.FeatureMixin.getContextMenuItems.call(this, e)
items.push({ items.push({
text: L._('Display measure'), text: L._('Display measure'),
callback: function () { callback: function () {
@ -922,7 +922,7 @@ L.U.PathMixin = {
}, },
getContextMenuEditItems: function (e) { getContextMenuEditItems: function (e) {
const items = L.U.FeatureMixin.getContextMenuEditItems.call(this, e) const items = U.FeatureMixin.getContextMenuEditItems.call(this, e)
if ( if (
this.map.editedFeature && this.map.editedFeature &&
this.isSameClass(this.map.editedFeature) && this.isSameClass(this.map.editedFeature) &&
@ -949,10 +949,10 @@ L.U.PathMixin = {
}, },
getInplaceToolbarActions: function (e) { getInplaceToolbarActions: function (e) {
const items = L.U.FeatureMixin.getInplaceToolbarActions.call(this, e) const items = U.FeatureMixin.getInplaceToolbarActions.call(this, e)
if (this.isMulti()) { if (this.isMulti()) {
items.push(L.U.DeleteShapeAction) items.push(U.DeleteShapeAction)
items.push(L.U.ExtractShapeFromMultiAction) items.push(U.ExtractShapeFromMultiAction)
} }
return items return items
}, },
@ -975,9 +975,9 @@ L.U.PathMixin = {
}, },
} }
L.U.Polyline = L.Polyline.extend({ U.Polyline = L.Polyline.extend({
parentClass: L.Polyline, parentClass: L.Polyline,
includes: [L.U.FeatureMixin, L.U.PathMixin], includes: [U.FeatureMixin, U.PathMixin],
staticOptions: { staticOptions: {
stroke: true, stroke: true,
@ -986,7 +986,7 @@ L.U.Polyline = L.Polyline.extend({
}, },
isSameClass: function (other) { isSameClass: function (other) {
return other instanceof L.U.Polyline return other instanceof U.Polyline
}, },
getClassName: function () { getClassName: function () {
@ -999,7 +999,7 @@ L.U.Polyline = L.Polyline.extend({
}, },
getContextMenuEditItems: function (e) { getContextMenuEditItems: function (e) {
const items = L.U.PathMixin.getContextMenuEditItems.call(this, e) const items = U.PathMixin.getContextMenuEditItems.call(this, e)
const vertexClicked = e.vertex const vertexClicked = e.vertex
let index let index
if (!this.isMulti()) { if (!this.isMulti()) {
@ -1029,7 +1029,7 @@ L.U.Polyline = L.Polyline.extend({
}, },
getContextMenuMultiItems: function (e) { getContextMenuMultiItems: function (e) {
const items = L.U.PathMixin.getContextMenuMultiItems.call(this, e) const items = U.PathMixin.getContextMenuMultiItems.call(this, e)
items.push({ items.push({
text: L._('Merge lines'), text: L._('Merge lines'),
callback: this.mergeShapes, callback: this.mergeShapes,
@ -1050,7 +1050,7 @@ L.U.Polyline = L.Polyline.extend({
}, },
getAdvancedEditActions: function (container) { getAdvancedEditActions: function (container) {
L.U.FeatureMixin.getAdvancedEditActions.call(this, container) U.FeatureMixin.getAdvancedEditActions.call(this, container)
const toPolygon = L.DomUtil.createButton( const toPolygon = L.DomUtil.createButton(
'button umap-to-polygon', 'button umap-to-polygon',
container, container,
@ -1110,24 +1110,24 @@ L.U.Polyline = L.Polyline.extend({
}, },
getVertexActions: function (e) { getVertexActions: function (e) {
const actions = L.U.FeatureMixin.getVertexActions.call(this, e), const actions = U.FeatureMixin.getVertexActions.call(this, e),
index = e.vertex.getIndex() index = e.vertex.getIndex()
if (index === 0 || index === e.vertex.getLastIndex()) if (index === 0 || index === e.vertex.getLastIndex())
actions.push(L.U.ContinueLineAction) actions.push(U.ContinueLineAction)
else actions.push(L.U.SplitLineAction) else actions.push(U.SplitLineAction)
return actions return actions
}, },
}) })
L.U.Polygon = L.Polygon.extend({ U.Polygon = L.Polygon.extend({
parentClass: L.Polygon, parentClass: L.Polygon,
includes: [L.U.FeatureMixin, L.U.PathMixin], includes: [U.FeatureMixin, U.PathMixin],
staticOptions: { staticOptions: {
mainColor: 'fillColor', mainColor: 'fillColor',
}, },
isSameClass: function (other) { isSameClass: function (other) {
return other instanceof L.U.Polygon return other instanceof U.Polygon
}, },
getClassName: function () { getClassName: function () {
@ -1135,7 +1135,7 @@ L.U.Polygon = L.Polygon.extend({
}, },
getShapeOptions: function () { getShapeOptions: function () {
const options = L.U.PathMixin.getShapeOptions() const options = U.PathMixin.getShapeOptions()
options.push( options.push(
'properties._umap_options.stroke', 'properties._umap_options.stroke',
'properties._umap_options.fill', 'properties._umap_options.fill',
@ -1146,7 +1146,7 @@ L.U.Polygon = L.Polygon.extend({
}, },
getInteractionOptions: function () { getInteractionOptions: function () {
const options = L.U.FeatureMixin.getInteractionOptions() const options = U.FeatureMixin.getInteractionOptions()
options.push('properties._umap_options.interactive') options.push('properties._umap_options.interactive')
return options return options
}, },
@ -1157,7 +1157,7 @@ L.U.Polygon = L.Polygon.extend({
}, },
getContextMenuEditItems: function (e) { getContextMenuEditItems: function (e) {
const items = L.U.PathMixin.getContextMenuEditItems.call(this, e), const items = U.PathMixin.getContextMenuEditItems.call(this, e),
shape = this.shapeAt(e.latlng) shape = this.shapeAt(e.latlng)
// No multi and no holes. // No multi and no holes.
if (shape && !this.isMulti() && (L.LineUtil.isFlat(shape) || shape.length === 1)) { if (shape && !this.isMulti() && (L.LineUtil.isFlat(shape) || shape.length === 1)) {
@ -1191,7 +1191,7 @@ L.U.Polygon = L.Polygon.extend({
}, },
getAdvancedEditActions: function (container) { getAdvancedEditActions: function (container) {
L.U.FeatureMixin.getAdvancedEditActions.call(this, container) U.FeatureMixin.getAdvancedEditActions.call(this, container)
const toPolyline = L.DomUtil.createButton( const toPolyline = L.DomUtil.createButton(
'button umap-to-polyline', 'button umap-to-polyline',
container, container,
@ -1211,8 +1211,8 @@ L.U.Polygon = L.Polygon.extend({
}, },
getInplaceToolbarActions: function (e) { getInplaceToolbarActions: function (e) {
const items = L.U.PathMixin.getInplaceToolbarActions.call(this, e) const items = U.PathMixin.getInplaceToolbarActions.call(this, e)
items.push(L.U.CreateHoleAction) items.push(U.CreateHoleAction)
return items return items
}, },
}) })

View file

@ -379,10 +379,10 @@ L.FormBuilder.PopupContent = L.FormBuilder.Select.extend({
L.FormBuilder.LayerTypeChooser = L.FormBuilder.Select.extend({ L.FormBuilder.LayerTypeChooser = L.FormBuilder.Select.extend({
getOptions: function () { getOptions: function () {
const layer_classes = [ const layer_classes = [
L.U.Layer.Default, U.Layer.Default,
L.U.Layer.Cluster, U.Layer.Cluster,
L.U.Layer.Heat, U.Layer.Heat,
L.U.Layer.Choropleth, U.Layer.Choropleth,
] ]
return layer_classes.map((class_) => [class_.TYPE, class_.NAME]) return layer_classes.map((class_) => [class_.TYPE, class_.NAME])
}, },
@ -607,7 +607,7 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
// Do not try to render URL with variables // Do not try to render URL with variables
const box = L.DomUtil.create('div', 'umap-pictogram-choice', this.buttons) const box = L.DomUtil.create('div', 'umap-pictogram-choice', this.buttons)
L.DomEvent.on(box, 'click', this.onDefine, this) L.DomEvent.on(box, 'click', this.onDefine, this)
const icon = L.U.Icon.makeIconElement(this.value(), box) const icon = U.Icon.makeIconElement(this.value(), box)
} }
this.button = L.DomUtil.createButton( this.button = L.DomUtil.createButton(
'button action-button', 'button action-button',
@ -707,7 +707,7 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
showCharsTab: function () { showCharsTab: function () {
this.openTab('chars') this.openTab('chars')
const value = !L.U.Icon.isImg(this.value()) ? this.value() : null const value = !U.Icon.isImg(this.value()) ? this.value() : null
const input = this.buildInput(this.body, value) const input = this.buildInput(this.body, value)
input.placeholder = L._('Type char or paste emoji') input.placeholder = L._('Type char or paste emoji')
input.type = 'text' input.type = 'text'
@ -960,7 +960,7 @@ L.FormBuilder.ManageOwner = L.FormBuilder.Element.extend({
className: 'edit-owner', className: 'edit-owner',
on_select: L.bind(this.onSelect, this), on_select: L.bind(this.onSelect, this),
} }
this.autocomplete = new L.U.AutoComplete.Ajax.Select(this.parentNode, options) this.autocomplete = new U.AutoComplete.Ajax.Select(this.parentNode, options)
const owner = this.toHTML() const owner = this.toHTML()
if (owner) if (owner)
this.autocomplete.displaySelected({ this.autocomplete.displaySelected({
@ -989,7 +989,7 @@ L.FormBuilder.ManageEditors = L.FormBuilder.Element.extend({
on_select: L.bind(this.onSelect, this), on_select: L.bind(this.onSelect, this),
on_unselect: L.bind(this.onUnselect, this), on_unselect: L.bind(this.onUnselect, this),
} }
this.autocomplete = new L.U.AutoComplete.Ajax.SelectMultiple( this.autocomplete = new U.AutoComplete.Ajax.SelectMultiple(
this.parentNode, this.parentNode,
options options
) )
@ -1023,7 +1023,7 @@ L.FormBuilder.ManageEditors = L.FormBuilder.Element.extend({
}, },
}) })
L.U.FormBuilder = L.FormBuilder.extend({ U.FormBuilder = L.FormBuilder.extend({
options: { options: {
className: 'umap-form', className: 'umap-form',
}, },
@ -1114,7 +1114,7 @@ L.U.FormBuilder = L.FormBuilder.extend({
handler: 'IconUrl', handler: 'IconUrl',
label: L._('Icon symbol'), label: L._('Icon symbol'),
inheritable: true, inheritable: true,
helpText: L.U.Help.formatIconSymbol, helpText: U.Help.formatIconSymbol,
}, },
popupShape: { handler: 'PopupShape', label: L._('Popup shape'), inheritable: true }, popupShape: { handler: 'PopupShape', label: L._('Popup shape'), inheritable: true },
popupTemplate: { popupTemplate: {

View file

@ -1,4 +1,4 @@
L.U.Icon = L.DivIcon.extend({ U.Icon = L.DivIcon.extend({
initialize: function (map, options) { initialize: function (map, options) {
this.map = map this.map = map
const default_options = { const default_options = {
@ -42,7 +42,7 @@ L.U.Icon = L.DivIcon.extend({
onAdd: function () {}, onAdd: function () {},
}) })
L.U.Icon.Default = L.U.Icon.extend({ U.Icon.Default = U.Icon.extend({
default_options: { default_options: {
iconAnchor: new L.Point(16, 40), iconAnchor: new L.Point(16, 40),
popupAnchor: new L.Point(0, -40), popupAnchor: new L.Point(0, -40),
@ -52,11 +52,11 @@ L.U.Icon.Default = L.U.Icon.extend({
initialize: function (map, options) { initialize: function (map, options) {
options = L.Util.extend({}, this.default_options, options) options = L.Util.extend({}, this.default_options, options)
L.U.Icon.prototype.initialize.call(this, map, options) U.Icon.prototype.initialize.call(this, map, options)
}, },
_setIconStyles: function (img, name) { _setIconStyles: function (img, name) {
L.U.Icon.prototype._setIconStyles.call(this, img, name) U.Icon.prototype._setIconStyles.call(this, img, name)
const color = this._getColor(), const color = this._getColor(),
opacity = this._getOpacity() opacity = this._getOpacity()
this.elements.container.style.backgroundColor = color this.elements.container.style.backgroundColor = color
@ -68,7 +68,7 @@ L.U.Icon.Default = L.U.Icon.extend({
onAdd: function () { onAdd: function () {
const src = this._getIconUrl('icon') const src = this._getIconUrl('icon')
const bgcolor = this._getColor() const bgcolor = this._getColor()
L.U.Icon.setIconContrast(this.elements.icon, this.elements.container, src, bgcolor) U.Icon.setIconContrast(this.elements.icon, this.elements.container, src, bgcolor)
}, },
createIcon: function () { createIcon: function () {
@ -82,14 +82,14 @@ L.U.Icon.Default = L.U.Icon.extend({
this.elements.arrow = L.DomUtil.create('div', 'icon_arrow', this.elements.main) this.elements.arrow = L.DomUtil.create('div', 'icon_arrow', this.elements.main)
const src = this._getIconUrl('icon') const src = this._getIconUrl('icon')
if (src) { if (src) {
this.elements.icon = L.U.Icon.makeIconElement(src, this.elements.container) this.elements.icon = U.Icon.makeIconElement(src, this.elements.container)
} }
this._setIconStyles(this.elements.main, 'icon') this._setIconStyles(this.elements.main, 'icon')
return this.elements.main return this.elements.main
}, },
}) })
L.U.Icon.Circle = L.U.Icon.extend({ U.Icon.Circle = U.Icon.extend({
initialize: function (map, options) { initialize: function (map, options) {
const default_options = { const default_options = {
popupAnchor: new L.Point(0, -6), popupAnchor: new L.Point(0, -6),
@ -97,11 +97,11 @@ L.U.Icon.Circle = L.U.Icon.extend({
className: 'umap-circle-icon', className: 'umap-circle-icon',
} }
options = L.Util.extend({}, default_options, options) options = L.Util.extend({}, default_options, options)
L.U.Icon.prototype.initialize.call(this, map, options) U.Icon.prototype.initialize.call(this, map, options)
}, },
_setIconStyles: function (img, name) { _setIconStyles: function (img, name) {
L.U.Icon.prototype._setIconStyles.call(this, img, name) U.Icon.prototype._setIconStyles.call(this, img, name)
this.elements.main.style.backgroundColor = this._getColor() this.elements.main.style.backgroundColor = this._getColor()
this.elements.main.style.opacity = this._getOpacity() this.elements.main.style.opacity = this._getOpacity()
}, },
@ -115,7 +115,7 @@ L.U.Icon.Circle = L.U.Icon.extend({
}, },
}) })
L.U.Icon.Drop = L.U.Icon.Default.extend({ U.Icon.Drop = U.Icon.Default.extend({
default_options: { default_options: {
iconAnchor: new L.Point(16, 42), iconAnchor: new L.Point(16, 42),
popupAnchor: new L.Point(0, -42), popupAnchor: new L.Point(0, -42),
@ -124,7 +124,7 @@ L.U.Icon.Drop = L.U.Icon.Default.extend({
}, },
}) })
L.U.Icon.Ball = L.U.Icon.Default.extend({ U.Icon.Ball = U.Icon.Default.extend({
default_options: { default_options: {
iconAnchor: new L.Point(8, 30), iconAnchor: new L.Point(8, 30),
popupAnchor: new L.Point(0, -28), popupAnchor: new L.Point(0, -28),
@ -146,7 +146,7 @@ L.U.Icon.Ball = L.U.Icon.Default.extend({
}, },
_setIconStyles: function (img, name) { _setIconStyles: function (img, name) {
L.U.Icon.prototype._setIconStyles.call(this, img, name) U.Icon.prototype._setIconStyles.call(this, img, name)
const color = this._getColor('color') const color = this._getColor('color')
let background let background
if (L.Browser.ielt9) { if (L.Browser.ielt9) {
@ -161,7 +161,7 @@ L.U.Icon.Ball = L.U.Icon.Default.extend({
}, },
}) })
L.U.Icon.Cluster = L.DivIcon.extend({ U.Icon.Cluster = L.DivIcon.extend({
options: { options: {
iconSize: [40, 40], iconSize: [40, 40],
}, },
@ -191,13 +191,13 @@ L.U.Icon.Cluster = L.DivIcon.extend({
}, },
}) })
L.U.Icon.isImg = function (src) { U.Icon.isImg = function (src) {
return L.Util.isPath(src) || L.Util.isRemoteUrl(src) || L.Util.isDataImage(src) return L.Util.isPath(src) || L.Util.isRemoteUrl(src) || L.Util.isDataImage(src)
} }
L.U.Icon.makeIconElement = function (src, parent) { U.Icon.makeIconElement = function (src, parent) {
let icon let icon
if (L.U.Icon.isImg(src)) { if (U.Icon.isImg(src)) {
icon = L.DomUtil.create('img') icon = L.DomUtil.create('img')
icon.src = src icon.src = src
} else { } else {
@ -208,7 +208,7 @@ L.U.Icon.makeIconElement = function (src, parent) {
return icon return icon
} }
L.U.Icon.setIconContrast = function (icon, parent, src, bgcolor) { U.Icon.setIconContrast = function (icon, parent, src, bgcolor) {
/* /*
* icon: the element we'll adapt the style, it can be an image or text * icon: the element we'll adapt the style, it can be an image or text
* parent: the element we'll consider to decide whether to adapt the style, * parent: the element we'll consider to decide whether to adapt the style,

View file

@ -1,4 +1,4 @@
L.U.Importer = L.Class.extend({ U.Importer = L.Class.extend({
TYPES: ['geojson', 'csv', 'gpx', 'kml', 'osm', 'georss', 'umap'], TYPES: ['geojson', 'csv', 'gpx', 'kml', 'osm', 'georss', 'umap'],
initialize: function (map) { initialize: function (map) {
this.map = map this.map = map

View file

@ -55,20 +55,8 @@ L.Map.mergeOptions({
featuresHaveOwner: false, featuresHaveOwner: false,
}) })
L.U.Map.include({ U.Map = L.Map.extend({
HIDDABLE_CONTROLS: [ includes: [ControlsMixin],
'zoom',
'search',
'fullscreen',
'embed',
'locate',
'measure',
'editinosm',
'datalayers',
'star',
'tilelayers',
],
editableOptions: { editableOptions: {
'zoom': undefined, 'zoom': undefined,
'scrollWheelZoom': Boolean, 'scrollWheelZoom': Boolean,
@ -154,13 +142,13 @@ L.U.Map.include({
// After calling parent initialize, as we are doing initCenter our-selves // After calling parent initialize, as we are doing initCenter our-selves
if (geojson.geometry) this.options.center = this.latLng(geojson.geometry) if (geojson.geometry) this.options.center = this.latLng(geojson.geometry)
this.urls = new window.umap.URLs(this.options.urls) this.urls = new U.URLs(this.options.urls)
this.ui = new L.U.UI(this._container) this.ui = new U.UI(this._container)
this.ui.on('dataloading', (e) => this.fire('dataloading', e)) this.ui.on('dataloading', (e) => this.fire('dataloading', e))
this.ui.on('dataload', (e) => this.fire('dataload', e)) this.ui.on('dataload', (e) => this.fire('dataload', e))
this.server = new window.umap.ServerRequest(this.ui) this.server = new U.ServerRequest(this.ui)
this.request = new window.umap.Request(this.ui) this.request = new U.Request(this.ui)
this.initLoader() this.initLoader()
this.name = this.options.name this.name = this.options.name
@ -212,7 +200,7 @@ L.U.Map.include({
this.facets = {} this.facets = {}
// Needed for actions labels // Needed for actions labels
this.help = new L.U.Help(this) this.help = new U.Help(this)
if (this.options.hash) this.addHash() if (this.options.hash) this.addHash()
this.initTileLayers() this.initTileLayers()
@ -292,11 +280,11 @@ L.U.Map.include({
} }
} }
this.slideshow = new L.U.Slideshow(this, this.options.slideshow) this.slideshow = new U.Slideshow(this, this.options.slideshow)
this.permissions = new L.U.MapPermissions(this) this.permissions = new U.MapPermissions(this)
this.initCaptionBar() this.initCaptionBar()
if (this.hasEditMode()) { if (this.hasEditMode()) {
this.editTools = new L.U.Editable(this) this.editTools = new U.Editable(this)
this.ui.on( this.ui.on(
'panel:closed panel:open', 'panel:closed panel:open',
function () { function () {
@ -370,25 +358,25 @@ L.U.Map.include({
this._controls = {} this._controls = {}
if (this.hasEditMode() && !this.options.noControl) { if (this.hasEditMode() && !this.options.noControl) {
new L.U.EditControl(this).addTo(this) new U.EditControl(this).addTo(this)
new L.U.DrawToolbar({ map: this }).addTo(this) new U.DrawToolbar({ map: this }).addTo(this)
const editActions = [ const editActions = [
L.U.ImportAction, U.ImportAction,
L.U.EditPropertiesAction, U.EditPropertiesAction,
L.U.ManageDatalayersAction, U.ManageDatalayersAction,
L.U.ChangeTileLayerAction, U.ChangeTileLayerAction,
L.U.UpdateExtentAction, U.UpdateExtentAction,
L.U.UpdatePermsAction, U.UpdatePermsAction,
] ]
new L.U.SettingsToolbar({ actions: editActions }).addTo(this) new U.SettingsToolbar({ actions: editActions }).addTo(this)
} }
this._controls.zoom = new L.Control.Zoom({ this._controls.zoom = new L.Control.Zoom({
zoomInTitle: L._('Zoom in'), zoomInTitle: L._('Zoom in'),
zoomOutTitle: L._('Zoom out'), zoomOutTitle: L._('Zoom out'),
}) })
this._controls.datalayers = new L.U.DataLayersControl(this) this._controls.datalayers = new U.DataLayersControl(this)
this._controls.locate = L.control.locate({ this._controls.locate = L.control.locate({
strings: { strings: {
title: L._('Center map on your location'), title: L._('Center map on your location'),
@ -405,10 +393,10 @@ L.U.Map.include({
this._controls.fullscreen = new L.Control.Fullscreen({ this._controls.fullscreen = new L.Control.Fullscreen({
title: { false: L._('View Fullscreen'), true: L._('Exit Fullscreen') }, title: { false: L._('View Fullscreen'), true: L._('Exit Fullscreen') },
}) })
this._controls.search = new L.U.SearchControl() this._controls.search = new U.SearchControl()
this._controls.embed = new L.Control.Embed(this, this.options.embedOptions) this._controls.embed = new L.Control.Embed(this, this.options.embedOptions)
this._controls.tilelayersChooser = new L.U.TileLayerChooser(this) this._controls.tilelayersChooser = new U.TileLayerChooser(this)
this._controls.star = new L.U.StarControl(this) this._controls.star = new U.StarControl(this)
this._controls.editinosm = new L.Control.EditInOSM({ this._controls.editinosm = new L.Control.EditInOSM({
position: 'topleft', position: 'topleft',
widgetOptions: { widgetOptions: {
@ -418,16 +406,16 @@ L.U.Map.include({
}, },
}) })
this._controls.measure = new L.MeasureControl().initHandler(this) this._controls.measure = new L.MeasureControl().initHandler(this)
this._controls.more = new L.U.MoreControls() this._controls.more = new U.MoreControls()
this._controls.scale = L.control.scale() this._controls.scale = L.control.scale()
this._controls.permanentCredit = new L.U.PermanentCreditsControl(this) this._controls.permanentCredit = new U.PermanentCreditsControl(this)
if (this.options.scrollWheelZoom) this.scrollWheelZoom.enable() if (this.options.scrollWheelZoom) this.scrollWheelZoom.enable()
else this.scrollWheelZoom.disable() else this.scrollWheelZoom.disable()
this.browser = new window.umap.Browser(this) this.browser = new U.Browser(this)
this.importer = new L.U.Importer(this) this.importer = new U.Importer(this)
this.drop = new L.U.DropControl(this) this.drop = new U.DropControl(this)
this.share = new L.U.Share(this) this.share = new U.Share(this)
this._controls.tilelayers = new L.U.TileLayerControl(this) this._controls.tilelayers = new U.TileLayerControl(this)
this._controls.tilelayers.setLayers() this._controls.tilelayers.setLayers()
this.renderControls() this.renderControls()
@ -450,7 +438,7 @@ L.U.Map.include({
} }
if (this.options.noControl) return if (this.options.noControl) return
this._controls.attribution = new L.U.AttributionControl().addTo(this) this._controls.attribution = new U.AttributionControl().addTo(this)
if (this.options.miniMap && !this.options.noControl) { if (this.options.miniMap && !this.options.noControl) {
this.whenReady(function () { this.whenReady(function () {
if (this.selected_tilelayer) { if (this.selected_tilelayer) {
@ -564,10 +552,10 @@ L.U.Map.include({
modifierKey = e.ctrlKey || e.metaKey modifierKey = e.ctrlKey || e.metaKey
/* Generic shortcuts */ /* Generic shortcuts */
if (key === L.U.Keys.F && modifierKey) { if (key === U.Keys.F && modifierKey) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.search() this.search()
} else if (e.keyCode === L.U.Keys.ESC) { } else if (e.keyCode === U.Keys.ESC) {
if (this.help.visible()) this.help.hide() if (this.help.visible()) this.help.hide()
else this.ui.closePanel() else this.ui.closePanel()
} }
@ -575,11 +563,11 @@ L.U.Map.include({
if (!this.hasEditMode()) return if (!this.hasEditMode()) return
/* Edit mode only shortcuts */ /* Edit mode only shortcuts */
if (key === L.U.Keys.E && modifierKey && !this.editEnabled) { if (key === U.Keys.E && modifierKey && !this.editEnabled) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.enableEdit() this.enableEdit()
} else if ( } else if (
key === L.U.Keys.E && key === U.Keys.E &&
modifierKey && modifierKey &&
this.editEnabled && this.editEnabled &&
!this.isDirty !this.isDirty
@ -588,41 +576,41 @@ L.U.Map.include({
this.disableEdit() this.disableEdit()
this.ui.closePanel() this.ui.closePanel()
} }
if (key === L.U.Keys.S && modifierKey) { if (key === U.Keys.S && modifierKey) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
if (this.isDirty) { if (this.isDirty) {
this.save() this.save()
} }
} }
if (key === L.U.Keys.Z && modifierKey && this.isDirty) { if (key === U.Keys.Z && modifierKey && this.isDirty) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.askForReset() this.askForReset()
} }
if (key === L.U.Keys.M && modifierKey && this.editEnabled) { if (key === U.Keys.M && modifierKey && this.editEnabled) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.editTools.startMarker() this.editTools.startMarker()
} }
if (key === L.U.Keys.P && modifierKey && this.editEnabled) { if (key === U.Keys.P && modifierKey && this.editEnabled) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.editTools.startPolygon() this.editTools.startPolygon()
} }
if (key === L.U.Keys.L && modifierKey && this.editEnabled) { if (key === U.Keys.L && modifierKey && this.editEnabled) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.editTools.startPolyline() this.editTools.startPolyline()
} }
if (key === L.U.Keys.I && modifierKey && this.editEnabled) { if (key === U.Keys.I && modifierKey && this.editEnabled) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.importer.open() this.importer.open()
} }
if (key === L.U.Keys.O && modifierKey && this.editEnabled) { if (key === U.Keys.O && modifierKey && this.editEnabled) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.importer.openFiles() this.importer.openFiles()
} }
if (key === L.U.Keys.H && modifierKey && this.editEnabled) { if (key === U.Keys.H && modifierKey && this.editEnabled) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
this.help.show('edit') this.help.show('edit')
} }
if (e.keyCode === L.U.Keys.ESC) { if (e.keyCode === U.Keys.ESC) {
if (this.editEnabled && this.editTools.drawing()) { if (this.editEnabled && this.editTools.drawing()) {
this.editTools.stopDrawing() this.editTools.stopDrawing()
} }
@ -833,7 +821,7 @@ L.U.Map.include({
datalayer = datalayer || { datalayer = datalayer || {
name: `${L._('Layer')} ${this.datalayers_index.length + 1}`, name: `${L._('Layer')} ${this.datalayers_index.length + 1}`,
} }
return new L.U.DataLayer(this, datalayer) return new U.DataLayer(this, datalayer)
}, },
getDefaultOption: function (option) { getDefaultOption: function (option) {
@ -1238,7 +1226,7 @@ L.U.Map.include({
'options.captionBar', 'options.captionBar',
'options.captionMenus', 'options.captionMenus',
]) ])
builder = new L.U.FormBuilder(this, UIFields, { builder = new U.FormBuilder(this, UIFields, {
callback: function () { callback: function () {
this.renderControls() this.renderControls()
this.initCaptionBar() this.initCaptionBar()
@ -1267,7 +1255,7 @@ L.U.Map.include({
'options.dashArray', 'options.dashArray',
] ]
builder = new L.U.FormBuilder(this, shapeOptions, { builder = new U.FormBuilder(this, shapeOptions, {
callback: function (e) { callback: function (e) {
if (this._controls.miniMap) this.renderControls() if (this._controls.miniMap) this.renderControls()
this.eachVisibleDataLayer((datalayer) => { this.eachVisibleDataLayer((datalayer) => {
@ -1327,7 +1315,7 @@ L.U.Map.include({
], ],
] ]
builder = new L.U.FormBuilder(this, optionsFields, { builder = new U.FormBuilder(this, optionsFields, {
callback: function (e) { callback: function (e) {
this.initCaptionBar() this.initCaptionBar()
if (e.helper.field === 'options.sortKey') { if (e.helper.field === 'options.sortKey') {
@ -1352,7 +1340,7 @@ L.U.Map.include({
'options.labelInteractive', 'options.labelInteractive',
'options.outlinkTarget', 'options.outlinkTarget',
] ]
builder = new L.U.FormBuilder(this, popupFields, { builder = new U.FormBuilder(this, popupFields, {
callback: function (e) { callback: function (e) {
if ( if (
e.helper.field === 'options.popupTemplate' || e.helper.field === 'options.popupTemplate' ||
@ -1419,7 +1407,7 @@ L.U.Map.include({
container, container,
L._('Custom background') L._('Custom background')
) )
builder = new L.U.FormBuilder(this, tilelayerFields, { builder = new U.FormBuilder(this, tilelayerFields, {
callback: this.initTileLayers, callback: this.initTileLayers,
callbackContext: this, callbackContext: this,
}) })
@ -1470,7 +1458,7 @@ L.U.Map.include({
['options.overlay.tms', { handler: 'Switch', label: L._('TMS format') }], ['options.overlay.tms', { handler: 'Switch', label: L._('TMS format') }],
] ]
const overlay = L.DomUtil.createFieldset(container, L._('Custom overlay')) const overlay = L.DomUtil.createFieldset(container, L._('Custom overlay'))
builder = new L.U.FormBuilder(this, overlayFields, { builder = new U.FormBuilder(this, overlayFields, {
callback: this.initTileLayers, callback: this.initTileLayers,
callbackContext: this, callbackContext: this,
}) })
@ -1500,7 +1488,7 @@ L.U.Map.include({
{ handler: 'BlurFloatInput', placeholder: L._('max East') }, { handler: 'BlurFloatInput', placeholder: L._('max East') },
], ],
] ]
const boundsBuilder = new L.U.FormBuilder(this, boundsFields, { const boundsBuilder = new U.FormBuilder(this, boundsFields, {
callback: this.handleLimitBounds, callback: this.handleLimitBounds,
callbackContext: this, callbackContext: this,
}) })
@ -1566,7 +1554,7 @@ L.U.Map.include({
this.slideshow.setOptions(this.options.slideshow) this.slideshow.setOptions(this.options.slideshow)
this.renderControls() this.renderControls()
} }
const slideshowBuilder = new L.U.FormBuilder(this, slideshowFields, { const slideshowBuilder = new U.FormBuilder(this, slideshowFields, {
callback: slideshowHandler, callback: slideshowHandler,
callbackContext: this, callbackContext: this,
}) })
@ -1606,7 +1594,7 @@ L.U.Map.include({
{ handler: 'Switch', label: L._('Permanent credits background') }, { handler: 'Switch', label: L._('Permanent credits background') },
], ],
] ]
const creditsBuilder = new L.U.FormBuilder(this, creditsFields, { const creditsBuilder = new U.FormBuilder(this, creditsFields, {
callback: this.renderControls, callback: this.renderControls,
callbackContext: this, callbackContext: this,
}) })
@ -1662,7 +1650,7 @@ L.U.Map.include({
metadataFields = ['options.name', 'options.description'], metadataFields = ['options.name', 'options.description'],
title = L.DomUtil.create('h3', '', container) title = L.DomUtil.create('h3', '', container)
title.textContent = L._('Edit map properties') title.textContent = L._('Edit map properties')
const builder = new L.U.FormBuilder(this, metadataFields) const builder = new U.FormBuilder(this, metadataFields)
const form = builder.build() const form = builder.build()
container.appendChild(form) container.appendChild(form)
this._editControls(container) this._editControls(container)
@ -1796,7 +1784,7 @@ L.U.Map.include({
}, },
initContextMenu: function () { initContextMenu: function () {
this.contextmenu = new L.U.ContextMenu(this) this.contextmenu = new U.ContextMenu(this)
this.contextmenu.enable() this.contextmenu.enable()
}, },

View file

@ -1,4 +1,4 @@
L.U.Layer = { U.Layer = {
browsable: true, browsable: true,
getType: function () { getType: function () {
@ -26,12 +26,12 @@ L.U.Layer = {
}, },
} }
L.U.Layer.Default = L.FeatureGroup.extend({ U.Layer.Default = L.FeatureGroup.extend({
statics: { statics: {
NAME: L._('Default'), NAME: L._('Default'),
TYPE: 'Default', TYPE: 'Default',
}, },
includes: [L.U.Layer], includes: [U.Layer],
initialize: function (datalayer) { initialize: function (datalayer) {
this.datalayer = datalayer this.datalayer = datalayer
@ -39,7 +39,7 @@ L.U.Layer.Default = L.FeatureGroup.extend({
}, },
}) })
L.U.MarkerCluster = L.MarkerCluster.extend({ U.MarkerCluster = L.MarkerCluster.extend({
// Custom class so we can call computeTextColor // Custom class so we can call computeTextColor
// when element is already on the DOM. // when element is already on the DOM.
@ -51,12 +51,12 @@ L.U.MarkerCluster = L.MarkerCluster.extend({
}, },
}) })
L.U.Layer.Cluster = L.MarkerClusterGroup.extend({ U.Layer.Cluster = L.MarkerClusterGroup.extend({
statics: { statics: {
NAME: L._('Clustered'), NAME: L._('Clustered'),
TYPE: 'Cluster', TYPE: 'Cluster',
}, },
includes: [L.U.Layer], includes: [U.Layer],
initialize: function (datalayer) { initialize: function (datalayer) {
this.datalayer = datalayer this.datalayer = datalayer
@ -65,14 +65,14 @@ L.U.Layer.Cluster = L.MarkerClusterGroup.extend({
color: this.datalayer.getColor(), color: this.datalayer.getColor(),
}, },
iconCreateFunction: function (cluster) { iconCreateFunction: function (cluster) {
return new L.U.Icon.Cluster(datalayer, cluster) return new U.Icon.Cluster(datalayer, cluster)
}, },
} }
if (this.datalayer.options.cluster && this.datalayer.options.cluster.radius) { if (this.datalayer.options.cluster && this.datalayer.options.cluster.radius) {
options.maxClusterRadius = this.datalayer.options.cluster.radius options.maxClusterRadius = this.datalayer.options.cluster.radius
} }
L.MarkerClusterGroup.prototype.initialize.call(this, options) L.MarkerClusterGroup.prototype.initialize.call(this, options)
this._markerCluster = L.U.MarkerCluster this._markerCluster = U.MarkerCluster
this._layers = [] this._layers = []
}, },
@ -132,12 +132,12 @@ L.U.Layer.Cluster = L.MarkerClusterGroup.extend({
}, },
}) })
L.U.Layer.Choropleth = L.FeatureGroup.extend({ U.Layer.Choropleth = L.FeatureGroup.extend({
statics: { statics: {
NAME: L._('Choropleth'), NAME: L._('Choropleth'),
TYPE: 'Choropleth', TYPE: 'Choropleth',
}, },
includes: [L.U.Layer], includes: [U.Layer],
// Have defaults that better suit the choropleth mode. // Have defaults that better suit the choropleth mode.
defaults: { defaults: {
color: 'white', color: 'white',
@ -338,12 +338,12 @@ L.U.Layer.Choropleth = L.FeatureGroup.extend({
}, },
}) })
L.U.Layer.Heat = L.HeatLayer.extend({ U.Layer.Heat = L.HeatLayer.extend({
statics: { statics: {
NAME: L._('Heatmap'), NAME: L._('Heatmap'),
TYPE: 'Heat', TYPE: 'Heat',
}, },
includes: [L.U.Layer], includes: [U.Layer],
browsable: false, browsable: false,
initialize: function (datalayer) { initialize: function (datalayer) {
@ -505,7 +505,7 @@ L.U.Layer.Heat = L.HeatLayer.extend({
}, },
}) })
L.U.DataLayer = L.Evented.extend({ U.DataLayer = L.Evented.extend({
options: { options: {
displayOnLoad: true, displayOnLoad: true,
inCaption: true, inCaption: true,
@ -579,7 +579,7 @@ L.U.DataLayer = L.Evented.extend({
} }
this.backupOptions() this.backupOptions()
this.connectToMap() this.connectToMap()
this.permissions = new L.U.DataLayerPermissions(this) this.permissions = new U.DataLayerPermissions(this)
if (!this.umap_id) { if (!this.umap_id) {
if (this.showAtLoad()) this.show() if (this.showAtLoad()) this.show()
this.isDirty = true this.isDirty = true
@ -648,7 +648,7 @@ L.U.DataLayer = L.Evented.extend({
if (this.layer) this.layer.clearLayers() if (this.layer) this.layer.clearLayers()
// delete this.layer? // delete this.layer?
if (visible) this.map.removeLayer(this.layer) if (visible) this.map.removeLayer(this.layer)
const Class = L.U.Layer[this.options.type] || L.U.Layer.Default const Class = U.Layer[this.options.type] || U.Layer.Default
this.layer = new Class(this) this.layer = new Class(this)
this.eachLayer(this.showFeature) this.eachLayer(this.showFeature)
if (visible) this.show() if (visible) this.show()
@ -801,7 +801,7 @@ L.U.DataLayer = L.Evented.extend({
setOptions: function (options) { setOptions: function (options) {
delete options.geojson delete options.geojson
this.options = L.Util.CopyJSON(L.U.DataLayer.prototype.options) // Start from fresh. this.options = L.Util.CopyJSON(U.DataLayer.prototype.options) // Start from fresh.
this.updateOptions(options) this.updateOptions(options)
}, },
@ -1027,11 +1027,11 @@ L.U.DataLayer = L.Evented.extend({
}, },
_pointToLayer: function (geojson, latlng) { _pointToLayer: function (geojson, latlng) {
return new L.U.Marker(this.map, latlng, { geojson: geojson, datalayer: this }) return new U.Marker(this.map, latlng, { geojson: geojson, datalayer: this })
}, },
_lineToLayer: function (geojson, latlngs) { _lineToLayer: function (geojson, latlngs) {
return new L.U.Polyline(this.map, latlngs, { return new U.Polyline(this.map, latlngs, {
geojson: geojson, geojson: geojson,
datalayer: this, datalayer: this,
color: null, color: null,
@ -1043,7 +1043,7 @@ L.U.DataLayer = L.Evented.extend({
// for (let i = latlngs.length - 1; i > 0; i--) { // for (let i = latlngs.length - 1; i > 0; i--) {
// if (!latlngs.slice()[i].length) latlngs.splice(i, 1); // if (!latlngs.slice()[i].length) latlngs.splice(i, 1);
// } // }
return new L.U.Polygon(this.map, latlngs, { geojson: geojson, datalayer: this }) return new U.Polygon(this.map, latlngs, { geojson: geojson, datalayer: this })
}, },
importRaw: function (raw, type) { importRaw: function (raw, type) {
@ -1186,7 +1186,7 @@ L.U.DataLayer = L.Evented.extend({
], ],
] ]
const title = L.DomUtil.add('h3', '', container, L._('Layer properties')) const title = L.DomUtil.add('h3', '', container, L._('Layer properties'))
let builder = new L.U.FormBuilder(this, metadataFields, { let builder = new U.FormBuilder(this, metadataFields, {
callback: function (e) { callback: function (e) {
this.map.updateDatalayersControl() this.map.updateDatalayersControl()
if (e.helper.field === 'options.type') { if (e.helper.field === 'options.type') {
@ -1208,7 +1208,7 @@ L.U.DataLayer = L.Evented.extend({
const layerOptions = this.layer.getEditableOptions() const layerOptions = this.layer.getEditableOptions()
if (layerOptions.length) { if (layerOptions.length) {
builder = new L.U.FormBuilder(this, layerOptions, { builder = new U.FormBuilder(this, layerOptions, {
id: 'datalayer-layer-properties', id: 'datalayer-layer-properties',
callback: redrawCallback, callback: redrawCallback,
}) })
@ -1232,7 +1232,7 @@ L.U.DataLayer = L.Evented.extend({
'options.fillOpacity', 'options.fillOpacity',
] ]
builder = new L.U.FormBuilder(this, shapeOptions, { builder = new U.FormBuilder(this, shapeOptions, {
id: 'datalayer-advanced-properties', id: 'datalayer-advanced-properties',
callback: redrawCallback, callback: redrawCallback,
}) })
@ -1248,7 +1248,7 @@ L.U.DataLayer = L.Evented.extend({
'options.labelKey', 'options.labelKey',
] ]
builder = new L.U.FormBuilder(this, optionsFields, { builder = new U.FormBuilder(this, optionsFields, {
id: 'datalayer-advanced-properties', id: 'datalayer-advanced-properties',
callback: redrawCallback, callback: redrawCallback,
}) })
@ -1268,7 +1268,7 @@ L.U.DataLayer = L.Evented.extend({
'options.outlinkTarget', 'options.outlinkTarget',
'options.interactive', 'options.interactive',
] ]
builder = new L.U.FormBuilder(this, popupFields, { callback: redrawCallback }) builder = new U.FormBuilder(this, popupFields, { callback: redrawCallback })
const popupFieldset = L.DomUtil.createFieldset( const popupFieldset = L.DomUtil.createFieldset(
container, container,
L._('Interaction options') L._('Interaction options')
@ -1314,7 +1314,7 @@ L.U.DataLayer = L.Evented.extend({
} }
const remoteDataContainer = L.DomUtil.createFieldset(container, L._('Remote data')) const remoteDataContainer = L.DomUtil.createFieldset(container, L._('Remote data'))
builder = new L.U.FormBuilder(this, remoteDataFields) builder = new U.FormBuilder(this, remoteDataFields)
remoteDataContainer.appendChild(builder.build()) remoteDataContainer.appendChild(builder.build())
L.DomUtil.createButton( L.DomUtil.createButton(
'button umap-verify', 'button umap-verify',
@ -1646,7 +1646,7 @@ L.U.DataLayer = L.Evented.extend({
tableEdit: function () { tableEdit: function () {
if (this.isRemoteLayer() || !this.isVisible()) return if (this.isRemoteLayer() || !this.isVisible()) return
const editor = new L.U.TableEditor(this) const editor = new U.TableEditor(this)
editor.edit() editor.edit()
}, },
}) })

View file

@ -1,6 +1,6 @@
// Dedicated object so we can deal with a separate dirty status, and thus // Dedicated object so we can deal with a separate dirty status, and thus
// call the endpoint only when needed, saving one call at each save. // call the endpoint only when needed, saving one call at each save.
L.U.MapPermissions = L.Class.extend({ U.MapPermissions = L.Class.extend({
options: { options: {
owner: null, owner: null,
editors: [], editors: [],
@ -105,7 +105,7 @@ L.U.MapPermissions = L.Class.extend({
]) ])
} }
title.textContent = L._('Update permissions') title.textContent = L._('Update permissions')
const builder = new L.U.FormBuilder(this, fields) const builder = new U.FormBuilder(this, fields)
const form = builder.build() const form = builder.build()
container.appendChild(form) container.appendChild(form)
if (this.isAnonymousMap() && this.map.options.user) { if (this.isAnonymousMap() && this.map.options.user) {

View file

@ -1,6 +1,6 @@
/* Shapes */ /* Shapes */
L.U.Popup = L.Popup.extend({ U.Popup = L.Popup.extend({
options: { options: {
parseTemplate: true, parseTemplate: true,
}, },
@ -15,7 +15,7 @@ L.U.Popup = L.Popup.extend({
format: function () { format: function () {
const mode = this.feature.getOption('popupTemplate') || 'Default', const mode = this.feature.getOption('popupTemplate') || 'Default',
klass = L.U.PopupTemplate[mode] || L.U.PopupTemplate.Default klass = U.PopupTemplate[mode] || U.PopupTemplate.Default
this.content = new klass(this.feature, this.container) this.content = new klass(this.feature, this.container)
this.content.render() this.content.render()
const els = this.container.querySelectorAll('img,iframe') const els = this.container.querySelectorAll('img,iframe')
@ -42,14 +42,14 @@ L.U.Popup = L.Popup.extend({
}, },
}) })
L.U.Popup.Large = L.U.Popup.extend({ U.Popup.Large = U.Popup.extend({
options: { options: {
maxWidth: 500, maxWidth: 500,
className: 'umap-popup-large', className: 'umap-popup-large',
}, },
}) })
L.U.Popup.Panel = L.U.Popup.extend({ U.Popup.Panel = U.Popup.extend({
options: { options: {
zoomAnimation: false, zoomAnimation: false,
}, },
@ -97,13 +97,13 @@ L.U.Popup.Panel = L.U.Popup.extend({
_updatePosition: function () {}, _updatePosition: function () {},
_adjustPan: function () {}, _adjustPan: function () {},
}) })
L.U.Popup.SimplePanel = L.U.Popup.Panel // Retrocompat. U.Popup.SimplePanel = U.Popup.Panel // Retrocompat.
/* Content templates */ /* Content templates */
L.U.PopupTemplate = {} U.PopupTemplate = {}
L.U.PopupTemplate.Default = L.Class.extend({ U.PopupTemplate.Default = L.Class.extend({
initialize: function (feature, container) { initialize: function (feature, container) {
this.feature = feature this.feature = feature
this.container = container this.container = container
@ -176,7 +176,7 @@ L.U.PopupTemplate.Default = L.Class.extend({
}, },
}) })
L.U.PopupTemplate.BaseWithTitle = L.U.PopupTemplate.Default.extend({ U.PopupTemplate.BaseWithTitle = U.PopupTemplate.Default.extend({
renderTitle: function () { renderTitle: function () {
let title let title
if (this.feature.getDisplayName()) { if (this.feature.getDisplayName()) {
@ -187,7 +187,7 @@ L.U.PopupTemplate.BaseWithTitle = L.U.PopupTemplate.Default.extend({
}, },
}) })
L.U.PopupTemplate.Table = L.U.PopupTemplate.BaseWithTitle.extend({ U.PopupTemplate.Table = U.PopupTemplate.BaseWithTitle.extend({
formatRow: function (key, value) { formatRow: function (key, value) {
if (value.indexOf('http') === 0) { if (value.indexOf('http') === 0) {
value = `<a href="${value}" target="_blank">${value}</a>` value = `<a href="${value}" target="_blank">${value}</a>`
@ -213,7 +213,7 @@ L.U.PopupTemplate.Table = L.U.PopupTemplate.BaseWithTitle.extend({
}, },
}) })
L.U.PopupTemplate.GeoRSSImage = L.U.PopupTemplate.BaseWithTitle.extend({ U.PopupTemplate.GeoRSSImage = U.PopupTemplate.BaseWithTitle.extend({
options: { options: {
minWidth: 300, minWidth: 300,
maxWidth: 500, maxWidth: 500,
@ -237,7 +237,7 @@ L.U.PopupTemplate.GeoRSSImage = L.U.PopupTemplate.BaseWithTitle.extend({
}, },
}) })
L.U.PopupTemplate.GeoRSSLink = L.U.PopupTemplate.Default.extend({ U.PopupTemplate.GeoRSSLink = U.PopupTemplate.Default.extend({
options: { options: {
className: 'umap-georss-link', className: 'umap-georss-link',
}, },
@ -252,7 +252,7 @@ L.U.PopupTemplate.GeoRSSLink = L.U.PopupTemplate.Default.extend({
}, },
}) })
L.U.PopupTemplate.OSM = L.U.PopupTemplate.Default.extend({ U.PopupTemplate.OSM = U.PopupTemplate.Default.extend({
options: { options: {
className: 'umap-openstreetmap', className: 'umap-openstreetmap',
}, },
@ -270,9 +270,9 @@ L.U.PopupTemplate.OSM = L.U.PopupTemplate.Default.extend({
const color = this.feature.getDynamicOption('color') const color = this.feature.getDynamicOption('color')
title.style.backgroundColor = color title.style.backgroundColor = color
const iconUrl = this.feature.getDynamicOption('iconUrl') const iconUrl = this.feature.getDynamicOption('iconUrl')
let icon = L.U.Icon.makeIconElement(iconUrl, title) let icon = U.Icon.makeIconElement(iconUrl, title)
L.DomUtil.addClass(icon, 'icon') L.DomUtil.addClass(icon, 'icon')
L.U.Icon.setIconContrast(icon, title, iconUrl, color) U.Icon.setIconContrast(icon, title, iconUrl, color)
if (L.DomUtil.contrastedColor(title, color)) title.style.color = 'white' if (L.DomUtil.contrastedColor(title, color)) title.style.color = 'white'
L.DomUtil.add('span', '', title, this.getName()) L.DomUtil.add('span', '', title, this.getName())
const street = props['addr:street'] const street = props['addr:street']

View file

@ -1,4 +1,4 @@
L.U.Share = L.Class.extend({ U.Share = L.Class.extend({
EXPORT_TYPES: { EXPORT_TYPES: {
geojson: { geojson: {
formatter: function (map) { formatter: function (map) {
@ -138,13 +138,13 @@ L.U.Share = L.Class.extend({
for (let i = 0; i < this.map.HIDDABLE_CONTROLS.length; i++) { for (let i = 0; i < this.map.HIDDABLE_CONTROLS.length; i++) {
UIFields.push(`queryString.${this.map.HIDDABLE_CONTROLS[i]}Control`) UIFields.push(`queryString.${this.map.HIDDABLE_CONTROLS[i]}Control`)
} }
const iframeExporter = new L.U.IframeExporter(this.map) const iframeExporter = new U.IframeExporter(this.map)
const buildIframeCode = () => { const buildIframeCode = () => {
iframe.innerHTML = iframeExporter.build() iframe.innerHTML = iframeExporter.build()
exportUrl.value = window.location.protocol + iframeExporter.buildUrl() exportUrl.value = window.location.protocol + iframeExporter.buildUrl()
} }
buildIframeCode() buildIframeCode()
const builder = new L.U.FormBuilder(iframeExporter, UIFields, { const builder = new U.FormBuilder(iframeExporter, UIFields, {
callback: buildIframeCode, callback: buildIframeCode,
}) })
const iframeOptions = L.DomUtil.createFieldset( const iframeOptions = L.DomUtil.createFieldset(
@ -182,7 +182,7 @@ L.U.Share = L.Class.extend({
}, },
}) })
L.U.IframeExporter = L.Evented.extend({ U.IframeExporter = L.Evented.extend({
options: { options: {
includeFullScreenLink: true, includeFullScreenLink: true,
currentView: false, currentView: false,

View file

@ -1,4 +1,4 @@
L.U.Slideshow = L.Class.extend({ U.Slideshow = L.Class.extend({
statics: { statics: {
CLASSNAME: 'umap-slideshow-active', CLASSNAME: 'umap-slideshow-active',
}, },
@ -97,7 +97,7 @@ L.U.Slideshow = L.Class.extend({
play: function () { play: function () {
if (this._id) return if (this._id) return
if (this.map.editEnabled || !this.map.options.slideshow.active) return if (this.map.editEnabled || !this.map.options.slideshow.active) return
L.DomUtil.addClass(document.body, L.U.Slideshow.CLASSNAME) L.DomUtil.addClass(document.body, U.Slideshow.CLASSNAME)
this._id = window.setInterval(L.bind(this.loop, this), this.options.delay) this._id = window.setInterval(L.bind(this.loop, this), this.options.delay)
this.resetSpinners() this.resetSpinners()
this.loop() this.loop()
@ -110,7 +110,7 @@ L.U.Slideshow = L.Class.extend({
pause: function () { pause: function () {
if (this._id) { if (this._id) {
L.DomUtil.removeClass(document.body, L.U.Slideshow.CLASSNAME) L.DomUtil.removeClass(document.body, U.Slideshow.CLASSNAME)
window.clearInterval(this._id) window.clearInterval(this._id)
this._id = null this._id = null
} }

View file

@ -1,4 +1,4 @@
L.U.TableEditor = L.Class.extend({ U.TableEditor = L.Class.extend({
initialize: function (datalayer) { initialize: function (datalayer) {
this.datalayer = datalayer this.datalayer = datalayer
this.table = L.DomUtil.create('div', 'table') this.table = L.DomUtil.create('div', 'table')
@ -54,7 +54,7 @@ L.U.TableEditor = L.Class.extend({
}, },
renderRow: function (feature) { renderRow: function (feature) {
const builder = new L.U.FormBuilder(feature, this.field_properties, { const builder = new U.FormBuilder(feature, this.field_properties, {
id: `umap-feature-properties_${L.stamp(feature)}`, id: `umap-feature-properties_${L.stamp(feature)}`,
className: 'trow', className: 'trow',
callback: feature.resetTooltip, callback: feature.resetTooltip,

View file

@ -1,7 +1,7 @@
/* /*
* Modals * Modals
*/ */
L.U.UI = L.Evented.extend({ U.UI = L.Evented.extend({
ALERTS: Array(), ALERTS: Array(),
ALERT_ID: null, ALERT_ID: null,
TOOLTIP_ID: null, TOOLTIP_ID: null,

View file

@ -176,7 +176,7 @@ const POLYGONS = {
], ],
} }
describe('L.U.Choropleth', () => { describe('U.Choropleth', () => {
let path = '/map/99/datalayer/edit/62/', let path = '/map/99/datalayer/edit/62/',
poly1, poly1,
poly4, poly4,

View file

@ -1,4 +1,4 @@
describe('L.U.DataLayer', () => { describe('U.DataLayer', () => {
let path = '/map/99/datalayer/update/62/', let path = '/map/99/datalayer/update/62/',
map, map,
datalayer datalayer

View file

@ -1,4 +1,4 @@
describe('L.U.FeatureMixin', function () { describe('U.FeatureMixin', function () {
let map, datalayer let map, datalayer
before(async () => { before(async () => {
await fetchMock.mock( await fetchMock.mock(

View file

@ -1,4 +1,4 @@
describe('L.U.Map.Export', function () { describe('U.Map.Export', function () {
let map let map
before(async () => { before(async () => {
await fetchMock.mock( await fetchMock.mock(

View file

@ -1,4 +1,4 @@
describe('L.U.Map', () => { describe('U.Map', () => {
let map, datalayer let map, datalayer
before(async () => { before(async () => {
await fetchMock.mock( await fetchMock.mock(

View file

@ -1,4 +1,4 @@
describe('L.U.Marker', () => { describe('U.Marker', () => {
let map, datalayer let map, datalayer
before(async () => { before(async () => {
const datalayer_response = JSON.parse(JSON.stringify(RESPONSES.datalayer62_GET)) // Copy. const datalayer_response = JSON.parse(JSON.stringify(RESPONSES.datalayer62_GET)) // Copy.
@ -86,7 +86,7 @@ describe('L.U.Marker', () => {
describe('#clone', () => { describe('#clone', () => {
it('should clone marker', () => { it('should clone marker', () => {
var layer = new L.U.Marker(map, [10, 20], { var layer = new U.Marker(map, [10, 20], {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
assert.equal(datalayer._index.length, 4) assert.equal(datalayer._index.length, 4)
@ -102,7 +102,7 @@ describe('L.U.Marker', () => {
describe('#edit()', function (done) { describe('#edit()', function (done) {
it('should allow changing coordinates manually', () => { it('should allow changing coordinates manually', () => {
var layer = new L.U.Marker(map, [10, 20], { var layer = new U.Marker(map, [10, 20], {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
enableEdit() enableEdit()
@ -112,7 +112,7 @@ describe('L.U.Marker', () => {
}) })
it('should not allow invalid latitude nor longitude', () => { it('should not allow invalid latitude nor longitude', () => {
var layer = new L.U.Marker(map, [10, 20], { var layer = new U.Marker(map, [10, 20], {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
enableEdit() enableEdit()

View file

@ -1,4 +1,4 @@
describe('L.U.Polygon', function () { describe('U.Polygon', function () {
var p2ll, map, datalayer var p2ll, map, datalayer
before(function () { before(function () {
@ -22,7 +22,7 @@ describe('L.U.Polygon', function () {
describe('#isMulti()', function () { describe('#isMulti()', function () {
it('should return false for basic Polygon', function () { it('should return false for basic Polygon', function () {
var layer = new L.U.Polygon( var layer = new U.Polygon(
map, map,
[ [
[1, 2], [1, 2],
@ -36,12 +36,12 @@ describe('L.U.Polygon', function () {
it('should return false for nested basic Polygon', function () { it('should return false for nested basic Polygon', function () {
var latlngs = [[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]]], var latlngs = [[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]]],
layer = new L.U.Polygon(map, latlngs, { datalayer: datalayer }) layer = new U.Polygon(map, latlngs, { datalayer: datalayer })
assert.notOk(layer.isMulti()) assert.notOk(layer.isMulti())
}) })
it('should return false for simple Polygon with hole', function () { it('should return false for simple Polygon with hole', function () {
var layer = new L.U.Polygon( var layer = new U.Polygon(
map, map,
[ [
[ [
@ -77,7 +77,7 @@ describe('L.U.Polygon', function () {
], ],
], ],
] ]
var layer = new L.U.Polygon(map, latLngs, { datalayer: datalayer }) var layer = new U.Polygon(map, latLngs, { datalayer: datalayer })
assert.ok(layer.isMulti()) assert.ok(layer.isMulti())
}) })
@ -103,7 +103,7 @@ describe('L.U.Polygon', function () {
], ],
], ],
] ]
var layer = new L.U.Polygon(map, latLngs, { datalayer: datalayer }) var layer = new U.Polygon(map, latLngs, { datalayer: datalayer })
assert.ok(layer.isMulti()) assert.ok(layer.isMulti())
}) })
}) })
@ -120,7 +120,7 @@ describe('L.U.Polygon', function () {
[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]], [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]],
[[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]], [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]],
], ],
layer = new L.U.Polygon(map, latlngs, { layer = new U.Polygon(map, latlngs, {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -129,7 +129,7 @@ describe('L.U.Polygon', function () {
it('should not allow to remove shape when not multi', function () { it('should not allow to remove shape when not multi', function () {
var latlngs = [[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]]], var latlngs = [[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]]],
layer = new L.U.Polygon(map, latlngs, { layer = new U.Polygon(map, latlngs, {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -138,7 +138,7 @@ describe('L.U.Polygon', function () {
it('should not allow to isolate shape when not multi', function () { it('should not allow to isolate shape when not multi', function () {
var latlngs = [[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]]], var latlngs = [[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]]],
layer = new L.U.Polygon(map, latlngs, { layer = new U.Polygon(map, latlngs, {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -150,7 +150,7 @@ describe('L.U.Polygon', function () {
[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]], [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]],
[[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]], [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]],
], ],
layer = new L.U.Polygon(map, latlngs, { layer = new U.Polygon(map, latlngs, {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -162,7 +162,7 @@ describe('L.U.Polygon', function () {
[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]], [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]],
[[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]], [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]],
], ],
layer = new L.U.Polygon(map, latlngs, { layer = new U.Polygon(map, latlngs, {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -176,7 +176,7 @@ describe('L.U.Polygon', function () {
[p2ll(120, 150), p2ll(150, 180), p2ll(180, 120)], [p2ll(120, 150), p2ll(150, 180), p2ll(180, 120)],
], ],
], ],
layer = new L.U.Polygon(map, latlngs, { layer = new U.Polygon(map, latlngs, {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -185,7 +185,7 @@ describe('L.U.Polygon', function () {
it('should allow to transform to lines when not multi', function () { it('should allow to transform to lines when not multi', function () {
var latlngs = [[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]]] var latlngs = [[[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]]]
new L.U.Polygon(map, latlngs, { datalayer: datalayer }).addTo( new U.Polygon(map, latlngs, { datalayer: datalayer }).addTo(
datalayer datalayer
) )
happen.at('contextmenu', 150, 150) happen.at('contextmenu', 150, 150)
@ -193,7 +193,7 @@ describe('L.U.Polygon', function () {
}) })
it('should not allow to transfer shape when not editedFeature', function () { it('should not allow to transfer shape when not editedFeature', function () {
new L.U.Polygon(map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], { new U.Polygon(map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
happen.at('contextmenu', 110, 160) happen.at('contextmenu', 110, 160)
@ -202,12 +202,12 @@ describe('L.U.Polygon', function () {
}) })
it('should not allow to transfer shape when editedFeature is not a polygon', function () { it('should not allow to transfer shape when editedFeature is not a polygon', function () {
var layer = new L.U.Polygon( var layer = new U.Polygon(
map, map,
[p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)],
{ datalayer: datalayer } { datalayer: datalayer }
).addTo(datalayer), ).addTo(datalayer),
other = new L.U.Polyline(map, [p2ll(200, 250), p2ll(200, 300)], { other = new U.Polyline(map, [p2ll(200, 250), p2ll(200, 300)], {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
other.edit() other.edit()
@ -218,13 +218,13 @@ describe('L.U.Polygon', function () {
it('should allow to transfer shape when another polygon is edited', function () { it('should allow to transfer shape when another polygon is edited', function () {
datalayer.empty() datalayer.empty()
var layer = new L.U.Polygon( var layer = new U.Polygon(
map, map,
[p2ll(200, 300), p2ll(300, 200), p2ll(200, 100)], [p2ll(200, 300), p2ll(300, 200), p2ll(200, 100)],
{ datalayer: datalayer } { datalayer: datalayer }
).addTo(datalayer) ).addTo(datalayer)
layer.edit() // This moves the map to put "other" at the center. layer.edit() // This moves the map to put "other" at the center.
var other = new L.U.Polygon( var other = new U.Polygon(
map, map,
[p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)],
{ datalayer: datalayer } { datalayer: datalayer }
@ -242,7 +242,7 @@ describe('L.U.Polygon', function () {
}) })
it('"add shape" control should be visible when editing a Polygon', function () { it('"add shape" control should be visible when editing a Polygon', function () {
var layer = new L.U.Polygon(map, [p2ll(100, 100), p2ll(100, 200)], { var layer = new U.Polygon(map, [p2ll(100, 100), p2ll(100, 200)], {
datalayer: datalayer, datalayer: datalayer,
}).addTo(datalayer) }).addTo(datalayer)
layer.edit() layer.edit()
@ -250,7 +250,7 @@ describe('L.U.Polygon', function () {
}) })
it('"add shape" control should extend the same multi', function () { it('"add shape" control should extend the same multi', function () {
var layer = new L.U.Polygon( var layer = new U.Polygon(
map, map,
[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)], [p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)],
{ datalayer: datalayer } { datalayer: datalayer }
@ -271,10 +271,10 @@ describe('L.U.Polygon', function () {
describe('#transferShape', function () { describe('#transferShape', function () {
it('should transfer simple polygon shape to another polygon', function () { it('should transfer simple polygon shape to another polygon', function () {
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
layer = new L.U.Polygon(map, latlngs, { datalayer: datalayer }).addTo( layer = new U.Polygon(map, latlngs, { datalayer: datalayer }).addTo(
datalayer datalayer
), ),
other = new L.U.Polygon( other = new U.Polygon(
map, map,
[p2ll(200, 350), p2ll(200, 300), p2ll(300, 200)], [p2ll(200, 350), p2ll(200, 300), p2ll(300, 200)],
{ datalayer: datalayer } { datalayer: datalayer }
@ -294,10 +294,10 @@ describe('L.U.Polygon', function () {
], ],
[[p2ll(200, 300), p2ll(300, 200)]], [[p2ll(200, 300), p2ll(300, 200)]],
], ],
layer = new L.U.Polygon(map, latlngs, { datalayer: datalayer }).addTo( layer = new U.Polygon(map, latlngs, { datalayer: datalayer }).addTo(
datalayer datalayer
), ),
other = new L.U.Polygon( other = new U.Polygon(
map, map,
[p2ll(200, 350), p2ll(200, 300), p2ll(300, 200)], [p2ll(200, 350), p2ll(200, 300), p2ll(300, 200)],
{ datalayer: datalayer } { datalayer: datalayer }
@ -314,7 +314,7 @@ describe('L.U.Polygon', function () {
describe('#isolateShape', function () { describe('#isolateShape', function () {
it('should not allow to isolate simple polygon', function () { it('should not allow to isolate simple polygon', function () {
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
layer = new L.U.Polygon(map, latlngs, { datalayer: datalayer }).addTo( layer = new U.Polygon(map, latlngs, { datalayer: datalayer }).addTo(
datalayer datalayer
) )
assert.equal(datalayer._index.length, 1) assert.equal(datalayer._index.length, 1)
@ -332,7 +332,7 @@ describe('L.U.Polygon', function () {
], ],
[[p2ll(200, 300), p2ll(300, 200)]], [[p2ll(200, 300), p2ll(300, 200)]],
], ],
layer = new L.U.Polygon(map, latlngs, { datalayer: datalayer }).addTo( layer = new U.Polygon(map, latlngs, { datalayer: datalayer }).addTo(
datalayer datalayer
) )
assert.equal(datalayer._index.length, 1) assert.equal(datalayer._index.length, 1)
@ -351,7 +351,7 @@ describe('L.U.Polygon', function () {
describe('#clone', function () { describe('#clone', function () {
it('should clone polygon', function () { it('should clone polygon', function () {
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
layer = new L.U.Polygon(map, latlngs, { datalayer: datalayer }).addTo( layer = new U.Polygon(map, latlngs, { datalayer: datalayer }).addTo(
datalayer datalayer
) )
assert.equal(datalayer._index.length, 1) assert.equal(datalayer._index.length, 1)

View file

@ -1,4 +1,4 @@
describe('L.U.Polyline', function () { describe('U.Polyline', function () {
var p2ll, map var p2ll, map
before(function () { before(function () {
@ -22,7 +22,7 @@ describe('L.U.Polyline', function () {
describe('#isMulti()', function () { describe('#isMulti()', function () {
it('should return false for basic Polyline', function () { it('should return false for basic Polyline', function () {
var layer = new L.U.Polyline( var layer = new U.Polyline(
this.map, this.map,
[ [
[1, 2], [1, 2],
@ -35,7 +35,7 @@ describe('L.U.Polyline', function () {
}) })
it('should return false for nested basic Polyline', function () { it('should return false for nested basic Polyline', function () {
var layer = new L.U.Polyline( var layer = new U.Polyline(
this.map, this.map,
[ [
[ [
@ -66,7 +66,7 @@ describe('L.U.Polyline', function () {
], ],
], ],
] ]
var layer = new L.U.Polyline(this.map, latLngs, { datalayer: this.datalayer }) var layer = new U.Polyline(this.map, latLngs, { datalayer: this.datalayer })
assert.ok(layer.isMulti()) assert.ok(layer.isMulti())
}) })
}) })
@ -83,7 +83,7 @@ describe('L.U.Polyline', function () {
[p2ll(100, 100), p2ll(100, 200)], [p2ll(100, 100), p2ll(100, 200)],
[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)], [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)],
], ],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -92,7 +92,7 @@ describe('L.U.Polyline', function () {
it('should not allow to remove shape when not multi', function () { it('should not allow to remove shape when not multi', function () {
var latlngs = [[p2ll(100, 100), p2ll(100, 200)]], var latlngs = [[p2ll(100, 100), p2ll(100, 200)]],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -101,7 +101,7 @@ describe('L.U.Polyline', function () {
it('should not allow to isolate shape when not multi', function () { it('should not allow to isolate shape when not multi', function () {
var latlngs = [[p2ll(100, 100), p2ll(100, 200)]], var latlngs = [[p2ll(100, 100), p2ll(100, 200)]],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -113,7 +113,7 @@ describe('L.U.Polyline', function () {
[p2ll(100, 150), p2ll(100, 200)], [p2ll(100, 150), p2ll(100, 200)],
[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)], [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)],
], ],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -125,7 +125,7 @@ describe('L.U.Polyline', function () {
[p2ll(100, 150), p2ll(100, 200)], [p2ll(100, 150), p2ll(100, 200)],
[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)], [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)],
], ],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -134,7 +134,7 @@ describe('L.U.Polyline', function () {
it('should allow to transform to polygon when not multi', function () { it('should allow to transform to polygon when not multi', function () {
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -142,7 +142,7 @@ describe('L.U.Polyline', function () {
}) })
it('should not allow to transfer shape when not editedFeature', function () { it('should not allow to transfer shape when not editedFeature', function () {
var layer = new L.U.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], { var layer = new U.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -150,10 +150,10 @@ describe('L.U.Polyline', function () {
}) })
it('should not allow to transfer shape when editedFeature is not a line', function () { it('should not allow to transfer shape when editedFeature is not a line', function () {
var layer = new L.U.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], { var layer = new U.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer), }).addTo(this.datalayer),
other = new L.U.Polygon( other = new U.Polygon(
this.map, this.map,
[p2ll(200, 300), p2ll(300, 200), p2ll(200, 100)], [p2ll(200, 300), p2ll(300, 200), p2ll(200, 100)],
{ datalayer: this.datalayer } { datalayer: this.datalayer }
@ -164,12 +164,12 @@ describe('L.U.Polyline', function () {
}) })
it('should allow to transfer shape when another line is edited', function () { it('should allow to transfer shape when another line is edited', function () {
var layer = new L.U.Polyline( var layer = new U.Polyline(
this.map, this.map,
[p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
{ datalayer: this.datalayer } { datalayer: this.datalayer }
).addTo(this.datalayer), ).addTo(this.datalayer),
other = new L.U.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], { other = new U.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
other.edit() other.edit()
@ -184,7 +184,7 @@ describe('L.U.Polyline', function () {
[p2ll(100, 100), p2ll(100, 200)], [p2ll(100, 100), p2ll(100, 200)],
[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)], [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)],
], ],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -193,7 +193,7 @@ describe('L.U.Polyline', function () {
it('should not allow to merge lines when not multi', function () { it('should not allow to merge lines when not multi', function () {
var latlngs = [[p2ll(100, 100), p2ll(100, 200)]], var latlngs = [[p2ll(100, 100), p2ll(100, 200)]],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
happen.once(layer._path, { type: 'contextmenu' }) happen.once(layer._path, { type: 'contextmenu' })
@ -202,7 +202,7 @@ describe('L.U.Polyline', function () {
it('should allow to split lines when clicking on vertex', function () { it('should allow to split lines when clicking on vertex', function () {
var latlngs = [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]], var latlngs = [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
layer.enableEdit() layer.enableEdit()
@ -212,7 +212,7 @@ describe('L.U.Polyline', function () {
it('should not allow to split lines when clicking on first vertex', function () { it('should not allow to split lines when clicking on first vertex', function () {
var latlngs = [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]], var latlngs = [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
layer.enableEdit() layer.enableEdit()
@ -223,7 +223,7 @@ describe('L.U.Polyline', function () {
it('should not allow to split lines when clicking on last vertex', function () { it('should not allow to split lines when clicking on last vertex', function () {
var latlngs = [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]], var latlngs = [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
layer.enableEdit() layer.enableEdit()
@ -240,7 +240,7 @@ describe('L.U.Polyline', function () {
}) })
it('"add shape" control should be visible when editing a Polyline', function () { it('"add shape" control should be visible when editing a Polyline', function () {
var layer = new L.U.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], { var layer = new U.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
layer.edit() layer.edit()
@ -248,7 +248,7 @@ describe('L.U.Polyline', function () {
}) })
it('"add shape" control should extend the same multi', function () { it('"add shape" control should extend the same multi', function () {
var layer = new L.U.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], { var layer = new U.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
layer.edit() layer.edit()
@ -267,10 +267,10 @@ describe('L.U.Polyline', function () {
describe('#transferShape', function () { describe('#transferShape', function () {
it('should transfer simple line shape to another line', function () { it('should transfer simple line shape to another line', function () {
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer), }).addTo(this.datalayer),
other = new L.U.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], { other = new U.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
assert.ok(this.map.hasLayer(layer)) assert.ok(this.map.hasLayer(layer))
@ -285,10 +285,10 @@ describe('L.U.Polyline', function () {
[p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
[p2ll(200, 300), p2ll(300, 200)], [p2ll(200, 300), p2ll(300, 200)],
], ],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer), }).addTo(this.datalayer),
other = new L.U.Polyline(this.map, [p2ll(250, 300), p2ll(350, 200)], { other = new U.Polyline(this.map, [p2ll(250, 300), p2ll(350, 200)], {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
assert.ok(this.map.hasLayer(layer)) assert.ok(this.map.hasLayer(layer))
@ -312,7 +312,7 @@ describe('L.U.Polyline', function () {
[0, 2], [0, 2],
], ],
], ],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
layer.mergeShapes() layer.mergeShapes()
@ -336,7 +336,7 @@ describe('L.U.Polyline', function () {
[0, 1], [0, 1],
], ],
], ],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
layer.mergeShapes() layer.mergeShapes()
@ -352,7 +352,7 @@ describe('L.U.Polyline', function () {
describe('#isolateShape', function () { describe('#isolateShape', function () {
it('should not allow to isolate simple line', function () { it('should not allow to isolate simple line', function () {
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
assert.equal(this.datalayer._index.length, 1) assert.equal(this.datalayer._index.length, 1)
@ -367,7 +367,7 @@ describe('L.U.Polyline', function () {
[p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
[[p2ll(200, 300), p2ll(300, 200)]], [[p2ll(200, 300), p2ll(300, 200)]],
], ],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
assert.equal(this.datalayer._index.length, 1) assert.equal(this.datalayer._index.length, 1)
@ -386,7 +386,7 @@ describe('L.U.Polyline', function () {
describe('#clone', function () { describe('#clone', function () {
it('should clone polyline', function () { it('should clone polyline', function () {
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
layer = new L.U.Polyline(this.map, latlngs, { layer = new U.Polyline(this.map, latlngs, {
datalayer: this.datalayer, datalayer: this.datalayer,
}).addTo(this.datalayer) }).addTo(this.datalayer)
assert.equal(this.datalayer._index.length, 1) assert.equal(this.datalayer._index.length, 1)

View file

@ -219,7 +219,7 @@ function initMap(options) {
type: 'Point', type: 'Point',
coordinates: [5.0592041015625, 52.05924589011585], coordinates: [5.0592041015625, 52.05924589011585],
} }
return new L.U.Map('map', options) return new U.Map('map', options)
} }
var RESPONSES = { var RESPONSES = {

View file

@ -38,8 +38,8 @@
{{ block.super }} {{ block.super }}
<script type="text/javascript"> <script type="text/javascript">
window.addEventListener('DOMContentLoaded', event => { window.addEventListener('DOMContentLoaded', event => {
const ui = new L.U.UI(document.querySelector('header')) const ui = new U.UI(document.querySelector('header'))
const server = new window.umap.ServerRequest(ui) const server = new U.ServerRequest(ui)
const getMore = async function (e) { const getMore = async function (e) {
L.DomEvent.stop(e) L.DomEvent.stop(e)
const [{html}, response, error] = await server.get(this.href) const [{html}, response, error] = await server.get(this.href)

View file

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