@teipublisher/pb-components 2.26.1-next.3 → 3.0.0-next-4.1
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/.github/workflows/docker-cypress.yml +54 -0
- package/.github/workflows/main.yml +6 -4
- package/.github/workflows/node.js.yml +56 -21
- package/.github/workflows/release.js.yml +19 -17
- package/.releaserc.json +1 -1
- package/CHANGELOG.md +346 -11
- package/Dockerfile +78 -70
- package/README.md +112 -4
- package/css/components.css +5 -5
- package/css/gridjs/mermaid.min.css +1 -1
- package/css/leaflet/Control.Geocoder.css +1 -126
- package/css/leaflet/images/layers.png +0 -0
- package/css/tify/tify.css +6 -5
- package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
- package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css.map +1 -0
- package/css/tom-select/tom-select.min.css +1 -1
- package/cypress.config.js +84 -0
- package/dist/api.html +1 -1
- package/dist/css/design-system.css +607 -0
- package/dist/demo/bundle-test.html +4 -3
- package/dist/demo/components.css +46 -1
- package/dist/demo/design-system.html +710 -0
- package/dist/demo/dts-client.html +2 -2
- package/dist/demo/pb-autocomplete.html +23 -11
- package/dist/demo/pb-autocomplete2.html +66 -55
- package/dist/demo/pb-autocomplete3.html +17 -8
- package/dist/demo/pb-blacklab-highlight.html +28 -11
- package/dist/demo/pb-blacklab-results.html +3 -2
- package/dist/demo/pb-browse-docs.html +24 -24
- package/dist/demo/pb-browse-docs2.html +3 -3
- package/dist/demo/pb-clipboard.html +32 -28
- package/dist/demo/pb-code-editor.html +6 -6
- package/dist/demo/pb-code-highlight.html +63 -63
- package/dist/demo/pb-codepen.html +1 -1
- package/dist/demo/pb-collapse.html +1 -1
- package/dist/demo/pb-collapse2.html +2 -2
- package/dist/demo/pb-combo-box.html +135 -130
- package/dist/demo/pb-custom-form.html +64 -55
- package/dist/demo/pb-dialog.html +12 -6
- package/dist/demo/pb-document.html +1 -1
- package/dist/demo/pb-download.html +68 -59
- package/dist/demo/pb-drawer.html +67 -46
- package/dist/demo/pb-drawer2.html +65 -58
- package/dist/demo/pb-edit-app.html +2 -2
- package/dist/demo/pb-edit-xml.html +1 -1
- package/dist/demo/pb-facsimile-2.html +26 -11
- package/dist/demo/pb-facsimile-3.html +25 -10
- package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
- package/dist/demo/pb-facsimile-dedup-test.html +48 -0
- package/dist/demo/pb-facsimile.html +4 -4
- package/dist/demo/pb-formula.html +1 -1
- package/dist/demo/pb-grid.html +22 -8
- package/dist/demo/pb-highlight.html +2 -2
- package/dist/demo/pb-i18n-simple.html +1 -0
- package/dist/demo/pb-i18n.html +15 -5
- package/dist/demo/pb-image-strip-standalone.html +2 -2
- package/dist/demo/pb-image-strip-view.html +2 -2
- package/dist/demo/pb-leaflet-map.html +3 -3
- package/dist/demo/pb-leaflet-map2.html +2 -2
- package/dist/demo/pb-leaflet-map3.html +3 -3
- package/dist/demo/pb-link.html +1 -1
- package/dist/demo/pb-load.html +2 -6
- package/dist/demo/pb-login.html +1 -3
- package/dist/demo/pb-manage-odds.html +9 -4
- package/dist/demo/pb-markdown.html +1 -1
- package/dist/demo/pb-media-query.html +2 -2
- package/dist/demo/pb-mei.html +2 -2
- package/dist/demo/pb-mei2.html +2 -2
- package/dist/demo/pb-message.html +2 -3
- package/dist/demo/pb-odd-editor.html +54 -52
- package/dist/demo/pb-page-header.html +27 -0
- package/dist/demo/pb-popover.html +1 -1
- package/dist/demo/pb-print-preview.html +2 -2
- package/dist/demo/pb-progress.html +4 -4
- package/dist/demo/pb-repeat.html +32 -36
- package/dist/demo/pb-search.html +16 -5
- package/dist/demo/pb-search2.html +4 -4
- package/dist/demo/pb-search3.html +3 -3
- package/dist/demo/pb-search4.html +3 -3
- package/dist/demo/pb-select-feature.html +4 -4
- package/dist/demo/pb-select-feature2.html +4 -4
- package/dist/demo/pb-select-feature3.html +2 -2
- package/dist/demo/pb-select-i18n.html +58 -53
- package/dist/demo/pb-select-odd.html +1 -1
- package/dist/demo/pb-select.html +190 -75
- package/dist/demo/pb-select2.html +91 -37
- package/dist/demo/pb-select3.html +109 -41
- package/dist/demo/pb-svg.html +1 -1
- package/dist/demo/pb-table-grid.html +26 -15
- package/dist/demo/pb-tabs.html +15 -7
- package/dist/demo/pb-tify.html +7 -7
- package/dist/demo/pb-timeline.html +1 -1
- package/dist/demo/pb-timeline2.html +1 -1
- package/dist/demo/pb-toggle-feature.html +26 -23
- package/dist/demo/pb-toggle-feature2.html +4 -4
- package/dist/demo/pb-toggle-feature3.html +2 -2
- package/dist/demo/pb-toggle-feature4.html +56 -54
- package/dist/demo/pb-version.html +2 -2
- package/dist/demo/pb-view.html +78 -40
- package/dist/demo/pb-view2.html +69 -46
- package/dist/demo/pb-view3.html +53 -48
- package/dist/demo/pb-view4.html +70 -49
- package/dist/demo/pb-zoom.html +2 -2
- package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
- package/dist/focus-mixin-VCsFap6b.js +768 -0
- package/dist/images/icons.svg +217 -0
- package/dist/jinn-codemirror-DETLdm08.js +1 -0
- package/dist/lib/openseadragon.min.js +80 -0
- package/dist/lib/openseadragon.min.js.map +1 -0
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +414 -3225
- package/dist/pb-components-bundle.js +3046 -4402
- package/dist/pb-dialog-tklYGWfc.js +121 -0
- package/dist/pb-edit-app.js +208 -107
- package/dist/pb-elements.json +716 -249
- package/dist/pb-facsimile.js +46 -0
- package/dist/pb-i18n-C0NDma4h.js +1 -0
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +152 -134
- package/dist/pb-mixin-DHoWQheB.js +1 -0
- package/dist/pb-odd-editor.js +1671 -1231
- package/dist/pb-tify.js +1 -27
- package/dist/unsafe-html-D5VGo9Oq.js +1 -0
- package/dist/urls-BEONu_g4.js +1 -0
- package/eslint.config.mjs +92 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/images/icons.svg +217 -0
- package/index.html +0 -5
- package/lib/leaflet-src.js.map +1 -0
- package/lib/leaflet.markercluster-src.js.map +1 -0
- package/lib/openseadragon.min.js +6 -6
- package/package.json +56 -81
- package/pb-elements.json +716 -249
- package/rollup.config.mjs +312 -0
- package/src/assets/components.css +5 -5
- package/src/assets/design-system.css +607 -0
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +70 -27
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +50 -42
- package/src/authority/kbga.js +136 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -68
- package/src/authority/registry.js +4 -4
- package/src/docs/demo-utils.js +91 -0
- package/src/docs/pb-component-docs.js +287 -147
- package/src/docs/pb-component-view.js +380 -273
- package/src/docs/pb-components-list.js +115 -51
- package/src/docs/pb-demo-snippet.js +199 -174
- package/src/dts-client.js +306 -303
- package/src/dts-select-endpoint.js +125 -85
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +175 -173
- package/src/pb-authority-lookup.js +198 -158
- package/src/pb-autocomplete.js +731 -313
- package/src/pb-blacklab-highlight.js +266 -260
- package/src/pb-blacklab-results.js +230 -225
- package/src/pb-browse-docs.js +601 -484
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +97 -76
- package/src/pb-code-editor.js +111 -103
- package/src/pb-code-highlight.js +234 -204
- package/src/pb-codepen.js +81 -73
- package/src/pb-collapse.js +265 -152
- package/src/pb-combo-box.js +191 -191
- package/src/pb-components-bundle.js +1 -7
- package/src/pb-components.js +2 -6
- package/src/pb-custom-form.js +230 -141
- package/src/pb-dialog.js +99 -63
- package/src/pb-document.js +118 -91
- package/src/pb-download.js +214 -198
- package/src/pb-drawer.js +146 -149
- package/src/pb-edit-app.js +471 -240
- package/src/pb-edit-xml.js +101 -98
- package/src/pb-events.js +126 -107
- package/src/pb-facs-link.js +130 -101
- package/src/pb-facsimile.js +494 -410
- package/src/pb-fetch.js +389 -0
- package/src/pb-formula.js +152 -154
- package/src/pb-geolocation.js +130 -132
- package/src/pb-grid-action.js +59 -56
- package/src/pb-grid.js +388 -228
- package/src/pb-highlight.js +142 -142
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +115 -127
- package/src/pb-icon-button.js +108 -0
- package/src/pb-icon.js +283 -0
- package/src/pb-image-strip.js +85 -79
- package/src/pb-lang.js +142 -57
- package/src/pb-leaflet-map.js +551 -483
- package/src/pb-link.js +132 -126
- package/src/pb-load.js +495 -428
- package/src/pb-login.js +303 -248
- package/src/pb-manage-odds.js +384 -338
- package/src/pb-map-icon.js +90 -90
- package/src/pb-map-layer.js +86 -86
- package/src/pb-markdown.js +107 -110
- package/src/pb-media-query.js +75 -73
- package/src/pb-mei.js +523 -303
- package/src/pb-message.js +144 -98
- package/src/pb-mixin.js +268 -265
- package/src/pb-navigation.js +83 -96
- package/src/pb-observable.js +39 -39
- package/src/pb-odd-editor.js +1209 -948
- package/src/pb-odd-elementspec-editor.js +375 -310
- package/src/pb-odd-model-editor.js +1189 -941
- package/src/pb-odd-parameter-editor.js +269 -170
- package/src/pb-odd-rendition-editor.js +184 -131
- package/src/pb-page.js +451 -422
- package/src/pb-paginate.js +260 -178
- package/src/pb-panel.js +217 -183
- package/src/pb-popover-themes.js +16 -9
- package/src/pb-popover.js +297 -288
- package/src/pb-print-preview.js +128 -128
- package/src/pb-progress.js +52 -52
- package/src/pb-repeat.js +141 -108
- package/src/pb-restricted.js +85 -78
- package/src/pb-search.js +258 -230
- package/src/pb-select-feature.js +210 -126
- package/src/pb-select-odd.js +184 -118
- package/src/pb-select-template.js +113 -78
- package/src/pb-select.js +330 -229
- package/src/pb-split-list.js +181 -176
- package/src/pb-svg.js +81 -80
- package/src/pb-table-column.js +55 -55
- package/src/pb-table-grid.js +334 -205
- package/src/pb-tabs.js +238 -61
- package/src/pb-tify.js +3331 -126
- package/src/pb-timeline.js +394 -255
- package/src/pb-toggle-feature.js +196 -188
- package/src/pb-upload.js +201 -176
- package/src/pb-version.js +22 -34
- package/src/pb-view-annotate.js +138 -102
- package/src/pb-view.js +1722 -1272
- package/src/pb-zoom.js +144 -46
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +14 -22
- package/src/settings.js +4 -4
- package/src/theming.js +98 -91
- package/src/urls.js +403 -289
- package/src/utils.js +53 -51
- package/vite.config.js +86 -0
- package/css/pb-styles.css +0 -51
- package/dist/iron-form-3b8dcaa7.js +0 -210
- package/dist/jinn-codemirror-da0e2d1f.js +0 -1
- package/dist/paper-checkbox-515a5284.js +0 -1597
- package/dist/paper-icon-button-b1d31571.js +0 -398
- package/dist/paper-listbox-a3b7175c.js +0 -1265
- package/dist/pb-i18n-0611135a.js +0 -1
- package/dist/pb-mixin-b1caa22e.js +0 -158
- package/dist/polymer-hack.js +0 -1
- package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
- package/lib/Control.Geocoder.min.js +0 -2
- package/lib/Control.Geocoder.min.js.map +0 -1
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -41
- package/src/polymer-hack.js +0 -6
package/src/pb-load.js
CHANGED
|
@@ -1,480 +1,547 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
|
-
import { translate } from
|
|
4
|
-
import { typesetMath } from
|
|
5
|
-
import { registry } from
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
3
|
+
import { translate } from './pb-i18n.js';
|
|
4
|
+
import { typesetMath } from './pb-formula.js';
|
|
5
|
+
import { registry } from './urls.js';
|
|
6
|
+
import './pb-fetch.js';
|
|
7
|
+
import './pb-dialog.js';
|
|
8
|
+
import { themableMixin } from './theming.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Dynamically load data by calling a server-side script, optionally triggered by an event.
|
|
12
12
|
* This is used for e.g. the document list on the start page or the table
|
|
13
13
|
* of contents.
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* @slot - default unnamed slot for content
|
|
16
16
|
* @fires pb-start-update - Fired before the element updates its content
|
|
17
17
|
* @fires pb-end-update - Fired after the element has finished updating its content
|
|
18
18
|
* @fires pb-results-received - Fired when the component received content from the server
|
|
19
19
|
* @fires pb-toggle - When received, changes the state of the feature
|
|
20
20
|
*/
|
|
21
|
-
export class PbLoad extends pbMixin(LitElement) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
21
|
+
export class PbLoad extends themableMixin(pbMixin(LitElement)) {
|
|
22
|
+
static get properties() {
|
|
23
|
+
return {
|
|
24
|
+
...super.properties,
|
|
25
|
+
/** The URL for the AJAX request. If a relative URL is passed, it will be resolved
|
|
26
|
+
* against the current API endpoint.
|
|
27
|
+
*/
|
|
28
|
+
url: {
|
|
29
|
+
type: String,
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* If set to true, the `url` property will be interpreted as a template string
|
|
33
|
+
* containing placeholders for parameters in `{parameter-name}`. The placeholders
|
|
34
|
+
* will be replaced by the actual parameters when building the final URL. Each parameter
|
|
35
|
+
* used in the URL template will be removed from the request parameter list.
|
|
36
|
+
*/
|
|
37
|
+
expand: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
},
|
|
40
|
+
/** ID of the pb-document this element is connected to. The document path to
|
|
41
|
+
* load will be taken from the pb-document.
|
|
42
|
+
*/
|
|
43
|
+
src: {
|
|
44
|
+
type: String,
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* The container element into which the results returned by
|
|
48
|
+
* the AJAX request will be loaded.
|
|
49
|
+
*/
|
|
50
|
+
container: {
|
|
51
|
+
type: String,
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Should content be loaded immediately when the component is initialized?
|
|
55
|
+
*/
|
|
56
|
+
auto: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Only load content once, not every time a `pb-load` event is received.
|
|
61
|
+
*/
|
|
62
|
+
loadOnce: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* If set, relative links (img, a) will be made absolute.
|
|
67
|
+
*/
|
|
68
|
+
fixLinks: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
attribute: 'fix-links',
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* Start offset to use for showing paginated content.
|
|
74
|
+
*/
|
|
75
|
+
start: {
|
|
76
|
+
type: Number,
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* If set, a parameter "language" will be added to the parameter list.
|
|
80
|
+
* Also, a refresh will be triggered if a `pb-i18n-update` event is received,
|
|
81
|
+
* e.g. due to the user selecting a different interface language.
|
|
82
|
+
*
|
|
83
|
+
* Also requires `requireLanguage` to be set on the surrounding `pb-page`.
|
|
84
|
+
* See there for more information.
|
|
85
|
+
*/
|
|
86
|
+
useLanguage: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
attribute: 'use-language',
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Indicates whether or not cross-site Access-Control requests should be made.
|
|
92
|
+
* Default is false.
|
|
93
|
+
*/
|
|
94
|
+
noCredentials: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
attribute: 'no-credentials',
|
|
97
|
+
},
|
|
98
|
+
/**
|
|
99
|
+
* Indicates if the parameters of the request made should be saved to the browser
|
|
100
|
+
* history and URL. Default: false.
|
|
101
|
+
*/
|
|
102
|
+
history: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* The event which will trigger a new request to be sent. Default is 'pb-load'.
|
|
107
|
+
*/
|
|
108
|
+
event: {
|
|
109
|
+
type: String,
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* Additional, user-defined parameters to be sent with the request.
|
|
113
|
+
*/
|
|
114
|
+
userParams: {
|
|
115
|
+
type: Object,
|
|
116
|
+
},
|
|
117
|
+
/**
|
|
118
|
+
* If set, silently ignore errors when sending the request.
|
|
119
|
+
*/
|
|
120
|
+
silent: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Do not add internal parameters like 'start' or 'language' to the URL
|
|
125
|
+
* but leave it untouched.
|
|
126
|
+
*/
|
|
127
|
+
plain: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
constructor() {
|
|
134
|
+
super();
|
|
135
|
+
this.auto = false;
|
|
136
|
+
this.loadOnce = false;
|
|
137
|
+
this.history = false;
|
|
138
|
+
this.event = 'pb-load';
|
|
139
|
+
this.loaded = false;
|
|
140
|
+
this.language = null;
|
|
141
|
+
this.noCredentials = false;
|
|
142
|
+
this.silent = false;
|
|
143
|
+
this._retryCount = 0;
|
|
144
|
+
this._maxRetries = 20; // Maximum retries for document resolution
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
connectedCallback() {
|
|
148
|
+
super.connectedCallback();
|
|
149
|
+
this.subscribeTo(this.event, ev => {
|
|
150
|
+
waitOnce('pb-page-ready', () => {
|
|
151
|
+
if (this.history) {
|
|
152
|
+
if (ev.detail && ev.detail.params) {
|
|
153
|
+
const { start } = ev.detail.params;
|
|
154
|
+
if (start) {
|
|
155
|
+
registry.commit(this, { start });
|
|
130
156
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.loadOnce = false;
|
|
138
|
-
this.history = false;
|
|
139
|
-
this.event = 'pb-load';
|
|
140
|
-
this.loaded = false;
|
|
141
|
-
this.language = null;
|
|
142
|
-
this.noCredentials = false;
|
|
143
|
-
this.silent = false;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
connectedCallback() {
|
|
147
|
-
super.connectedCallback();
|
|
148
|
-
this.subscribeTo(this.event, (ev) => {
|
|
149
|
-
waitOnce('pb-page-ready', () => {
|
|
150
|
-
if (this.history) {
|
|
151
|
-
if (ev.detail && ev.detail.params) {
|
|
152
|
-
const start = ev.detail.params.start;
|
|
153
|
-
if (start) {
|
|
154
|
-
registry.commit(this, { start });
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
this.userParams = registry.state;
|
|
158
|
-
registry.subscribe(this, (state) => {
|
|
159
|
-
if (state.start) {
|
|
160
|
-
this.start = state.start;
|
|
161
|
-
this.load();
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
registry.replace(this, this.userParams);
|
|
165
|
-
}
|
|
166
|
-
this.load(ev);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
this.subscribeTo('pb-toggle', ev => {
|
|
171
|
-
this.toggleFeature(ev);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
this.subscribeTo('pb-i18n-update', ev => {
|
|
175
|
-
const needsRefresh = this.language && this.language !== ev.detail.language;
|
|
176
|
-
this.language = ev.detail.language;
|
|
177
|
-
if (this.useLanguage && needsRefresh) {
|
|
178
|
-
this.load();
|
|
157
|
+
}
|
|
158
|
+
this.userParams = registry.state;
|
|
159
|
+
registry.subscribe(this, state => {
|
|
160
|
+
if (state.start) {
|
|
161
|
+
this.start = state.start;
|
|
162
|
+
this.load();
|
|
179
163
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (this.history) {
|
|
183
|
-
registry.subscribe(this, (state) => {
|
|
184
|
-
this.start = state.start;
|
|
185
|
-
this.userParams = state;
|
|
186
|
-
this.load();
|
|
187
|
-
});
|
|
164
|
+
});
|
|
165
|
+
registry.replace(this, this.userParams);
|
|
188
166
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
167
|
+
this.load(ev);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
this.subscribeTo('pb-toggle', ev => {
|
|
172
|
+
this.toggleFeature(ev);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Subscribe to pb-document events to know when the document is ready
|
|
176
|
+
this.subscribeTo('pb-document', ev => {
|
|
177
|
+
if (ev.detail && ev.detail.id === this.src) {
|
|
178
|
+
console.log(`<pb-load> Document ${this.src} is ready, triggering load`);
|
|
179
|
+
this.load();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
this.subscribeTo(
|
|
184
|
+
'pb-i18n-update',
|
|
185
|
+
ev => {
|
|
186
|
+
const needsRefresh = this.language && this.language !== ev.detail.language;
|
|
187
|
+
this.language = ev.detail.language;
|
|
188
|
+
if (this.useLanguage && needsRefresh) {
|
|
189
|
+
this.load();
|
|
208
190
|
}
|
|
191
|
+
},
|
|
192
|
+
[],
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
if (this.history) {
|
|
196
|
+
registry.subscribe(this, state => {
|
|
197
|
+
this.start = state.start;
|
|
198
|
+
this.userParams = state;
|
|
199
|
+
this.load();
|
|
200
|
+
});
|
|
209
201
|
}
|
|
210
202
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
203
|
+
this.signalReady();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
firstUpdated() {
|
|
207
|
+
if (this.auto) {
|
|
208
|
+
this.start = registry.state.start || 1;
|
|
209
|
+
waitOnce('pb-page-ready', data => {
|
|
210
|
+
if (data && data.language) {
|
|
211
|
+
this.language = data.language;
|
|
212
|
+
}
|
|
213
|
+
// Add a longer delay to ensure all components are properly initialized
|
|
214
|
+
// This includes pb-document elements that need time to set their properties
|
|
215
|
+
setTimeout(() => {
|
|
216
|
+
this.wait(() => this.load());
|
|
217
|
+
}, 200);
|
|
218
|
+
});
|
|
219
|
+
} else {
|
|
220
|
+
waitOnce('pb-page-ready', data => {
|
|
221
|
+
if (data && data.language) {
|
|
222
|
+
this.language = data.language;
|
|
227
223
|
}
|
|
224
|
+
});
|
|
228
225
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
</paper-button>
|
|
248
|
-
</div>
|
|
249
|
-
</paper-dialog>
|
|
250
|
-
`;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
229
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
230
|
+
if (oldValue && oldValue !== newValue) {
|
|
231
|
+
switch (name) {
|
|
232
|
+
case 'url':
|
|
233
|
+
case 'userParams':
|
|
234
|
+
case 'start':
|
|
235
|
+
if (this.auto && this.loader) {
|
|
236
|
+
waitOnce('pb-page-ready', () => {
|
|
237
|
+
this.wait(() => this.load());
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
default:
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
251
244
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
render() {
|
|
248
|
+
return html`
|
|
249
|
+
<slot></slot>
|
|
250
|
+
<pb-fetch
|
|
251
|
+
id="loadContent"
|
|
252
|
+
verbose
|
|
253
|
+
handle-as="text"
|
|
254
|
+
method="get"
|
|
255
|
+
?with-credentials="${!this.noCredentials}"
|
|
256
|
+
@response="${this._handleContent}"
|
|
257
|
+
@error="${this._handleError}"
|
|
258
|
+
></pb-fetch>
|
|
259
|
+
<pb-dialog id="errorDialog" title="${translate('dialogs.error')}">
|
|
260
|
+
<p id="errorMessage"></p>
|
|
261
|
+
<div slot="footer">
|
|
262
|
+
<button rel="prev" type="button">${translate('dialogs.close')}</button>
|
|
263
|
+
</div>
|
|
264
|
+
</pb-dialog>
|
|
265
|
+
`;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
static get styles() {
|
|
269
|
+
return css`
|
|
270
|
+
:host {
|
|
271
|
+
display: block;
|
|
272
|
+
}
|
|
273
|
+
`;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
toggleFeature(ev) {
|
|
277
|
+
this.userParams = registry.getState(this);
|
|
278
|
+
console.log('<pb-load> toggle feature %o', this.userParams);
|
|
279
|
+
if (ev.detail.refresh) {
|
|
280
|
+
if (this.history) {
|
|
281
|
+
registry.commit(this, this.userParams);
|
|
282
|
+
}
|
|
283
|
+
this.load();
|
|
259
284
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
this.load();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
getURL(params) {
|
|
288
|
+
let { url } = this;
|
|
289
|
+
if (this.expand) {
|
|
290
|
+
url = url.replace(/{([^})]+)}/g, (match, key) => {
|
|
291
|
+
if (!params[key]) {
|
|
292
|
+
return '';
|
|
269
293
|
}
|
|
294
|
+
const param = encodeURIComponent(params[key] || key);
|
|
295
|
+
delete params[key];
|
|
296
|
+
return param;
|
|
297
|
+
});
|
|
270
298
|
}
|
|
299
|
+
return this.toAbsoluteURL(url);
|
|
300
|
+
}
|
|
271
301
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
const param = encodeURIComponent(params[key] || key);
|
|
280
|
-
delete params[key];
|
|
281
|
-
return param;
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
return this.toAbsoluteURL(url);
|
|
302
|
+
load(ev) {
|
|
303
|
+
if (!this.url) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (this.loadOnce && this.loaded) {
|
|
307
|
+
return;
|
|
285
308
|
}
|
|
286
309
|
|
|
287
|
-
|
|
288
|
-
if (!this.url) {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
if (this.loadOnce && this.loaded) {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
this.emitTo('pb-start-update');
|
|
310
|
+
this.emitTo('pb-start-update');
|
|
296
311
|
|
|
297
|
-
|
|
312
|
+
let params = {};
|
|
298
313
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
} else {
|
|
305
|
-
params = ev;
|
|
306
|
-
}
|
|
314
|
+
if (ev) {
|
|
315
|
+
if (ev instanceof Event) {
|
|
316
|
+
if (ev.detail && ev.detail.params) {
|
|
317
|
+
params = ev.detail.params;
|
|
307
318
|
}
|
|
319
|
+
} else {
|
|
320
|
+
params = ev;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
308
323
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
324
|
+
const doc = this.getDocument();
|
|
325
|
+
console.log(`<pb-load> getDocument() returned:`, doc, `src="${this.src}"`);
|
|
326
|
+
console.log(`<pb-load> Available elements with id "${this.src}":`, document.getElementById(this.src));
|
|
327
|
+
if (doc) {
|
|
328
|
+
console.log(`<pb-load> Document found, path="${doc.path}", odd="${doc.odd}", view="${doc.view}"`);
|
|
329
|
+
}
|
|
330
|
+
if (!this.plain) {
|
|
331
|
+
if (doc && doc.path) {
|
|
332
|
+
params.doc = doc.path;
|
|
333
|
+
console.log(`<pb-load> Setting params.doc to:`, doc.path);
|
|
334
|
+
this._retryCount = 0; // Reset retry counter when document is found
|
|
335
|
+
} else if (this.src) {
|
|
336
|
+
// Document not found but src is specified - wait for it to be available
|
|
337
|
+
if (this._retryCount < this._maxRetries) {
|
|
338
|
+
this._retryCount++;
|
|
339
|
+
const delay = Math.min(100 * this._retryCount, 1000); // Progressive delay up to 1 second
|
|
340
|
+
console.warn(`<pb-load> Document with id "${this.src}" not found or not ready, retrying in ${delay}ms (attempt ${this._retryCount}/${this._maxRetries})`);
|
|
341
|
+
setTimeout(() => {
|
|
342
|
+
this.load(ev);
|
|
343
|
+
}, delay);
|
|
344
|
+
return;
|
|
345
|
+
} else {
|
|
346
|
+
console.error(`<pb-load> Document with id "${this.src}" not found after ${this._maxRetries} attempts`);
|
|
347
|
+
// Instead of returning, show a loading state and keep trying
|
|
348
|
+
this.innerHTML = '<pb-i18n key="dialogs.loading">Loading...</pb-i18n>';
|
|
349
|
+
return;
|
|
323
350
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
//
|
|
327
|
-
|
|
328
|
-
|
|
351
|
+
} else {
|
|
352
|
+
// No document and no src specified - this might be intentional for plain mode
|
|
353
|
+
// But if we have {doc} in the URL template, we should warn
|
|
354
|
+
if (this.url && this.url.includes('{doc}')) {
|
|
355
|
+
console.warn(`<pb-load> URL template contains {doc} placeholder but no document is available and no src is specified`);
|
|
329
356
|
}
|
|
357
|
+
}
|
|
330
358
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
loader.params = params;
|
|
336
|
-
loader.url = url;
|
|
337
|
-
loader.generateRequest();
|
|
359
|
+
// set start parameter to start property, but only if not provided otherwise already
|
|
360
|
+
if (this.start && !params.start) {
|
|
361
|
+
params.start = this.start;
|
|
362
|
+
}
|
|
338
363
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
364
|
+
if (this.language) {
|
|
365
|
+
params.language = this.language;
|
|
366
|
+
}
|
|
342
367
|
}
|
|
368
|
+
params = this.prepareParameters(params);
|
|
343
369
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
*/
|
|
350
|
-
prepareParameters(params) {
|
|
351
|
-
if (this.userParams) {
|
|
352
|
-
return Object.assign(params, this.userParams);
|
|
353
|
-
}
|
|
354
|
-
return params;
|
|
370
|
+
// filter null values
|
|
371
|
+
for (const [k, v] of Object.entries(params)) {
|
|
372
|
+
if (v === null) {
|
|
373
|
+
delete params[k];
|
|
374
|
+
}
|
|
355
375
|
}
|
|
356
376
|
|
|
357
|
-
|
|
358
|
-
const resp = this.shadowRoot.getElementById('loadContent').lastResponse;
|
|
359
|
-
if (this.container) {
|
|
360
|
-
this.style.display = 'none';
|
|
361
|
-
document.querySelectorAll(this.container).forEach((elem) => {
|
|
362
|
-
elem.innerHTML = resp;
|
|
363
|
-
this._parseHeaders(ev.detail.xhr, elem);
|
|
364
|
-
this._fixLinks(elem);
|
|
365
|
-
this._onLoad(elem);
|
|
366
|
-
});
|
|
367
|
-
} else {
|
|
368
|
-
this.style.display = '';
|
|
369
|
-
this._clearContent();
|
|
377
|
+
const url = this.getURL(params);
|
|
370
378
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
379
|
+
// Check if the URL still contains unresolved parameters
|
|
380
|
+
if (url.includes('{') && url.includes('}')) {
|
|
381
|
+
console.warn(`<pb-load> URL still contains unresolved parameters: ${url}`);
|
|
382
|
+
if (this.src) {
|
|
383
|
+
// Keep showing loading state and retry later
|
|
384
|
+
this.innerHTML = '<pb-i18n key="dialogs.loading">Loading...</pb-i18n>';
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
377
388
|
|
|
378
|
-
|
|
379
|
-
|
|
389
|
+
console.log('<pb-load> Loading %s with parameters %o', url, params);
|
|
390
|
+
const loader = this.shadowRoot.getElementById('loadContent');
|
|
391
|
+
loader.params = params;
|
|
392
|
+
loader.url = url;
|
|
393
|
+
loader.generateRequest();
|
|
380
394
|
|
|
381
|
-
|
|
395
|
+
if (this.loadOnce) {
|
|
396
|
+
this.loaded = true;
|
|
382
397
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Allow subclasses to set parameters before the request is being sent.
|
|
402
|
+
*
|
|
403
|
+
* @param params Map of parameters
|
|
404
|
+
* @return new or modified parameters map
|
|
405
|
+
*/
|
|
406
|
+
prepareParameters(params) {
|
|
407
|
+
if (this.userParams) {
|
|
408
|
+
return Object.assign(params, this.userParams);
|
|
390
409
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
+
return params;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
_handleContent(ev) {
|
|
414
|
+
const resp = this.shadowRoot.getElementById('loadContent').lastResponse;
|
|
415
|
+
if (this.container) {
|
|
416
|
+
this.style.display = 'none';
|
|
417
|
+
document.querySelectorAll(this.container).forEach(elem => {
|
|
418
|
+
elem.innerHTML = resp;
|
|
419
|
+
this._parseHeaders(ev.detail.xhr, elem);
|
|
420
|
+
this._fixLinks(elem);
|
|
421
|
+
this._onLoad(elem);
|
|
422
|
+
});
|
|
423
|
+
} else {
|
|
424
|
+
this.style.display = '';
|
|
425
|
+
this._clearContent();
|
|
426
|
+
|
|
427
|
+
const div = document.createElement('div');
|
|
428
|
+
div.innerHTML = resp;
|
|
429
|
+
this._parseHeaders(ev.detail.xhr, div);
|
|
430
|
+
div.slot = '';
|
|
431
|
+
this.appendChild(div);
|
|
432
|
+
this._fixLinks(div);
|
|
433
|
+
|
|
434
|
+
this._onLoad(div);
|
|
410
435
|
}
|
|
411
436
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
// Search for data-pagination-* attributes first and if they
|
|
415
|
-
// can't be found, check HTTP headers
|
|
416
|
-
//
|
|
417
|
-
// However, if noCredentials is set, we won't be able to access the headers
|
|
418
|
-
function getPaginationParam(type, noHeaders) {
|
|
419
|
-
const elem = content.querySelector(`[data-pagination-${type}]`);
|
|
420
|
-
if (elem) {
|
|
421
|
-
return elem.getAttribute(`data-pagination-${type}`);
|
|
422
|
-
}
|
|
423
|
-
return noHeaders ? 0 : xhr.getResponseHeader(`pb-${type}`);
|
|
424
|
-
}
|
|
437
|
+
this.emitTo('pb-end-update');
|
|
438
|
+
}
|
|
425
439
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
this.emitTo('pb-results-received', {
|
|
433
|
-
"count": total ? parseInt(total, 10) : 0,
|
|
434
|
-
"start": this.start,
|
|
435
|
-
"content": content,
|
|
436
|
-
"params": this.shadowRoot.getElementById('loadContent').params
|
|
437
|
-
});
|
|
440
|
+
_clearContent() {
|
|
441
|
+
const contentSlot = this.shadowRoot.querySelector('slot:not([name])');
|
|
442
|
+
if (contentSlot) {
|
|
443
|
+
// clear content from slot
|
|
444
|
+
contentSlot.assignedNodes().forEach(node => node.parentNode.removeChild(node));
|
|
438
445
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
content.querySelectorAll('a').forEach((link) => {
|
|
449
|
-
const oldHref = link.getAttribute('href');
|
|
450
|
-
const href = new URL(oldHref, `${this.getEndpoint()}/`);
|
|
451
|
-
link.href = href;
|
|
452
|
-
});
|
|
453
|
-
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
_handleError() {
|
|
449
|
+
this.emitTo('pb-end-update');
|
|
450
|
+
const loader = this.shadowRoot.getElementById('loadContent');
|
|
451
|
+
const { response } = loader.lastError;
|
|
452
|
+
if (this.silent) {
|
|
453
|
+
console.error('Request failed: %s', response ? response.description : '');
|
|
454
|
+
return;
|
|
454
455
|
}
|
|
455
|
-
|
|
456
|
-
|
|
456
|
+
let message;
|
|
457
|
+
if (response) {
|
|
458
|
+
message = response.description;
|
|
459
|
+
} else {
|
|
460
|
+
message = '<pb-i18n key="dialogs.serverError"></pb-i18n>';
|
|
461
|
+
}
|
|
462
|
+
const dialog = this.shadowRoot.getElementById('errorDialog');
|
|
463
|
+
const messageElement = this.shadowRoot.getElementById('errorMessage');
|
|
464
|
+
messageElement.innerHTML = `<pb-i18n key="dialogs.serverError"></pb-i18n>: ${message}`;
|
|
465
|
+
dialog.openDialog();
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
_parseHeaders(xhr, content) {
|
|
469
|
+
// Try to determine number of pages and current position
|
|
470
|
+
// Search for data-pagination-* attributes first and if they
|
|
471
|
+
// can't be found, check HTTP headers
|
|
472
|
+
//
|
|
473
|
+
// However, if noCredentials is set, we won't be able to access the headers
|
|
474
|
+
function getPaginationParam(type, noHeaders) {
|
|
475
|
+
const elem = content.querySelector(`[data-pagination-${type}]`);
|
|
476
|
+
if (elem) {
|
|
477
|
+
return elem.getAttribute(`data-pagination-${type}`);
|
|
478
|
+
}
|
|
479
|
+
return noHeaders ? 0 : xhr.getResponseHeader(`pb-${type}`);
|
|
457
480
|
}
|
|
458
481
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
482
|
+
const total = getPaginationParam('total', this.noCredentials);
|
|
483
|
+
const start = getPaginationParam('start', this.noCredentials);
|
|
484
|
+
|
|
485
|
+
if (this.start !== start) {
|
|
486
|
+
this.start = parseInt(start);
|
|
487
|
+
}
|
|
488
|
+
this.emitTo('pb-results-received', {
|
|
489
|
+
count: total ? parseInt(total, 10) : 0,
|
|
490
|
+
start: this.start,
|
|
491
|
+
content,
|
|
492
|
+
params: this.shadowRoot.getElementById('loadContent').params,
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
_fixLinks(content) {
|
|
497
|
+
typesetMath(content);
|
|
498
|
+
if (this.fixLinks) {
|
|
499
|
+
content.querySelectorAll('img').forEach(image => {
|
|
500
|
+
const oldSrc = image.getAttribute('src');
|
|
501
|
+
if (!oldSrc) {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
try {
|
|
505
|
+
image.src = this.toAbsoluteURL(oldSrc);
|
|
506
|
+
} catch (err) {
|
|
507
|
+
console.warn('<pb-load> Unable to resolve image URL %s', oldSrc, err);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
content.querySelectorAll('a').forEach(link => {
|
|
511
|
+
const oldHref = link.getAttribute('href');
|
|
512
|
+
if (!oldHref) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
try {
|
|
516
|
+
link.href = this.toAbsoluteURL(oldHref);
|
|
517
|
+
} catch (err) {
|
|
518
|
+
console.warn('<pb-load> Unable to resolve link URL %s', oldHref, err);
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
_onLoad(content) {}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Fired before the element updates its content
|
|
528
|
+
*
|
|
529
|
+
* @event pb-start-update
|
|
530
|
+
* @param {object} Parameters to be passed to the request
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Fired after the element has finished updating its content
|
|
535
|
+
*
|
|
536
|
+
* @event pb-end-update
|
|
537
|
+
*/
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Fired after the element has received content from the server
|
|
541
|
+
*
|
|
542
|
+
* @event pb-results-received
|
|
543
|
+
* @param {int} count number of results received (according to `pb-total` header)
|
|
544
|
+
* @param {int} start offset into the result set (according to `pb-start` header)
|
|
545
|
+
*/
|
|
479
546
|
}
|
|
480
|
-
customElements.define('pb-load', PbLoad);
|
|
547
|
+
customElements.define('pb-load', PbLoad);
|