@teipublisher/pb-components 1.44.1 → 2.0.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 +67 -0
- package/dist/demo/demos.json +2 -1
- package/dist/demo/pb-browse-docs.html +2 -1
- package/dist/demo/pb-combo-box.html +1 -1
- package/dist/demo/pb-document.html +2 -2
- package/dist/demo/pb-load.html +2 -2
- package/dist/demo/pb-select-feature.html +1 -1
- package/dist/demo/pb-select-feature2.html +10 -3
- package/dist/demo/pb-select-feature3.html +1 -1
- package/dist/demo/pb-select-odd.html +1 -1
- package/dist/demo/pb-table-grid.html +1 -1
- package/dist/demo/pb-tabs.html +8 -2
- package/dist/demo/pb-toggle-feature.html +2 -2
- package/dist/demo/pb-toggle-feature2.html +2 -2
- package/dist/demo/pb-toggle-feature3.html +2 -2
- package/dist/demo/pb-view.html +1 -1
- package/dist/demo/pb-view4.html +86 -0
- package/dist/pb-code-editor.js +1 -1
- package/dist/pb-component-docs.js +33 -33
- package/dist/pb-components-bundle.js +173 -173
- package/dist/pb-edit-app.js +6 -6
- package/dist/pb-elements.json +94 -28
- package/dist/{pb-i18n-3963b098.js → pb-i18n-8a90c591.js} +1 -1
- package/dist/pb-leaflet-map.js +1 -1
- package/dist/pb-mixin-8a593923.js +158 -0
- package/dist/pb-odd-editor.js +47 -47
- package/dist/{vaadin-element-mixin-08cf11b5.js → vaadin-element-mixin-672938e3.js} +18 -18
- package/i18n/common/en.json +9 -1
- package/package.json +5 -4
- package/pb-elements.json +94 -28
- package/src/dts-client.js +14 -14
- package/src/dts-select-endpoint.js +5 -5
- package/src/pb-ajax.js +4 -4
- package/src/pb-authority-lookup.js +2 -2
- package/src/pb-autocomplete.js +9 -11
- package/src/pb-blacklab-highlight.js +3 -3
- package/src/pb-browse-docs.js +44 -27
- package/src/pb-browse.js +9 -3
- package/src/pb-combo-box.js +2 -2
- package/src/pb-document.js +15 -1
- package/src/pb-download.js +2 -2
- package/src/pb-edit-app.js +2 -2
- package/src/pb-edit-xml.js +2 -2
- package/src/pb-events.js +26 -18
- package/src/pb-facsimile.js +28 -4
- package/src/pb-grid.js +55 -53
- package/src/pb-lang.js +2 -2
- package/src/pb-link.js +10 -16
- package/src/pb-load.js +35 -25
- package/src/pb-login.js +2 -2
- package/src/pb-manage-odds.js +2 -2
- package/src/pb-markdown.js +2 -2
- package/src/pb-mei.js +2 -2
- package/src/pb-mixin.js +103 -196
- package/src/pb-odd-editor.js +2 -2
- package/src/pb-page.js +30 -21
- package/src/pb-paginate.js +24 -19
- package/src/pb-print-preview.js +2 -2
- package/src/pb-repeat.js +2 -1
- package/src/pb-search.js +34 -8
- package/src/pb-select-feature.js +62 -39
- package/src/pb-select-odd.js +8 -7
- package/src/pb-select-template.js +5 -4
- package/src/pb-select.js +31 -28
- package/src/pb-split-list.js +18 -11
- package/src/pb-table-grid.js +9 -8
- package/src/pb-tabs.js +29 -12
- package/src/pb-toggle-feature.js +51 -55
- package/src/pb-upload.js +10 -3
- package/src/pb-view.js +118 -95
- package/src/theming.js +148 -149
- package/src/urls.js +233 -0
- package/dist/pb-mixin-88125cb2.js +0 -158
package/src/pb-document.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin';
|
|
2
|
+
import { pbMixin } from './pb-mixin.js';
|
|
3
|
+
import { registry } from "./urls.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Represents a Publisher document. It has no visual presentation but holds meta-data
|
|
@@ -52,6 +53,10 @@ class PbDocument extends pbMixin(LitElement) {
|
|
|
52
53
|
type: String,
|
|
53
54
|
reflect: true
|
|
54
55
|
},
|
|
56
|
+
disableHistory: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
attribute: 'disable-history'
|
|
59
|
+
},
|
|
55
60
|
sourceView: {
|
|
56
61
|
type: String,
|
|
57
62
|
attribute: 'source-view'
|
|
@@ -63,10 +68,19 @@ class PbDocument extends pbMixin(LitElement) {
|
|
|
63
68
|
super();
|
|
64
69
|
this.path = '';
|
|
65
70
|
this.rootPath = '';
|
|
71
|
+
this.disableHistory = false;
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
connectedCallback() {
|
|
69
75
|
super.connectedCallback();
|
|
76
|
+
|
|
77
|
+
if (!this.disableHistory) {
|
|
78
|
+
if (registry.state.path) {
|
|
79
|
+
this.path = registry.state.path;
|
|
80
|
+
}
|
|
81
|
+
this.view = registry.state.view || this.view;
|
|
82
|
+
this.odd = registry.state.odd || this.odd;
|
|
83
|
+
}
|
|
70
84
|
}
|
|
71
85
|
|
|
72
86
|
attributeChangedCallback(name, oldVal, newVal) {
|
package/src/pb-download.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import 'js-cookie/src/js.cookie.js';
|
|
3
|
-
import { pbMixin } from './pb-mixin.js';
|
|
3
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Generate a link to download a resource. Optionally shows a dialog during the download.
|
|
@@ -104,7 +104,7 @@ export class PbDownload extends pbMixin(LitElement) {
|
|
|
104
104
|
this._href = this._computeURL();
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
|
-
|
|
107
|
+
waitOnce('pb-page-ready', () => {
|
|
108
108
|
this._target = this._computeTarget();
|
|
109
109
|
this._href = this._computeURL();
|
|
110
110
|
});
|
package/src/pb-edit-app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin.js';
|
|
2
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
3
|
import { translate } from './pb-i18n.js';
|
|
4
4
|
import '@polymer/paper-input/paper-input.js';
|
|
5
5
|
import '@polymer/paper-button';
|
|
@@ -62,7 +62,7 @@ export class PbEditApp extends pbMixin(LitElement) {
|
|
|
62
62
|
indexListbox.selected = undefined;
|
|
63
63
|
indexListbox.selected = old;
|
|
64
64
|
}, []);
|
|
65
|
-
|
|
65
|
+
waitOnce('pb-page-ready', (detail) => {
|
|
66
66
|
let url;
|
|
67
67
|
if (this.minApiVersion('1.0.0')) {
|
|
68
68
|
url = `${detail.endpoint}/api/templates`;
|
package/src/pb-edit-xml.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin';
|
|
2
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -43,7 +43,7 @@ export class PbEditXml extends pbMixin(LitElement) {
|
|
|
43
43
|
|
|
44
44
|
connectedCallback() {
|
|
45
45
|
super.connectedCallback();
|
|
46
|
-
|
|
46
|
+
waitOnce('pb-page-ready', (options) => {
|
|
47
47
|
if (options.endpoint === '.') {
|
|
48
48
|
this._href = '/exist/apps/eXide/';
|
|
49
49
|
} else {
|
package/src/pb-events.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { defaultChannel } from "./pb-mixin.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Utility class to plug into TEI Publisher's event system from custom javascript.
|
|
3
5
|
*/
|
|
@@ -12,16 +14,10 @@ export class PbEvents {
|
|
|
12
14
|
* Receives the event as first and the event handler as second parameter.
|
|
13
15
|
*/
|
|
14
16
|
static subscribe(name, channels, callback, once=false) {
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line no-param-reassign
|
|
17
|
-
channels = [channels];
|
|
18
|
-
}
|
|
17
|
+
const _channels = PbEvents._getChannels(channels)
|
|
19
18
|
const handler = document.addEventListener(name, (/** @type {CustomEvent} */ ev) => {
|
|
20
|
-
if (
|
|
21
|
-
(
|
|
22
|
-
if (callback) {
|
|
23
|
-
callback(ev, handler);
|
|
24
|
-
}
|
|
19
|
+
if (callback && ev.detail && ev.detail.key && _channels.includes(ev.detail.key)) {
|
|
20
|
+
callback(ev, handler);
|
|
25
21
|
}
|
|
26
22
|
}, {
|
|
27
23
|
once
|
|
@@ -37,14 +33,10 @@ export class PbEvents {
|
|
|
37
33
|
* @returns {Promise} resolves if event is caught, providing the event as parameter
|
|
38
34
|
*/
|
|
39
35
|
static subscribeOnce(name, channels=null) {
|
|
40
|
-
|
|
41
|
-
// eslint-disable-next-line no-param-reassign
|
|
42
|
-
channels = [channels];
|
|
43
|
-
}
|
|
36
|
+
const _channels = PbEvents._getChannels(channels);
|
|
44
37
|
return new Promise((resolve) => {
|
|
45
38
|
document.addEventListener(name, (/** @type {CustomEvent} */ ev) => {
|
|
46
|
-
if (
|
|
47
|
-
(channels && ev.detail && ev.detail.key && channels.indexOf(ev.detail.key) > -1)) {
|
|
39
|
+
if (ev.detail && ev.detail.key && _channels.includes(ev.detail.key)) {
|
|
48
40
|
resolve(ev);
|
|
49
41
|
}
|
|
50
42
|
}, {
|
|
@@ -53,6 +45,24 @@ export class PbEvents {
|
|
|
53
45
|
});
|
|
54
46
|
}
|
|
55
47
|
|
|
48
|
+
/**
|
|
49
|
+
* determine channels to subscribe to
|
|
50
|
+
*
|
|
51
|
+
* @param {string|string[]|null} channels name of a channel, array of channel names or null to target the default channel
|
|
52
|
+
* @returns {string[]} channels
|
|
53
|
+
*/
|
|
54
|
+
static _getChannels(channels) {
|
|
55
|
+
// no channels: null or empty string or empty array
|
|
56
|
+
if (channels === null || !channels.length) {
|
|
57
|
+
return [defaultChannel]
|
|
58
|
+
}
|
|
59
|
+
// single string
|
|
60
|
+
if (!Array.isArray(channels)) {
|
|
61
|
+
return [channels];
|
|
62
|
+
}
|
|
63
|
+
return channels;
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
/**
|
|
57
67
|
* Emit an event to a particular channel
|
|
58
68
|
*
|
|
@@ -62,9 +72,7 @@ export class PbEvents {
|
|
|
62
72
|
*/
|
|
63
73
|
static emit(type, channel=null, detail=null) {
|
|
64
74
|
const options = detail || {};
|
|
65
|
-
|
|
66
|
-
options.key = channel;
|
|
67
|
-
}
|
|
75
|
+
options.key = channel || defaultChannel;
|
|
68
76
|
const ev = new CustomEvent(type, {
|
|
69
77
|
detail: options
|
|
70
78
|
});
|
package/src/pb-facsimile.js
CHANGED
|
@@ -10,13 +10,13 @@ import { resolveURL } from './utils.js';
|
|
|
10
10
|
* @fires pb-update - Checks the contents received for pb-facs-links
|
|
11
11
|
* @fires pb-show-annotation - When received, sets up the viewer to select a particular image and highlight coordinates
|
|
12
12
|
* @fires pb-facsimile-status - Indicates the status of loading an image into the viewer. The status is indicated
|
|
13
|
-
* by the `status` property in event.detail as follows: `loading` - image was requested; `loaded` - image is displayed;
|
|
13
|
+
* by the `status` property in event.detail as follows: `loading` - image was requested; `loaded` - image is displayed;
|
|
14
14
|
* `fail` - image could not be loaded.
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
* @cssprop --pb-facsimile-height=auto - Max. height of the image viewer
|
|
17
17
|
* @cssprop --pb-facsimile-border - Style for the annotation highlight border
|
|
18
18
|
* @csspart image - exposes the inner div hosting the image viewer
|
|
19
|
-
*
|
|
19
|
+
*
|
|
20
20
|
* @slot before - use for content which should be shown above the facsimile viewer
|
|
21
21
|
* @slot after - use for content which should be shown below the facsimile viewer
|
|
22
22
|
*/
|
|
@@ -254,6 +254,28 @@ export class PbFacsimile extends pbMixin(LitElement) {
|
|
|
254
254
|
this.loaded = false;
|
|
255
255
|
this.emitTo('pb-facsimile-status', { status: 'fail' });
|
|
256
256
|
});
|
|
257
|
+
|
|
258
|
+
/*
|
|
259
|
+
handling of full-screen view requires to hide/unhide the content of body to allow full screen viewer
|
|
260
|
+
to full-page functionality. Standard OSD completely deletes all body children disconnecting all event-handlers
|
|
261
|
+
that have been there. This solution just uses style.display to hide/show. Former display value of pb-page
|
|
262
|
+
will be preserved.
|
|
263
|
+
|
|
264
|
+
Current limitation: this solution assumes that a pb-page element exists and is an immediate child of body.
|
|
265
|
+
*/
|
|
266
|
+
this.ownerPage = this.closest('pb-page');
|
|
267
|
+
if(this.ownerPage){
|
|
268
|
+
this.pbPageDisplay = window.getComputedStyle(this.ownerPage).getPropertyValue('display');
|
|
269
|
+
this.viewer.addHandler('full-screen', (ev) => {
|
|
270
|
+
if(ev.fullScreen){
|
|
271
|
+
this.ownerPage.style.display = 'none';
|
|
272
|
+
}else{
|
|
273
|
+
this.viewer.clearOverlays();
|
|
274
|
+
this.emitTo('pb-refresh');
|
|
275
|
+
this.ownerPage.style.display = this.pbPageDisplay;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
257
279
|
this._facsimileObserver();
|
|
258
280
|
|
|
259
281
|
this.signalReady();
|
|
@@ -381,4 +403,6 @@ export class PbFacsimile extends pbMixin(LitElement) {
|
|
|
381
403
|
|
|
382
404
|
|
|
383
405
|
}
|
|
384
|
-
customElements.
|
|
406
|
+
if (!customElements.get('pb-facsimile')) {
|
|
407
|
+
customElements.define('pb-facsimile', PbFacsimile);
|
|
408
|
+
}
|
package/src/pb-grid.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import { pbMixin } from './pb-mixin.js';
|
|
3
|
+
import { registry } from "./urls.js";
|
|
3
4
|
import './pb-panel.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -54,6 +55,7 @@ export class PbGrid extends pbMixin(LitElement) {
|
|
|
54
55
|
|
|
55
56
|
constructor() {
|
|
56
57
|
super();
|
|
58
|
+
this.panels = [];
|
|
57
59
|
this.direction = 'ltr';
|
|
58
60
|
this.animated = 'pb-view';
|
|
59
61
|
this.animation = false;
|
|
@@ -63,34 +65,35 @@ export class PbGrid extends pbMixin(LitElement) {
|
|
|
63
65
|
super.connectedCallback();
|
|
64
66
|
|
|
65
67
|
this.subscribeTo('pb-panel', ev => {
|
|
66
|
-
const idx =
|
|
67
|
-
if (idx
|
|
68
|
-
|
|
69
|
-
this.panels[this.direction === 'rtl' ? this.panels.length - idx - 1 : idx] = ev.detail.active;
|
|
70
|
-
|
|
71
|
-
localStorage.setItem('pb-grid.panels', this.panels.join('.'));
|
|
72
|
-
this.setParameter('panels', this.panels.join('.'));
|
|
73
|
-
this.pushHistory('added panel');
|
|
68
|
+
const idx = this._getPanelIndex(ev.detail.panel);
|
|
69
|
+
if (idx < 0) {
|
|
70
|
+
return // panel not found
|
|
74
71
|
}
|
|
72
|
+
console.log('<pb-grid> Updating panel %d to show %s', idx, ev.detail.active);
|
|
73
|
+
this.panels[this.direction === 'rtl' ? this.panels.length - idx - 1 : idx] = ev.detail.active;
|
|
74
|
+
|
|
75
|
+
registry.commit(this, this._getState())
|
|
75
76
|
});
|
|
76
|
-
|
|
77
|
+
|
|
78
|
+
const panelsParam = registry.get('panels');
|
|
77
79
|
if (panelsParam) {
|
|
78
80
|
this.panels = panelsParam.split('.').map(param => parseInt(param));
|
|
79
|
-
localStorage.setItem('pb-grid.panels', this.panels.join('.'));
|
|
80
|
-
} else {
|
|
81
|
-
const panelsStored = localStorage.getItem('pb-grid.panels');
|
|
82
|
-
if (panelsStored) {
|
|
83
|
-
this.panels = panelsStored.split('.').map(param => parseInt(param));
|
|
84
|
-
}
|
|
85
81
|
}
|
|
86
82
|
|
|
83
|
+
registry.subscribe(this, (state) => {
|
|
84
|
+
const newState = state.panels ? state.panels.split('.') : [];
|
|
85
|
+
this.panels = newState;
|
|
86
|
+
this.innerHTML=''; // hard reset of child DOM
|
|
87
|
+
this.panels.forEach(panelNum => this._insertPanel(panelNum));
|
|
88
|
+
this._update();
|
|
89
|
+
});
|
|
87
90
|
this._columns = this.panels.length;
|
|
88
91
|
this.template = this.querySelector('template');
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
firstUpdated() {
|
|
92
95
|
this.panels.forEach(panelNum => this._insertPanel(panelNum));
|
|
93
|
-
|
|
96
|
+
registry.commit(this, this._getState())
|
|
94
97
|
this._animate();
|
|
95
98
|
this._update();
|
|
96
99
|
}
|
|
@@ -132,41 +135,32 @@ export class PbGrid extends pbMixin(LitElement) {
|
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
addPanel(initial) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
initial = 0;
|
|
143
|
-
}
|
|
138
|
+
let value = initial
|
|
139
|
+
if (!initial && !this.panels.length) {
|
|
140
|
+
value = 0
|
|
141
|
+
}
|
|
142
|
+
if (!initial && this.panels.length) {
|
|
143
|
+
const max = this.panels.reduce((result, next) => Math.max(result, next), 0);
|
|
144
|
+
value = max + 1;
|
|
144
145
|
}
|
|
145
|
-
this._columns++;
|
|
146
|
-
this.panels.push(initial);
|
|
147
|
-
|
|
148
|
-
localStorage.setItem('pb-grid.panels', this.panels.join('.'));
|
|
149
|
-
this.setParameter('panels', this.panels.join('.'));
|
|
150
|
-
this.pushHistory('added panel');
|
|
151
146
|
|
|
152
|
-
this.
|
|
147
|
+
this._columns += 1;
|
|
148
|
+
this.panels.push(value);
|
|
153
149
|
|
|
150
|
+
this._insertPanel(value);
|
|
151
|
+
registry.commit(this, this._getState())
|
|
154
152
|
this._update();
|
|
155
|
-
|
|
156
153
|
this.emitTo('pb-refresh', null);
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
removePanel(panel) {
|
|
160
|
-
const idx =
|
|
157
|
+
const idx = this._getPanelIndex(panel);
|
|
161
158
|
console.log('<pb-grid> Removing panel %d', idx);
|
|
162
159
|
this.panels.splice(this.direction === 'rtl' ? this.panels.length - idx - 1 : idx, 1);
|
|
163
160
|
|
|
164
|
-
this.setParameter('panels', this.panels.join('.'));
|
|
165
|
-
localStorage.setItem('pb-grid.panels', this.panels.join('.'));
|
|
166
|
-
this.pushHistory('removed panel');
|
|
167
|
-
|
|
168
161
|
panel.parentNode.removeChild(panel);
|
|
169
|
-
this._columns
|
|
162
|
+
this._columns -= 1;
|
|
163
|
+
registry.commit(this, this._getState() )
|
|
170
164
|
this._update();
|
|
171
165
|
}
|
|
172
166
|
|
|
@@ -182,22 +176,28 @@ export class PbGrid extends pbMixin(LitElement) {
|
|
|
182
176
|
}
|
|
183
177
|
|
|
184
178
|
_update() {
|
|
185
|
-
const widths =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
widths.push('1fr');
|
|
196
|
-
}
|
|
197
|
-
});
|
|
179
|
+
const widths = Array.from(this.children)
|
|
180
|
+
.filter(child => !(child instanceof HTMLTemplateElement))
|
|
181
|
+
.map(child => {
|
|
182
|
+
const styles = window.getComputedStyle(child);
|
|
183
|
+
const width = styles.getPropertyValue('max-width');
|
|
184
|
+
if (width && width !== 'none') {
|
|
185
|
+
return width;
|
|
186
|
+
}
|
|
187
|
+
return '1fr';
|
|
188
|
+
});
|
|
198
189
|
this.style.setProperty('--pb-computed-column-widths', widths.join(' '));
|
|
199
190
|
}
|
|
200
191
|
|
|
192
|
+
_getPanelIndex(panel) {
|
|
193
|
+
const panels = Array.from(this.querySelectorAll('._grid_panel'));
|
|
194
|
+
return panels.indexOf(panel);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_getState() {
|
|
198
|
+
return { panels: this.panels.join('.') };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
201
|
render() {
|
|
202
202
|
return html`<slot></slot>`;
|
|
203
203
|
}
|
|
@@ -214,4 +214,6 @@ export class PbGrid extends pbMixin(LitElement) {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
}
|
|
217
|
-
customElements.
|
|
217
|
+
if (!customElements.get('pb-grid')) {
|
|
218
|
+
customElements.define('pb-grid', PbGrid);
|
|
219
|
+
}
|
package/src/pb-lang.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import '@polymer/paper-dropdown-menu/paper-dropdown-menu.js';
|
|
3
3
|
import '@polymer/paper-listbox';
|
|
4
|
-
import { pbMixin } from './pb-mixin.js';
|
|
4
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
5
5
|
import { translate } from "./pb-i18n.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -46,7 +46,7 @@ export class PbLang extends pbMixin(LitElement) {
|
|
|
46
46
|
this.subscribeTo('pb-i18n-update', (ev) => {
|
|
47
47
|
this.selected = ev.detail.language.replace(/^([^-]+).*$/, '$1');
|
|
48
48
|
}, []);
|
|
49
|
-
|
|
49
|
+
waitOnce('pb-i18n-update', (options) => {
|
|
50
50
|
this.selected = options.language.replace(/^([^-]+).*$/, '$1');
|
|
51
51
|
});
|
|
52
52
|
}
|
package/src/pb-link.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LitElement, html } from 'lit-element';
|
|
2
2
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
3
3
|
import { pbMixin } from './pb-mixin.js';
|
|
4
|
+
import { registry } from "./urls.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Create an internal link: clicking it will cause connected views to
|
|
@@ -88,37 +89,30 @@ export class PbLink extends pbMixin(LitElement) {
|
|
|
88
89
|
_onClick(ev) {
|
|
89
90
|
ev.preventDefault();
|
|
90
91
|
|
|
91
|
-
const params = {
|
|
92
|
-
|
|
92
|
+
const params = {
|
|
93
|
+
id: null,
|
|
94
|
+
root: null
|
|
93
95
|
};
|
|
94
96
|
if (this.xmlId) {
|
|
95
97
|
params.id = this.xmlId;
|
|
96
|
-
this.history && this.setParameter('id', this.xmlId);
|
|
97
98
|
} else if (this.nodeId) {
|
|
98
|
-
params.
|
|
99
|
-
this.history && this.setParameter('root', this.nodeId);
|
|
99
|
+
params.root = this.nodeId;
|
|
100
100
|
}
|
|
101
101
|
if (this.path) {
|
|
102
102
|
params.path = this.path;
|
|
103
|
-
this.history && this.setPath(this.path);
|
|
104
103
|
}
|
|
105
104
|
if (this.odd) {
|
|
106
105
|
params.odd = this.odd;
|
|
107
|
-
|
|
106
|
+
}
|
|
107
|
+
if (this.hash) {
|
|
108
|
+
params.hash = this.hash;
|
|
108
109
|
}
|
|
109
110
|
if (this.view) {
|
|
110
111
|
params.view = this.view;
|
|
111
|
-
this.history && this.setParameter('view', this.view);
|
|
112
112
|
}
|
|
113
|
-
if (this.
|
|
114
|
-
|
|
115
|
-
if (this.history) {
|
|
116
|
-
this.getUrl().hash = this.hash;
|
|
117
|
-
}
|
|
118
|
-
} else if (this.history) {
|
|
119
|
-
this.getUrl().hash = '';
|
|
113
|
+
if (this.history) {
|
|
114
|
+
registry.commit(this, params);
|
|
120
115
|
}
|
|
121
|
-
this.pushHistory('link click');
|
|
122
116
|
|
|
123
117
|
this.emitTo('pb-refresh', params);
|
|
124
118
|
}
|
package/src/pb-load.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin.js';
|
|
2
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
3
|
import { translate } from "./pb-i18n.js";
|
|
4
4
|
import { typesetMath } from "./pb-formula.js";
|
|
5
|
+
import { registry } from "./urls.js";
|
|
5
6
|
import '@polymer/iron-ajax';
|
|
6
7
|
import '@polymer/paper-dialog';
|
|
7
8
|
import '@polymer/paper-dialog-scrollable';
|
|
@@ -138,30 +139,27 @@ export class PbLoad extends pbMixin(LitElement) {
|
|
|
138
139
|
connectedCallback() {
|
|
139
140
|
super.connectedCallback();
|
|
140
141
|
this.subscribeTo(this.event, (ev) => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
waitOnce('pb-page-ready', () => {
|
|
143
|
+
if (this.history) {
|
|
144
|
+
if (ev.detail && ev.detail.params) {
|
|
145
|
+
const start = ev.detail.params.start;
|
|
146
|
+
if (start) {
|
|
147
|
+
registry.commit(this, { start });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
this.userParams = registry.state;
|
|
151
|
+
registry.subscribe(this, (state) => {
|
|
152
|
+
if (state.start) {
|
|
153
|
+
this.start = state.start;
|
|
154
|
+
this.load();
|
|
155
|
+
}
|
|
147
156
|
});
|
|
157
|
+
registry.replace(this, this.userParams);
|
|
148
158
|
}
|
|
149
|
-
}
|
|
150
|
-
PbLoad.waitOnce('pb-page-ready', () => {
|
|
151
159
|
this.load(ev);
|
|
152
160
|
});
|
|
153
161
|
});
|
|
154
162
|
|
|
155
|
-
if (this.history) {
|
|
156
|
-
window.addEventListener('popstate', (ev) => {
|
|
157
|
-
ev.preventDefault();
|
|
158
|
-
if (ev.state && ev.state.start && ev.state.start !== this.start) {
|
|
159
|
-
this.start = ev.state.start;
|
|
160
|
-
this.load();
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
163
|
this.subscribeTo('pb-toggle', ev => {
|
|
166
164
|
this.toggleFeature(ev);
|
|
167
165
|
});
|
|
@@ -174,20 +172,28 @@ export class PbLoad extends pbMixin(LitElement) {
|
|
|
174
172
|
}
|
|
175
173
|
}, []);
|
|
176
174
|
|
|
175
|
+
if (this.history) {
|
|
176
|
+
registry.subscribe(this, (state) => {
|
|
177
|
+
this.start = state.start;
|
|
178
|
+
this.userParams = state;
|
|
179
|
+
this.load();
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
177
183
|
this.signalReady();
|
|
178
184
|
}
|
|
179
185
|
|
|
180
186
|
firstUpdated() {
|
|
181
187
|
if (this.auto) {
|
|
182
|
-
this.start =
|
|
183
|
-
|
|
188
|
+
this.start = registry.state.start || 1;
|
|
189
|
+
waitOnce('pb-page-ready', (data) => {
|
|
184
190
|
if (data && data.language) {
|
|
185
191
|
this.language = data.language;
|
|
186
192
|
}
|
|
187
193
|
this.wait(() => this.load());
|
|
188
194
|
});
|
|
189
195
|
} else {
|
|
190
|
-
|
|
196
|
+
waitOnce('pb-page-ready', (data) => {
|
|
191
197
|
if (data && data.language) {
|
|
192
198
|
this.language = data.language;
|
|
193
199
|
}
|
|
@@ -203,7 +209,7 @@ export class PbLoad extends pbMixin(LitElement) {
|
|
|
203
209
|
case 'userParams':
|
|
204
210
|
case 'start':
|
|
205
211
|
if (this.auto && this.loader) {
|
|
206
|
-
|
|
212
|
+
waitOnce('pb-page-ready', () => {
|
|
207
213
|
this.wait(() => this.load());
|
|
208
214
|
});
|
|
209
215
|
}
|
|
@@ -246,9 +252,12 @@ export class PbLoad extends pbMixin(LitElement) {
|
|
|
246
252
|
}
|
|
247
253
|
|
|
248
254
|
toggleFeature(ev) {
|
|
249
|
-
this.userParams =
|
|
255
|
+
this.userParams = registry.getState(this);
|
|
250
256
|
console.log('<pb-load> toggle feature %o', this.userParams);
|
|
251
|
-
if (ev.detail.
|
|
257
|
+
if (ev.detail.refresh) {
|
|
258
|
+
if (this.history) {
|
|
259
|
+
registry.commit(this, this.userParams);
|
|
260
|
+
}
|
|
252
261
|
this.load();
|
|
253
262
|
}
|
|
254
263
|
}
|
|
@@ -410,6 +419,7 @@ export class PbLoad extends pbMixin(LitElement) {
|
|
|
410
419
|
this.emitTo('pb-results-received', {
|
|
411
420
|
"count": total ? parseInt(total, 10) : 0,
|
|
412
421
|
"start": this.start,
|
|
422
|
+
"content": content,
|
|
413
423
|
"params": this.shadowRoot.getElementById('loadContent').params
|
|
414
424
|
});
|
|
415
425
|
}
|
package/src/pb-login.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin.js';
|
|
2
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
3
|
import { translate } from "./pb-i18n.js";
|
|
4
4
|
import '@polymer/iron-ajax';
|
|
5
5
|
import '@polymer/paper-dialog';
|
|
@@ -117,7 +117,7 @@ export class PbLogin extends pbMixin(LitElement) {
|
|
|
117
117
|
this._checkLogin.generateRequest();
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
|
-
|
|
120
|
+
waitOnce('pb-page-ready', (detail) => {
|
|
121
121
|
if (minVersion(detail.apiVersion, '1.0.0')) {
|
|
122
122
|
this._checkLogin.url = `${detail.endpoint}/api/login/`;
|
|
123
123
|
} else {
|
package/src/pb-manage-odds.js
CHANGED
|
@@ -7,7 +7,7 @@ import '@polymer/paper-button';
|
|
|
7
7
|
import '@polymer/paper-icon-button';
|
|
8
8
|
import '@polymer/paper-input/paper-input.js';
|
|
9
9
|
import '@polymer/app-layout/app-toolbar/app-toolbar.js';
|
|
10
|
-
import { pbMixin } from './pb-mixin.js';
|
|
10
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
11
11
|
import { translate } from './pb-i18n.js';
|
|
12
12
|
import './pb-restricted.js';
|
|
13
13
|
import './pb-ajax.js';
|
|
@@ -73,7 +73,7 @@ export class PbManageOdds extends pbMixin(LitElement) {
|
|
|
73
73
|
|
|
74
74
|
this._loader = this.shadowRoot.getElementById('load');
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
waitOnce('pb-page-ready', (options) => {
|
|
77
77
|
if (cmpVersion(options.apiVersion, '1.0.0') < 0) {
|
|
78
78
|
this._loader.url = `${options.endpoint}/modules/lib/components-odd.xql`;
|
|
79
79
|
} else {
|
package/src/pb-markdown.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
3
|
-
import { pbMixin } from './pb-mixin';
|
|
3
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
4
4
|
import * as marked from 'marked/lib/marked.js';
|
|
5
5
|
import './pb-code-highlight.js';
|
|
6
6
|
|
|
@@ -71,7 +71,7 @@ export class PbMarkdown extends pbMixin(LitElement) {
|
|
|
71
71
|
|
|
72
72
|
set url(value) {
|
|
73
73
|
this._url = value;
|
|
74
|
-
|
|
74
|
+
waitOnce("pb-page-ready", (options) => {
|
|
75
75
|
this._load(options.endpoint);
|
|
76
76
|
});
|
|
77
77
|
}
|
package/src/pb-mei.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
3
3
|
import "@lrnwebcomponents/es-global-bridge";
|
|
4
|
-
import { pbMixin } from './pb-mixin.js';
|
|
4
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
5
5
|
import { translate } from './pb-i18n.js';
|
|
6
6
|
import '@polymer/paper-icon-button';
|
|
7
7
|
import '@polymer/paper-checkbox';
|
|
@@ -145,7 +145,7 @@ export class PbMei extends pbMixin(LitElement) {
|
|
|
145
145
|
.then(() => {
|
|
146
146
|
this._verovio = new window.verovio.toolkit();
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
waitOnce('pb-page-ready', () => {
|
|
149
149
|
this.load();
|
|
150
150
|
});
|
|
151
151
|
});
|