@teipublisher/pb-components 1.32.1 → 1.34.0
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.
- package/CHANGELOG.md +41 -0
- package/dist/demo/demos.json +4 -1
- package/dist/demo/pb-timeline.html +122 -0
- package/dist/demo/pb-timeline2.html +94 -0
- package/dist/demo/timeline-dev-data.json +3 -0
- package/dist/pb-components-bundle.js +508 -252
- package/dist/pb-elements.json +301 -3
- package/dist/pb-leaflet-map.js +2 -2
- package/i18n/common/de.json +4 -0
- package/i18n/common/en.json +4 -0
- package/package.json +1 -1
- package/pb-elements.json +301 -3
- package/src/parse-date-service.js +266 -0
- package/src/pb-browse-docs.js +24 -8
- package/src/pb-components.js +1 -0
- package/src/pb-leaflet-map.js +44 -11
- package/src/pb-load.js +17 -6
- package/src/pb-timeline.js +741 -0
- package/src/pb-view.js +59 -10
- package/src/search-result-service.js +521 -0
package/src/pb-browse-docs.js
CHANGED
|
@@ -87,6 +87,13 @@ export class PbBrowseDocs extends PbLoad {
|
|
|
87
87
|
subforms: {
|
|
88
88
|
type: String
|
|
89
89
|
},
|
|
90
|
+
/**
|
|
91
|
+
* If set, rewrite URLs to load pages as static HTML files,
|
|
92
|
+
* so no TEI Publisher instance is required
|
|
93
|
+
*/
|
|
94
|
+
static: {
|
|
95
|
+
type: Boolean
|
|
96
|
+
},
|
|
90
97
|
_file: {
|
|
91
98
|
type: String
|
|
92
99
|
},
|
|
@@ -120,6 +127,8 @@ export class PbBrowseDocs extends PbLoad {
|
|
|
120
127
|
this.filterBy = 'title';
|
|
121
128
|
this._allowModification = false;
|
|
122
129
|
this._suggestions = [];
|
|
130
|
+
|
|
131
|
+
this.static = false;
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
connectedCallback() {
|
|
@@ -177,14 +186,16 @@ export class PbBrowseDocs extends PbLoad {
|
|
|
177
186
|
});
|
|
178
187
|
this.shadowRoot.getElementById('autocomplete').addEventListener('autocomplete-change', this._autocomplete.bind(this));
|
|
179
188
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
this.
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
if (this.login) {
|
|
190
|
+
const login = document.getElementById(this.login);
|
|
191
|
+
if (!login) {
|
|
192
|
+
console.error('<pb-browse-docs> connected pb-login element not found!');
|
|
193
|
+
} else {
|
|
194
|
+
this.subscribeTo('pb-login', (ev) => {
|
|
195
|
+
this._allowModification = this._loggedIn(ev.detail.user, ev.detail.group);
|
|
196
|
+
}, []);
|
|
197
|
+
this._allowModification = login.loggedIn && this._loggedIn(login.user, login.groups);
|
|
198
|
+
}
|
|
188
199
|
}
|
|
189
200
|
|
|
190
201
|
this.shadowRoot.getElementById('sort-list').addEventListener('selected-item-changed', this._sort.bind(this));
|
|
@@ -206,6 +217,7 @@ export class PbBrowseDocs extends PbLoad {
|
|
|
206
217
|
}
|
|
207
218
|
</style>
|
|
208
219
|
</custom-style>
|
|
220
|
+
<slot name="header"></slot>
|
|
209
221
|
<div class="toolbar">
|
|
210
222
|
<paper-dropdown-menu id="sort" label="${translate(this.sortLabel)}" part="sort-dropdown">
|
|
211
223
|
<paper-listbox id="sort-list" selected="${this.sortBy}" slot="dropdown-content" class="dropdown-content" attr-for-selected="value">
|
|
@@ -312,6 +324,10 @@ export class PbBrowseDocs extends PbLoad {
|
|
|
312
324
|
}
|
|
313
325
|
|
|
314
326
|
getURL(params) {
|
|
327
|
+
if (this.static) {
|
|
328
|
+
// use a static URL
|
|
329
|
+
return `collections/${this.collection}/${params.start || '1'}.html`;
|
|
330
|
+
}
|
|
315
331
|
const url = super.getURL(params);
|
|
316
332
|
return this.collection ? `${url}/${this.collection}` : url;
|
|
317
333
|
}
|
package/src/pb-components.js
CHANGED
|
@@ -58,6 +58,7 @@ import './pb-blacklab-results.js';
|
|
|
58
58
|
import './pb-blacklab-highlight.js';
|
|
59
59
|
import './pb-table-grid.js';
|
|
60
60
|
import './pb-split-list.js';
|
|
61
|
+
import './pb-timeline.js';
|
|
61
62
|
|
|
62
63
|
import '@polymer/iron-icons/editor-icons';
|
|
63
64
|
import '@polymer/iron-icons/social-icons';
|
package/src/pb-leaflet-map.js
CHANGED
|
@@ -9,9 +9,22 @@ import './pb-map-layer.js';
|
|
|
9
9
|
*
|
|
10
10
|
* @slot - may contain a series of `pb-map-layer` configurations
|
|
11
11
|
* @fires pb-leaflet-marker-click - Fires event to be processed by the map upon click
|
|
12
|
-
* @fires pb-update-map - When received, redraws the map to fit markers passed in with the event
|
|
13
|
-
*
|
|
14
|
-
* @fires pb-
|
|
12
|
+
* @fires pb-update-map - When received, redraws the map to fit markers passed in with the event.
|
|
13
|
+
* Event details should include an array of locations, see `pb-geolocation` event below.
|
|
14
|
+
* @fires pb-update - When received, redraws the map to show markers for all pb-geolocation elements found in the content of the pb-view
|
|
15
|
+
* @fires pb-geolocation - When received, focuses the map on the geocoordinates passed in with the event.
|
|
16
|
+
* The event details should include an object:
|
|
17
|
+
* ```
|
|
18
|
+
* {
|
|
19
|
+
* coordinates: {
|
|
20
|
+
* latitude: Number,
|
|
21
|
+
* longitude: Number
|
|
22
|
+
* },
|
|
23
|
+
* label: string - the label to show on mouseover,
|
|
24
|
+
* zoom: Number - fixed zoom level to zoom to,
|
|
25
|
+
* fitBounds: Boolean - if true, recompute current zoom level to show all markers
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
15
28
|
*/
|
|
16
29
|
export class PbLeafletMap extends pbMixin(LitElement) {
|
|
17
30
|
static get properties() {
|
|
@@ -43,6 +56,16 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
43
56
|
cluster: {
|
|
44
57
|
type: Boolean
|
|
45
58
|
},
|
|
59
|
+
/**
|
|
60
|
+
* Limits up to which zoom level markers are arranged into clusters.
|
|
61
|
+
* Using a higher zoom level here will result in more markers to be shown.
|
|
62
|
+
*
|
|
63
|
+
* Requires `cluster` option to be enabled.
|
|
64
|
+
*/
|
|
65
|
+
disableClusteringAt: {
|
|
66
|
+
type: Number,
|
|
67
|
+
attribute: 'disable-clustering-at'
|
|
68
|
+
},
|
|
46
69
|
/**
|
|
47
70
|
* If enabled, the map will not automatically scroll to the coordinates received via `pb-geolocation`
|
|
48
71
|
*/
|
|
@@ -89,6 +112,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
89
112
|
this.disabled = true;
|
|
90
113
|
this.cluster = false;
|
|
91
114
|
this.fitMarkers = false;
|
|
115
|
+
this.disableClusteringAt = null;
|
|
92
116
|
}
|
|
93
117
|
|
|
94
118
|
connectedCallback() {
|
|
@@ -159,9 +183,6 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
159
183
|
if (ev.detail.coordinates) {
|
|
160
184
|
this.latitude = ev.detail.coordinates.latitude;
|
|
161
185
|
this.longitude = ev.detail.coordinates.longitude;
|
|
162
|
-
if (ev.detail.zoom) {
|
|
163
|
-
this.zoom = ev.detail.zoom;
|
|
164
|
-
}
|
|
165
186
|
if (!this._hasMarker(this.latitude, this.longitude)) {
|
|
166
187
|
const marker = L.marker([this.latitude, this.longitude]);
|
|
167
188
|
marker.addEventListener('click', () => {
|
|
@@ -186,7 +207,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
186
207
|
if (this.toggle) {
|
|
187
208
|
this.disabled = false;
|
|
188
209
|
}
|
|
189
|
-
this._locationChanged(this.latitude, this.longitude,
|
|
210
|
+
this._locationChanged(this.latitude, this.longitude, ev.detail.zoom);
|
|
190
211
|
}
|
|
191
212
|
});
|
|
192
213
|
}
|
|
@@ -255,7 +276,11 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
255
276
|
this._configureLayers();
|
|
256
277
|
|
|
257
278
|
if (this.cluster) {
|
|
258
|
-
|
|
279
|
+
const options = {};
|
|
280
|
+
if (this.disableClusteringAt) {
|
|
281
|
+
options.disableClusteringAtZoom = this.disableClusteringAt;
|
|
282
|
+
}
|
|
283
|
+
this._markerLayer = L.markerClusterGroup(options);
|
|
259
284
|
} else {
|
|
260
285
|
this._markerLayer = L.layerGroup();
|
|
261
286
|
}
|
|
@@ -359,11 +384,19 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
359
384
|
const coords = L.latLng([lat, long]);
|
|
360
385
|
this._markerLayer.eachLayer((layer) => {
|
|
361
386
|
if (layer.getLatLng().equals(coords)) {
|
|
362
|
-
|
|
387
|
+
if (zoom && !this.noScroll) {
|
|
388
|
+
layer.openTooltip();
|
|
389
|
+
this._map.setView(coords, zoom);
|
|
390
|
+
} else if (this.cluster) {
|
|
391
|
+
this._markerLayer.zoomToShowLayer(layer, () =>
|
|
392
|
+
layer.openTooltip()
|
|
393
|
+
);
|
|
394
|
+
} else {
|
|
395
|
+
layer.openTooltip();
|
|
396
|
+
this._map.setView(coords, this.zoom);
|
|
397
|
+
}
|
|
363
398
|
}
|
|
364
399
|
});
|
|
365
|
-
if (!this.noScroll)
|
|
366
|
-
this._map.setView(coords, zoom);
|
|
367
400
|
}
|
|
368
401
|
}
|
|
369
402
|
|
package/src/pb-load.js
CHANGED
|
@@ -288,13 +288,12 @@ export class PbLoad extends pbMixin(LitElement) {
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
_handleContent(ev) {
|
|
291
|
-
this._parseHeaders(ev.detail.xhr);
|
|
292
|
-
|
|
293
291
|
const resp = this.shadowRoot.getElementById('loadContent').lastResponse;
|
|
294
292
|
if (this.container) {
|
|
295
293
|
this.style.display = 'none';
|
|
296
294
|
document.querySelectorAll(this.container).forEach((elem) => {
|
|
297
|
-
elem.innerHTML = resp
|
|
295
|
+
elem.innerHTML = resp;
|
|
296
|
+
this._parseHeaders(ev.detail.xhr, elem);
|
|
298
297
|
this._fixLinks(elem);
|
|
299
298
|
this._onLoad(elem);
|
|
300
299
|
});
|
|
@@ -304,6 +303,7 @@ export class PbLoad extends pbMixin(LitElement) {
|
|
|
304
303
|
|
|
305
304
|
const div = document.createElement('div');
|
|
306
305
|
div.innerHTML = resp;
|
|
306
|
+
this._parseHeaders(ev.detail.xhr, div);
|
|
307
307
|
div.slot = '';
|
|
308
308
|
this.appendChild(div);
|
|
309
309
|
this._fixLinks(div);
|
|
@@ -338,9 +338,20 @@ export class PbLoad extends pbMixin(LitElement) {
|
|
|
338
338
|
dialog.open();
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
_parseHeaders(xhr) {
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
_parseHeaders(xhr, content) {
|
|
342
|
+
// Try to determine number of pages and current position
|
|
343
|
+
// Search for data-pagination-* attributes first and if they
|
|
344
|
+
// can't be found, check HTTP headers
|
|
345
|
+
function getPaginationParam(type) {
|
|
346
|
+
const elem = content.querySelector(`[data-pagination-${type}]`);
|
|
347
|
+
if (elem) {
|
|
348
|
+
return elem.getAttribute(`data-pagination-${type}`);
|
|
349
|
+
}
|
|
350
|
+
return xhr.getResponseHeader(`pb-${type}`);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const total = getPaginationParam('total');
|
|
354
|
+
const start = getPaginationParam('start');
|
|
344
355
|
|
|
345
356
|
if (this.start !== start) {
|
|
346
357
|
this.start = parseInt(start);
|