umap-project 1.14.0a1__py3-none-any.whl → 1.14.0a2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/static/.gitignore +0 -0
- umap/static/umap/base.css +994 -0
- umap/static/umap/bitbucket.png +0 -0
- umap/static/umap/content.css +395 -0
- umap/static/umap/favicons/apple-touch-icon.png +0 -0
- umap/static/umap/favicons/favicon.ico +0 -0
- umap/static/umap/favicons/icon-192.png +0 -0
- umap/static/umap/favicons/icon-512.png +0 -0
- umap/static/umap/favicons/icon.svg +5 -0
- umap/static/umap/font/FiraSans-Light.woff +0 -0
- umap/static/umap/font/FiraSans-Light.woff2 +0 -0
- umap/static/umap/font/FiraSans-LightItalic.woff +0 -0
- umap/static/umap/font/FiraSans-LightItalic.woff2 +0 -0
- umap/static/umap/font/FiraSans-SemiBold.woff +0 -0
- umap/static/umap/font/FiraSans-SemiBold.woff2 +0 -0
- umap/static/umap/font.css +33 -0
- umap/static/umap/github.png +0 -0
- umap/static/umap/img/16-white.svg +190 -0
- umap/static/umap/img/16.svg +182 -0
- umap/static/umap/img/24-white.svg +62 -0
- umap/static/umap/img/24.svg +90 -0
- umap/static/umap/img/edit.svg +7 -0
- umap/static/umap/img/icon-bg.png +0 -0
- umap/static/umap/img/logo.svg +4 -0
- umap/static/umap/img/logo_filigree.png +0 -0
- umap/static/umap/img/logo_small.svg +14 -0
- umap/static/umap/img/marker.png +0 -0
- umap/static/umap/img/opensource.svg +7 -0
- umap/static/umap/img/osm.svg +7 -0
- umap/static/umap/img/search.gif +0 -0
- umap/static/umap/img/source/16-white.svg +980 -0
- umap/static/umap/img/source/16.svg +201 -0
- umap/static/umap/img/source/24-white.svg +83 -0
- umap/static/umap/img/source/24.svg +110 -0
- umap/static/umap/js/components/fragment.js +13 -0
- umap/static/umap/js/modules/global.js +8 -0
- umap/static/umap/js/modules/urls.js +29 -0
- umap/static/umap/js/umap.autocomplete.js +336 -0
- umap/static/umap/js/umap.browser.js +148 -0
- umap/static/umap/js/umap.controls.js +1542 -0
- umap/static/umap/js/umap.core.js +851 -0
- umap/static/umap/js/umap.datalayer.permissions.js +72 -0
- umap/static/umap/js/umap.features.js +1216 -0
- umap/static/umap/js/umap.forms.js +1267 -0
- umap/static/umap/js/umap.icon.js +234 -0
- umap/static/umap/js/umap.importer.js +166 -0
- umap/static/umap/js/umap.js +2010 -0
- umap/static/umap/js/umap.layer.js +1636 -0
- umap/static/umap/js/umap.permissions.js +212 -0
- umap/static/umap/js/umap.popup.js +340 -0
- umap/static/umap/js/umap.share.js +254 -0
- umap/static/umap/js/umap.slideshow.js +165 -0
- umap/static/umap/js/umap.tableeditor.js +120 -0
- umap/static/umap/js/umap.ui.js +240 -0
- umap/static/umap/js/umap.xhr.js +304 -0
- umap/static/umap/locale/am_ET.js +447 -0
- umap/static/umap/locale/am_ET.json +445 -0
- umap/static/umap/locale/ar.js +447 -0
- umap/static/umap/locale/ar.json +445 -0
- umap/static/umap/locale/ast.js +447 -0
- umap/static/umap/locale/ast.json +445 -0
- umap/static/umap/locale/bg.js +447 -0
- umap/static/umap/locale/bg.json +445 -0
- umap/static/umap/locale/br.js +447 -0
- umap/static/umap/locale/br.json +445 -0
- umap/static/umap/locale/ca.js +447 -0
- umap/static/umap/locale/ca.json +445 -0
- umap/static/umap/locale/cs_CZ.js +447 -0
- umap/static/umap/locale/cs_CZ.json +445 -0
- umap/static/umap/locale/da.js +447 -0
- umap/static/umap/locale/da.json +445 -0
- umap/static/umap/locale/de.js +447 -0
- umap/static/umap/locale/de.json +445 -0
- umap/static/umap/locale/el.js +447 -0
- umap/static/umap/locale/el.json +445 -0
- umap/static/umap/locale/en.js +447 -0
- umap/static/umap/locale/en.json +445 -0
- umap/static/umap/locale/en_US.json +445 -0
- umap/static/umap/locale/es.js +447 -0
- umap/static/umap/locale/es.json +445 -0
- umap/static/umap/locale/et.js +447 -0
- umap/static/umap/locale/et.json +445 -0
- umap/static/umap/locale/eu.js +413 -0
- umap/static/umap/locale/eu.json +411 -0
- umap/static/umap/locale/fa_IR.js +447 -0
- umap/static/umap/locale/fa_IR.json +445 -0
- umap/static/umap/locale/fi.js +447 -0
- umap/static/umap/locale/fi.json +445 -0
- umap/static/umap/locale/fr.js +447 -0
- umap/static/umap/locale/fr.json +445 -0
- umap/static/umap/locale/gl.js +447 -0
- umap/static/umap/locale/gl.json +445 -0
- umap/static/umap/locale/he.js +447 -0
- umap/static/umap/locale/he.json +445 -0
- umap/static/umap/locale/hr.js +447 -0
- umap/static/umap/locale/hr.json +445 -0
- umap/static/umap/locale/hu.js +447 -0
- umap/static/umap/locale/hu.json +445 -0
- umap/static/umap/locale/id.js +447 -0
- umap/static/umap/locale/id.json +445 -0
- umap/static/umap/locale/is.js +447 -0
- umap/static/umap/locale/is.json +445 -0
- umap/static/umap/locale/it.js +447 -0
- umap/static/umap/locale/it.json +445 -0
- umap/static/umap/locale/ja.js +447 -0
- umap/static/umap/locale/ja.json +445 -0
- umap/static/umap/locale/ko.js +447 -0
- umap/static/umap/locale/ko.json +445 -0
- umap/static/umap/locale/lt.js +447 -0
- umap/static/umap/locale/lt.json +445 -0
- umap/static/umap/locale/ms.js +447 -0
- umap/static/umap/locale/ms.json +445 -0
- umap/static/umap/locale/nl.js +447 -0
- umap/static/umap/locale/nl.json +445 -0
- umap/static/umap/locale/no.js +447 -0
- umap/static/umap/locale/no.json +445 -0
- umap/static/umap/locale/pl.js +447 -0
- umap/static/umap/locale/pl.json +445 -0
- umap/static/umap/locale/pl_PL.json +445 -0
- umap/static/umap/locale/pt.js +447 -0
- umap/static/umap/locale/pt.json +445 -0
- umap/static/umap/locale/pt_BR.js +447 -0
- umap/static/umap/locale/pt_BR.json +445 -0
- umap/static/umap/locale/pt_PT.js +447 -0
- umap/static/umap/locale/pt_PT.json +445 -0
- umap/static/umap/locale/ro.js +447 -0
- umap/static/umap/locale/ro.json +445 -0
- umap/static/umap/locale/ru.js +447 -0
- umap/static/umap/locale/ru.json +445 -0
- umap/static/umap/locale/si.js +439 -0
- umap/static/umap/locale/si.json +437 -0
- umap/static/umap/locale/sk_SK.js +447 -0
- umap/static/umap/locale/sk_SK.json +445 -0
- umap/static/umap/locale/sl.js +447 -0
- umap/static/umap/locale/sl.json +445 -0
- umap/static/umap/locale/sr.js +447 -0
- umap/static/umap/locale/sr.json +445 -0
- umap/static/umap/locale/sv.js +447 -0
- umap/static/umap/locale/sv.json +445 -0
- umap/static/umap/locale/th_TH.js +447 -0
- umap/static/umap/locale/th_TH.json +445 -0
- umap/static/umap/locale/tr.js +447 -0
- umap/static/umap/locale/tr.json +445 -0
- umap/static/umap/locale/uk_UA.js +447 -0
- umap/static/umap/locale/uk_UA.json +445 -0
- umap/static/umap/locale/vi.js +447 -0
- umap/static/umap/locale/vi.json +445 -0
- umap/static/umap/locale/vi_VN.json +445 -0
- umap/static/umap/locale/zh.js +447 -0
- umap/static/umap/locale/zh.json +445 -0
- umap/static/umap/locale/zh_CN.json +445 -0
- umap/static/umap/locale/zh_TW.Big5.json +445 -0
- umap/static/umap/locale/zh_TW.js +447 -0
- umap/static/umap/locale/zh_TW.json +445 -0
- umap/static/umap/map.css +1843 -0
- umap/static/umap/nav.css +81 -0
- umap/static/umap/openstreetmap.png +0 -0
- umap/static/umap/test/.eslintrc +22 -0
- umap/static/umap/test/Choropleth.js +243 -0
- umap/static/umap/test/Controls.js +100 -0
- umap/static/umap/test/DataLayer.js +495 -0
- umap/static/umap/test/Feature.js +382 -0
- umap/static/umap/test/Map.Export.js +106 -0
- umap/static/umap/test/Map.Init.js +46 -0
- umap/static/umap/test/Map.js +342 -0
- umap/static/umap/test/Marker.js +122 -0
- umap/static/umap/test/Permissions.js +74 -0
- umap/static/umap/test/Polygon.js +367 -0
- umap/static/umap/test/Polyline.js +402 -0
- umap/static/umap/test/TableEditor.js +100 -0
- umap/static/umap/test/URLs.js +54 -0
- umap/static/umap/test/Util.js +549 -0
- umap/static/umap/test/_pre.js +460 -0
- umap/static/umap/test/index.html +135 -0
- umap/static/umap/theme.css +1 -0
- umap/static/umap/twitter.png +0 -0
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/METADATA +1 -1
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/RECORD +182 -6
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/WHEEL +0 -0
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/entry_points.txt +0 -0
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// Dedicated object so we can deal with a separate dirty status, and thus
|
|
2
|
+
// call the endpoint only when needed, saving one call at each save.
|
|
3
|
+
L.U.MapPermissions = L.Class.extend({
|
|
4
|
+
options: {
|
|
5
|
+
owner: null,
|
|
6
|
+
editors: [],
|
|
7
|
+
share_status: null,
|
|
8
|
+
edit_status: null,
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
initialize: function (map) {
|
|
12
|
+
this.setOptions(map.options.permissions)
|
|
13
|
+
this.map = map
|
|
14
|
+
let isDirty = false
|
|
15
|
+
const self = this
|
|
16
|
+
try {
|
|
17
|
+
Object.defineProperty(this, 'isDirty', {
|
|
18
|
+
get: function () {
|
|
19
|
+
return isDirty
|
|
20
|
+
},
|
|
21
|
+
set: function (status) {
|
|
22
|
+
isDirty = status
|
|
23
|
+
if (status) {
|
|
24
|
+
self.map.isDirty = status
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
} catch (e) {
|
|
29
|
+
// Certainly IE8, which has a limited version of defineProperty
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
setOptions: function (options) {
|
|
34
|
+
this.options = L.Util.setOptions(this, options)
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
isOwner: function () {
|
|
38
|
+
return (
|
|
39
|
+
this.map.options.user &&
|
|
40
|
+
this.map.options.permissions.owner &&
|
|
41
|
+
this.map.options.user.id == this.map.options.permissions.owner.id
|
|
42
|
+
)
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
isAnonymousMap: function () {
|
|
46
|
+
return !this.map.options.permissions.owner
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
getMap: function () {
|
|
50
|
+
return this.map
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
edit: function () {
|
|
54
|
+
if (this.map.options.editMode !== 'advanced') return
|
|
55
|
+
if (!this.map.options.umap_id)
|
|
56
|
+
return this.map.ui.alert({
|
|
57
|
+
content: L._('Please save the map first'),
|
|
58
|
+
level: 'info',
|
|
59
|
+
})
|
|
60
|
+
const container = L.DomUtil.create('div', 'permissions-panel'),
|
|
61
|
+
fields = [],
|
|
62
|
+
title = L.DomUtil.create('h3', '', container)
|
|
63
|
+
if (this.isAnonymousMap()) {
|
|
64
|
+
if (this.options.anonymous_edit_url) {
|
|
65
|
+
const helpText = `${L._('Secret edit link:')}<br>${
|
|
66
|
+
this.options.anonymous_edit_url
|
|
67
|
+
}`
|
|
68
|
+
L.DomUtil.add('p', 'help-text', container, helpText)
|
|
69
|
+
fields.push([
|
|
70
|
+
'options.edit_status',
|
|
71
|
+
{
|
|
72
|
+
handler: 'IntSelect',
|
|
73
|
+
label: L._('Who can edit'),
|
|
74
|
+
selectOptions: this.map.options.edit_statuses,
|
|
75
|
+
helpText: helpText,
|
|
76
|
+
},
|
|
77
|
+
])
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
if (this.isOwner()) {
|
|
81
|
+
fields.push([
|
|
82
|
+
'options.edit_status',
|
|
83
|
+
{
|
|
84
|
+
handler: 'IntSelect',
|
|
85
|
+
label: L._('Who can edit'),
|
|
86
|
+
selectOptions: this.map.options.edit_statuses,
|
|
87
|
+
},
|
|
88
|
+
])
|
|
89
|
+
fields.push([
|
|
90
|
+
'options.share_status',
|
|
91
|
+
{
|
|
92
|
+
handler: 'IntSelect',
|
|
93
|
+
label: L._('Who can view'),
|
|
94
|
+
selectOptions: this.map.options.share_statuses,
|
|
95
|
+
},
|
|
96
|
+
])
|
|
97
|
+
fields.push([
|
|
98
|
+
'options.owner',
|
|
99
|
+
{ handler: 'ManageOwner', label: L._("Map's owner") },
|
|
100
|
+
])
|
|
101
|
+
}
|
|
102
|
+
fields.push([
|
|
103
|
+
'options.editors',
|
|
104
|
+
{ handler: 'ManageEditors', label: L._("Map's editors") },
|
|
105
|
+
])
|
|
106
|
+
}
|
|
107
|
+
title.textContent = L._('Update permissions')
|
|
108
|
+
const builder = new L.U.FormBuilder(this, fields)
|
|
109
|
+
const form = builder.build()
|
|
110
|
+
container.appendChild(form)
|
|
111
|
+
if (this.isAnonymousMap() && this.map.options.user) {
|
|
112
|
+
// We have a user, and this user has come through here, so they can edit the map, so let's allow to own the map.
|
|
113
|
+
// Note: real check is made on the back office anyway.
|
|
114
|
+
const advancedActions = L.DomUtil.createFieldset(
|
|
115
|
+
container,
|
|
116
|
+
L._('Advanced actions')
|
|
117
|
+
)
|
|
118
|
+
const advancedButtons = L.DomUtil.create('div', 'button-bar', advancedActions)
|
|
119
|
+
const download = L.DomUtil.createButton(
|
|
120
|
+
'button',
|
|
121
|
+
advancedButtons,
|
|
122
|
+
L._('Attach the map to my account'),
|
|
123
|
+
this.attach,
|
|
124
|
+
this
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
L.DomUtil.add('h4', '', container, L._('Datalayers'))
|
|
128
|
+
this.map.eachDataLayer((datalayer) => {
|
|
129
|
+
datalayer.permissions.edit(container)
|
|
130
|
+
})
|
|
131
|
+
this.map.ui.openPanel({ data: { html: container }, className: 'dark' })
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
attach: function () {
|
|
135
|
+
this.map.post(this.getAttachUrl(), {
|
|
136
|
+
callback: function () {
|
|
137
|
+
this.options.owner = this.map.options.user
|
|
138
|
+
this.map.ui.alert({
|
|
139
|
+
content: L._('Map has been attached to your account'),
|
|
140
|
+
level: 'info',
|
|
141
|
+
})
|
|
142
|
+
this.map.ui.closePanel()
|
|
143
|
+
},
|
|
144
|
+
context: this,
|
|
145
|
+
})
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
save: function () {
|
|
149
|
+
if (!this.isDirty) return this.map.continueSaving()
|
|
150
|
+
const formData = new FormData()
|
|
151
|
+
if (!this.isAnonymousMap() && this.options.editors) {
|
|
152
|
+
const editors = this.options.editors.map((u) => u.id)
|
|
153
|
+
for (let i = 0; i < this.options.editors.length; i++)
|
|
154
|
+
formData.append('editors', this.options.editors[i].id)
|
|
155
|
+
}
|
|
156
|
+
if (this.isOwner() || this.isAnonymousMap())
|
|
157
|
+
formData.append('edit_status', this.options.edit_status)
|
|
158
|
+
if (this.isOwner()) {
|
|
159
|
+
formData.append('owner', this.options.owner && this.options.owner.id)
|
|
160
|
+
formData.append('share_status', this.options.share_status)
|
|
161
|
+
}
|
|
162
|
+
this.map.post(this.getUrl(), {
|
|
163
|
+
data: formData,
|
|
164
|
+
context: this,
|
|
165
|
+
callback: function (data) {
|
|
166
|
+
this.commit()
|
|
167
|
+
this.isDirty = false
|
|
168
|
+
this.map.continueSaving()
|
|
169
|
+
this.map.fire('postsync')
|
|
170
|
+
},
|
|
171
|
+
})
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
getUrl: function () {
|
|
175
|
+
return L.Util.template(this.map.options.urls.map_update_permissions, {
|
|
176
|
+
map_id: this.map.options.umap_id,
|
|
177
|
+
})
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
getAttachUrl: function () {
|
|
181
|
+
return L.Util.template(this.map.options.urls.map_attach_owner, {
|
|
182
|
+
map_id: this.map.options.umap_id,
|
|
183
|
+
})
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
addOwnerLink: function (element, container) {
|
|
187
|
+
if (this.options.owner && this.options.owner.name && this.options.owner.url) {
|
|
188
|
+
const ownerContainer = L.DomUtil.add(
|
|
189
|
+
element,
|
|
190
|
+
'umap-map-owner',
|
|
191
|
+
container,
|
|
192
|
+
` ${L._('by')} `
|
|
193
|
+
)
|
|
194
|
+
L.DomUtil.createLink(
|
|
195
|
+
'',
|
|
196
|
+
ownerContainer,
|
|
197
|
+
this.options.owner.name,
|
|
198
|
+
this.options.owner.url
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
commit: function () {
|
|
204
|
+
L.Util.extend(this.map.options.permissions, this.options)
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
getShareStatusDisplay: function () {
|
|
208
|
+
return Object.fromEntries(this.map.options.share_statuses)[
|
|
209
|
+
this.options.share_status
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
})
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/* Shapes */
|
|
2
|
+
|
|
3
|
+
L.U.Popup = L.Popup.extend({
|
|
4
|
+
options: {
|
|
5
|
+
parseTemplate: true,
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
initialize: function (feature) {
|
|
9
|
+
this.feature = feature
|
|
10
|
+
this.container = L.DomUtil.create('div', 'umap-popup')
|
|
11
|
+
this.format()
|
|
12
|
+
L.Popup.prototype.initialize.call(this, {}, feature)
|
|
13
|
+
this.setContent(this.container)
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
format: function () {
|
|
17
|
+
const mode = this.feature.getOption('popupTemplate') || 'Default',
|
|
18
|
+
klass = L.U.PopupTemplate[mode] || L.U.PopupTemplate.Default
|
|
19
|
+
this.content = new klass(this.feature, this.container)
|
|
20
|
+
this.content.render()
|
|
21
|
+
const els = this.container.querySelectorAll('img,iframe')
|
|
22
|
+
for (let i = 0; i < els.length; i++) {
|
|
23
|
+
this.onElementLoaded(els[i])
|
|
24
|
+
}
|
|
25
|
+
if (!els.length && this.container.textContent.replace('\n', '') === '') {
|
|
26
|
+
this.container.innerHTML = ''
|
|
27
|
+
L.DomUtil.add('h3', '', this.container, this.feature.getDisplayName())
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
onElementLoaded: function (el) {
|
|
32
|
+
L.DomEvent.on(
|
|
33
|
+
el,
|
|
34
|
+
'load',
|
|
35
|
+
function () {
|
|
36
|
+
this._updateLayout()
|
|
37
|
+
this._updatePosition()
|
|
38
|
+
this._adjustPan()
|
|
39
|
+
},
|
|
40
|
+
this
|
|
41
|
+
)
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
L.U.Popup.Large = L.U.Popup.extend({
|
|
46
|
+
options: {
|
|
47
|
+
maxWidth: 500,
|
|
48
|
+
className: 'umap-popup-large',
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
L.U.Popup.Panel = L.U.Popup.extend({
|
|
53
|
+
options: {
|
|
54
|
+
zoomAnimation: false,
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
allButton: function () {
|
|
58
|
+
const button = L.DomUtil.create('li', '')
|
|
59
|
+
L.DomUtil.create('i', 'umap-icon-16 umap-list', button)
|
|
60
|
+
const label = L.DomUtil.create('span', '', button)
|
|
61
|
+
label.textContent = label.title = L._('See all')
|
|
62
|
+
L.DomEvent.on(button, 'click', this.feature.map.openBrowser, this.feature.map)
|
|
63
|
+
return button
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
onAdd: function (map) {
|
|
67
|
+
map.ui.openPanel({
|
|
68
|
+
data: { html: this._content },
|
|
69
|
+
actions: [this.allButton()],
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
// fire events as in base class Popup.js:onAdd
|
|
73
|
+
map.fire('popupopen', { popup: this })
|
|
74
|
+
if (this._source) {
|
|
75
|
+
this._source.fire('popupopen', { popup: this }, true)
|
|
76
|
+
if (!(this._source instanceof L.Path)) {
|
|
77
|
+
this._source.on('preclick', L.DomEvent.stopPropagation)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
onRemove: function (map) {
|
|
83
|
+
map.ui.closePanel()
|
|
84
|
+
|
|
85
|
+
// fire events as in base class Popup.js:onRemove
|
|
86
|
+
map.fire('popupclose', { popup: this })
|
|
87
|
+
if (this._source) {
|
|
88
|
+
this._source.fire('popupclose', { popup: this }, true)
|
|
89
|
+
if (!(this._source instanceof L.Path)) {
|
|
90
|
+
this._source.off('preclick', L.DomEvent.stopPropagation)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
update: function () {},
|
|
96
|
+
_updateLayout: function () {},
|
|
97
|
+
_updatePosition: function () {},
|
|
98
|
+
_adjustPan: function () {},
|
|
99
|
+
})
|
|
100
|
+
L.U.Popup.SimplePanel = L.U.Popup.Panel // Retrocompat.
|
|
101
|
+
|
|
102
|
+
/* Content templates */
|
|
103
|
+
|
|
104
|
+
L.U.PopupTemplate = {}
|
|
105
|
+
|
|
106
|
+
L.U.PopupTemplate.Default = L.Class.extend({
|
|
107
|
+
initialize: function (feature, container) {
|
|
108
|
+
this.feature = feature
|
|
109
|
+
this.container = container
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
renderTitle: function () {},
|
|
113
|
+
|
|
114
|
+
renderBody: function () {
|
|
115
|
+
const template = this.feature.getOption('popupContentTemplate')
|
|
116
|
+
const target = this.feature.getOption('outlinkTarget')
|
|
117
|
+
const container = L.DomUtil.create('div', 'umap-popup-container')
|
|
118
|
+
let content = ''
|
|
119
|
+
let properties
|
|
120
|
+
let center
|
|
121
|
+
properties = this.feature.extendedProperties()
|
|
122
|
+
// Resolve properties inside description
|
|
123
|
+
properties.description = L.Util.greedyTemplate(
|
|
124
|
+
this.feature.properties.description || '',
|
|
125
|
+
properties
|
|
126
|
+
)
|
|
127
|
+
content = L.Util.greedyTemplate(template, properties)
|
|
128
|
+
content = L.Util.toHTML(content, { target: target })
|
|
129
|
+
container.innerHTML = content
|
|
130
|
+
return container
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
renderFooter: function () {
|
|
134
|
+
if (this.feature.hasPopupFooter()) {
|
|
135
|
+
const footer = L.DomUtil.create('ul', 'umap-popup-footer', this.container),
|
|
136
|
+
previousLi = L.DomUtil.create('li', 'previous', footer),
|
|
137
|
+
zoomLi = L.DomUtil.create('li', 'zoom', footer),
|
|
138
|
+
nextLi = L.DomUtil.create('li', 'next', footer),
|
|
139
|
+
next = this.feature.getNext(),
|
|
140
|
+
prev = this.feature.getPrevious()
|
|
141
|
+
// Fixme: remove me when this is merged and released
|
|
142
|
+
// https://github.com/Leaflet/Leaflet/pull/9052
|
|
143
|
+
L.DomEvent.disableClickPropagation(footer)
|
|
144
|
+
if (next)
|
|
145
|
+
nextLi.title = L._('Go to «{feature}»', {
|
|
146
|
+
feature: next.properties.name || L._('next'),
|
|
147
|
+
})
|
|
148
|
+
if (prev)
|
|
149
|
+
previousLi.title = L._('Go to «{feature}»', {
|
|
150
|
+
feature: prev.properties.name || L._('previous'),
|
|
151
|
+
})
|
|
152
|
+
zoomLi.title = L._('Zoom to this feature')
|
|
153
|
+
L.DomEvent.on(nextLi, 'click', () => {
|
|
154
|
+
if (next) next.zoomTo({ callback: next.view })
|
|
155
|
+
})
|
|
156
|
+
L.DomEvent.on(previousLi, 'click', () => {
|
|
157
|
+
if (prev) prev.zoomTo({ callback: prev.view })
|
|
158
|
+
})
|
|
159
|
+
L.DomEvent.on(
|
|
160
|
+
zoomLi,
|
|
161
|
+
'click',
|
|
162
|
+
function () {
|
|
163
|
+
this.zoomTo()
|
|
164
|
+
},
|
|
165
|
+
this.feature
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
render: function () {
|
|
171
|
+
const title = this.renderTitle()
|
|
172
|
+
if (title) this.container.appendChild(title)
|
|
173
|
+
const body = this.renderBody()
|
|
174
|
+
if (body) L.DomUtil.add('div', 'umap-popup-content', this.container, body)
|
|
175
|
+
this.renderFooter()
|
|
176
|
+
},
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
L.U.PopupTemplate.BaseWithTitle = L.U.PopupTemplate.Default.extend({
|
|
180
|
+
renderTitle: function () {
|
|
181
|
+
let title
|
|
182
|
+
if (this.feature.getDisplayName()) {
|
|
183
|
+
title = L.DomUtil.create('h3', 'popup-title')
|
|
184
|
+
title.textContent = this.feature.getDisplayName()
|
|
185
|
+
}
|
|
186
|
+
return title
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
L.U.PopupTemplate.Table = L.U.PopupTemplate.BaseWithTitle.extend({
|
|
191
|
+
formatRow: function (key, value) {
|
|
192
|
+
if (value.indexOf('http') === 0) {
|
|
193
|
+
value = `<a href="${value}" target="_blank">${value}</a>`
|
|
194
|
+
}
|
|
195
|
+
return value
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
addRow: function (container, key, value) {
|
|
199
|
+
const tr = L.DomUtil.create('tr', '', container)
|
|
200
|
+
L.DomUtil.add('th', '', tr, key)
|
|
201
|
+
L.DomUtil.add('td', '', tr, this.formatRow(key, value))
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
renderBody: function () {
|
|
205
|
+
const table = L.DomUtil.create('table')
|
|
206
|
+
|
|
207
|
+
for (const key in this.feature.properties) {
|
|
208
|
+
if (typeof this.feature.properties[key] === 'object' || key === 'name') continue
|
|
209
|
+
// TODO, manage links (url, mailto, wikipedia...)
|
|
210
|
+
this.addRow(table, key, L.Util.escapeHTML(this.feature.properties[key]).trim())
|
|
211
|
+
}
|
|
212
|
+
return table
|
|
213
|
+
},
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
L.U.PopupTemplate.GeoRSSImage = L.U.PopupTemplate.BaseWithTitle.extend({
|
|
217
|
+
options: {
|
|
218
|
+
minWidth: 300,
|
|
219
|
+
maxWidth: 500,
|
|
220
|
+
className: 'umap-popup-large umap-georss-image',
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
renderBody: function () {
|
|
224
|
+
const container = L.DomUtil.create('a')
|
|
225
|
+
container.href = this.feature.properties.link
|
|
226
|
+
container.target = '_blank'
|
|
227
|
+
if (this.feature.properties.img) {
|
|
228
|
+
const img = L.DomUtil.create('img', '', container)
|
|
229
|
+
img.src = this.feature.properties.img
|
|
230
|
+
// Sadly, we are unable to override this from JS the clean way
|
|
231
|
+
// See https://github.com/Leaflet/Leaflet/commit/61d746818b99d362108545c151a27f09d60960ee#commitcomment-6061847
|
|
232
|
+
img.style.maxWidth = `${this.options.maxWidth}px`
|
|
233
|
+
img.style.maxHeight = `${this.options.maxWidth}px`
|
|
234
|
+
this.onElementLoaded(img)
|
|
235
|
+
}
|
|
236
|
+
return container
|
|
237
|
+
},
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
L.U.PopupTemplate.GeoRSSLink = L.U.PopupTemplate.Default.extend({
|
|
241
|
+
options: {
|
|
242
|
+
className: 'umap-georss-link',
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
renderBody: function () {
|
|
246
|
+
const title = this.renderTitle(this),
|
|
247
|
+
a = L.DomUtil.add('a')
|
|
248
|
+
a.href = this.feature.properties.link
|
|
249
|
+
a.target = '_blank'
|
|
250
|
+
a.appendChild(title)
|
|
251
|
+
return a
|
|
252
|
+
},
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
L.U.PopupTemplate.OSM = L.U.PopupTemplate.Default.extend({
|
|
256
|
+
options: {
|
|
257
|
+
className: 'umap-openstreetmap',
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
getName: function () {
|
|
261
|
+
const props = this.feature.properties
|
|
262
|
+
if (L.locale && props[`name:${L.locale}`]) return props[`name:${L.locale}`]
|
|
263
|
+
return props.name
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
renderBody: function () {
|
|
267
|
+
const props = this.feature.properties
|
|
268
|
+
const container = L.DomUtil.add('div')
|
|
269
|
+
const title = L.DomUtil.add('h3', 'popup-title', container)
|
|
270
|
+
const color = this.feature.getDynamicOption('color')
|
|
271
|
+
title.style.backgroundColor = color
|
|
272
|
+
const iconUrl = this.feature.getDynamicOption('iconUrl')
|
|
273
|
+
let icon = L.U.Icon.makeIconElement(iconUrl, title)
|
|
274
|
+
L.DomUtil.addClass(icon, 'icon')
|
|
275
|
+
L.U.Icon.setIconContrast(icon, title, iconUrl, color)
|
|
276
|
+
if (L.DomUtil.contrastedColor(title, color)) title.style.color = 'white'
|
|
277
|
+
L.DomUtil.add('span', '', title, this.getName())
|
|
278
|
+
const street = props['addr:street']
|
|
279
|
+
if (street) {
|
|
280
|
+
const row = L.DomUtil.add('address', 'address', container)
|
|
281
|
+
const number = props['addr:housenumber']
|
|
282
|
+
if (number) {
|
|
283
|
+
// Poor way to deal with international forms of writting addresses
|
|
284
|
+
L.DomUtil.add('span', '', row, `${L._('No.')}: ${number}`)
|
|
285
|
+
L.DomUtil.add('span', '', row, `${L._('Street')}: ${street}`)
|
|
286
|
+
} else {
|
|
287
|
+
L.DomUtil.add('span', '', row, street)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (props.website) {
|
|
291
|
+
L.DomUtil.element(
|
|
292
|
+
'a',
|
|
293
|
+
{ href: props.website, textContent: props.website },
|
|
294
|
+
container
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
const phone = props.phone || props['contact:phone']
|
|
298
|
+
if (phone) {
|
|
299
|
+
L.DomUtil.add(
|
|
300
|
+
'div',
|
|
301
|
+
'',
|
|
302
|
+
container,
|
|
303
|
+
L.DomUtil.element('a', { href: `tel:${phone}`, textContent: phone })
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
if (props.mobile) {
|
|
307
|
+
L.DomUtil.add(
|
|
308
|
+
'div',
|
|
309
|
+
'',
|
|
310
|
+
container,
|
|
311
|
+
L.DomUtil.element('a', {
|
|
312
|
+
href: `tel:${props.mobile}`,
|
|
313
|
+
textContent: props.mobile,
|
|
314
|
+
})
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
const email = props.email || props['contact:email']
|
|
318
|
+
if (email) {
|
|
319
|
+
L.DomUtil.add(
|
|
320
|
+
'div',
|
|
321
|
+
'',
|
|
322
|
+
container,
|
|
323
|
+
L.DomUtil.element('a', { href: `mailto:${email}`, textContent: email })
|
|
324
|
+
)
|
|
325
|
+
}
|
|
326
|
+
const id = props['@id']
|
|
327
|
+
if (id) {
|
|
328
|
+
L.DomUtil.add(
|
|
329
|
+
'div',
|
|
330
|
+
'osm-link',
|
|
331
|
+
container,
|
|
332
|
+
L.DomUtil.element('a', {
|
|
333
|
+
href: `https://www.openstreetmap.org/${id}`,
|
|
334
|
+
textContent: L._('See on OpenStreetMap'),
|
|
335
|
+
})
|
|
336
|
+
)
|
|
337
|
+
}
|
|
338
|
+
return container
|
|
339
|
+
},
|
|
340
|
+
})
|