@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-mixin.js
CHANGED
|
@@ -18,6 +18,8 @@ const readyEventsFired = new Set();
|
|
|
18
18
|
*/
|
|
19
19
|
const initEventsFired = new Map();
|
|
20
20
|
|
|
21
|
+
export const defaultChannel = '__default__';
|
|
22
|
+
|
|
21
23
|
export function clearPageEvents() {
|
|
22
24
|
initEventsFired.clear();
|
|
23
25
|
}
|
|
@@ -43,6 +45,46 @@ export function waitOnce(name, callback) {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Get the list of channels this element emits to.
|
|
50
|
+
*
|
|
51
|
+
* @param {HTMLElement} elem the emitting element
|
|
52
|
+
* @returns {String[]} an array of channel names
|
|
53
|
+
*/
|
|
54
|
+
export function getEmittedChannels(elem) {
|
|
55
|
+
const emitConfig = elem.getAttribute('emit-config');
|
|
56
|
+
if (emitConfig) {
|
|
57
|
+
const json = JSON.parse(emitConfig);
|
|
58
|
+
return Object.keys(json);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const emitAttr = elem.getAttribute('emit');
|
|
62
|
+
if (emitAttr) {
|
|
63
|
+
return [emitAttr]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return [defaultChannel];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get the list of channels this element subscribes to.
|
|
71
|
+
*
|
|
72
|
+
* @param {HTMLElement} elem the subscribing element
|
|
73
|
+
* @returns {String[]} an array of channel names
|
|
74
|
+
*/
|
|
75
|
+
export function getSubscribedChannels(elem) {
|
|
76
|
+
const subscribeConfig = elem.getAttribute('subscribe-config');
|
|
77
|
+
if (subscribeConfig) {
|
|
78
|
+
const json = JSON.parse(subscribeConfig);
|
|
79
|
+
return Object.keys(json);
|
|
80
|
+
}
|
|
81
|
+
const subscribeAttr = elem.getAttribute('subscribe');
|
|
82
|
+
if (subscribeAttr) {
|
|
83
|
+
return [subscribeAttr];
|
|
84
|
+
}
|
|
85
|
+
return [defaultChannel];
|
|
86
|
+
}
|
|
87
|
+
|
|
46
88
|
/**
|
|
47
89
|
* Implements the core channel/event mechanism used by components in TEI Publisher
|
|
48
90
|
* to communicate.
|
|
@@ -168,41 +210,42 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
|
|
|
168
210
|
* to signal that they are ready to respond to events. Only wait for elements which
|
|
169
211
|
* emit to one of the channels this component subscribes to.
|
|
170
212
|
*
|
|
171
|
-
* @param callback function to be called when all components are ready
|
|
213
|
+
* @param {Function} callback function to be called when all components are ready
|
|
172
214
|
*/
|
|
173
215
|
wait(callback) {
|
|
174
|
-
if (this.waitFor) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
216
|
+
if (!this.waitFor) {
|
|
217
|
+
callback();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const targetNodes = Array.from(document.querySelectorAll(this.waitFor));
|
|
221
|
+
const targets = targetNodes.filter(target => this.emitsOnSameChannel(target));
|
|
222
|
+
const targetCount = targets.length;
|
|
223
|
+
if (targetCount === 0) {
|
|
224
|
+
// selector did not return any targets
|
|
225
|
+
callback();
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
let count = targetCount;
|
|
229
|
+
targets.forEach((target) => {
|
|
230
|
+
if (target._isReady) {
|
|
231
|
+
count -= 1;
|
|
232
|
+
if (count === 0) {
|
|
233
|
+
callback();
|
|
234
|
+
}
|
|
235
|
+
return;
|
|
181
236
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (ev.detail.source == this) {
|
|
192
|
-
// same source: ignore
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
count++;
|
|
196
|
-
if (targetCount === count) {
|
|
197
|
-
target.removeEventListener('pb-ready', handler);
|
|
198
|
-
callback();
|
|
199
|
-
}
|
|
200
|
-
});
|
|
237
|
+
const handler = target.addEventListener('pb-ready', (ev) => {
|
|
238
|
+
if (ev.detail.source === this) {
|
|
239
|
+
// same source: ignore
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
count -= 1;
|
|
243
|
+
if (count === 0) {
|
|
244
|
+
target.removeEventListener('pb-ready', handler);
|
|
245
|
+
callback();
|
|
201
246
|
}
|
|
202
247
|
});
|
|
203
|
-
}
|
|
204
|
-
callback();
|
|
205
|
-
}
|
|
248
|
+
});
|
|
206
249
|
}
|
|
207
250
|
|
|
208
251
|
/**
|
|
@@ -262,23 +305,6 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
|
|
|
262
305
|
this.emitTo(name, data);
|
|
263
306
|
}
|
|
264
307
|
|
|
265
|
-
/**
|
|
266
|
-
* Get the list of channels this element subscribes to.
|
|
267
|
-
*
|
|
268
|
-
* @returns an array of channel names
|
|
269
|
-
*/
|
|
270
|
-
getSubscribedChannels() {
|
|
271
|
-
const chs = [];
|
|
272
|
-
if (this.subscribeConfig) {
|
|
273
|
-
Object.keys(this.subscribeConfig).forEach((key) => {
|
|
274
|
-
chs.push(key);
|
|
275
|
-
});
|
|
276
|
-
} else if (this.subscribe) {
|
|
277
|
-
chs.push(this.subscribe);
|
|
278
|
-
}
|
|
279
|
-
return chs;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
308
|
/**
|
|
283
309
|
* Check if the other element emits to one of the channels this
|
|
284
310
|
* element subscribes to.
|
|
@@ -286,8 +312,8 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
|
|
|
286
312
|
* @param {Element} other the other element to compare with
|
|
287
313
|
*/
|
|
288
314
|
emitsOnSameChannel(other) {
|
|
289
|
-
const myChannels =
|
|
290
|
-
const otherChannels =
|
|
315
|
+
const myChannels = getSubscribedChannels(this);
|
|
316
|
+
const otherChannels = getEmittedChannels(other);
|
|
291
317
|
if (myChannels.length === 0 && otherChannels.length === 0) {
|
|
292
318
|
// both emit to the default channel
|
|
293
319
|
return true;
|
|
@@ -295,28 +321,6 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
|
|
|
295
321
|
return myChannels.some((channel) => otherChannels.includes(channel));
|
|
296
322
|
}
|
|
297
323
|
|
|
298
|
-
/**
|
|
299
|
-
* Get the list of channels this element emits to.
|
|
300
|
-
*
|
|
301
|
-
* @returns an array of channel names
|
|
302
|
-
*/
|
|
303
|
-
static getEmittedChannels(elem) {
|
|
304
|
-
const chs = [];
|
|
305
|
-
const emitConfig = elem.getAttribute('emit-config');
|
|
306
|
-
if (emitConfig) {
|
|
307
|
-
const json = JSON.parse(emitConfig);
|
|
308
|
-
Object.keys(json).forEach(key => {
|
|
309
|
-
chs.push(key);
|
|
310
|
-
});
|
|
311
|
-
} else {
|
|
312
|
-
const emitAttr = elem.getAttribute('emit');
|
|
313
|
-
if (emitAttr) {
|
|
314
|
-
chs.push(emitAttr);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
return chs;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
324
|
/**
|
|
321
325
|
* Listen to the event defined by type. If property `subscribe` or `subscribe-config`
|
|
322
326
|
* is defined, this method will trigger the listener only if the event has a key
|
|
@@ -324,33 +328,21 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
|
|
|
324
328
|
*
|
|
325
329
|
* @param {String} type Name of the event, usually starting with `pb-`
|
|
326
330
|
* @param {Function} listener Callback function
|
|
327
|
-
* @param {
|
|
331
|
+
* @param {String[]} [channels] Optional: explicitely specify the channels to emit to. This overwrites
|
|
328
332
|
* the emit property. Pass empty array to target the default channel.
|
|
329
333
|
*/
|
|
330
|
-
subscribeTo(type, listener, channels) {
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
const handle = (ev) => {
|
|
336
|
-
if (ev.detail && ev.detail.key) {
|
|
334
|
+
subscribeTo(type, listener, channels = []) {
|
|
335
|
+
const chs = channels && channels.length ? channels : getSubscribedChannels(this);
|
|
336
|
+
const handlers = chs.map(key => {
|
|
337
|
+
const handle = ev => {
|
|
338
|
+
if (!ev.detail || !ev.detail.key || ev.detail.key !== key) {
|
|
337
339
|
return;
|
|
338
340
|
}
|
|
339
341
|
listener(ev);
|
|
340
342
|
};
|
|
341
343
|
document.addEventListener(type, handle);
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
handlers = chs.map(key => {
|
|
345
|
-
const handle = ev => {
|
|
346
|
-
if (ev.detail && ev.detail.key && ev.detail.key === key) {
|
|
347
|
-
listener(ev);
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
document.addEventListener(type, handle);
|
|
351
|
-
return handle;
|
|
352
|
-
});
|
|
353
|
-
}
|
|
344
|
+
return handle;
|
|
345
|
+
});
|
|
354
346
|
// add new handlers to list of active subscriptions
|
|
355
347
|
this._subscriptions.set(type, handlers);
|
|
356
348
|
return handlers;
|
|
@@ -362,50 +354,27 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
|
|
|
362
354
|
*
|
|
363
355
|
* @param {String} type Name of the event, usually starting with `pb-`
|
|
364
356
|
* @param {Object} [options] Options to be passed in ev.detail
|
|
365
|
-
* @param {
|
|
357
|
+
* @param {String[]} [channels] Optional: explicitely specify the channels to emit to. This overwrites
|
|
366
358
|
* the 'emit' property setting. Pass empty array to target the default channel.
|
|
367
359
|
*/
|
|
368
|
-
emitTo(type, options, channels) {
|
|
369
|
-
const chs = channels
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
} else {
|
|
377
|
-
options = { _source: this };
|
|
378
|
-
}
|
|
379
|
-
const ev = new CustomEvent(type, {
|
|
380
|
-
detail: options,
|
|
381
|
-
composed: true,
|
|
382
|
-
bubbles: true
|
|
383
|
-
});
|
|
384
|
-
this.dispatchEvent(ev);
|
|
385
|
-
} else {
|
|
386
|
-
chs.forEach(key => {
|
|
387
|
-
const detail = {
|
|
388
|
-
key: key,
|
|
389
|
-
_source: this
|
|
390
|
-
};
|
|
391
|
-
if (options) {
|
|
392
|
-
for (const opt in options) {
|
|
393
|
-
if (options.hasOwnProperty(opt)) {
|
|
394
|
-
detail[opt] = options[opt];
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
if (type === 'pb-ready') {
|
|
399
|
-
readyEventsFired.add(key);
|
|
400
|
-
}
|
|
401
|
-
const ev = new CustomEvent(type, {
|
|
402
|
-
detail: detail,
|
|
403
|
-
composed: true,
|
|
404
|
-
bubbles: true
|
|
405
|
-
});
|
|
406
|
-
this.dispatchEvent(ev);
|
|
407
|
-
});
|
|
360
|
+
emitTo(type, options, channels = []) {
|
|
361
|
+
const chs = channels && channels.length ? channels : getEmittedChannels(this);
|
|
362
|
+
chs.forEach(ch => this._emit(ch, type, options));
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
_emit(key, type, options) {
|
|
366
|
+
if (type === 'pb-ready') {
|
|
367
|
+
readyEventsFired.add(key);
|
|
408
368
|
}
|
|
369
|
+
|
|
370
|
+
// eslint-disable-next-line prefer-object-spread
|
|
371
|
+
const detail = Object.assign({ key, _source: this }, options);
|
|
372
|
+
const ev = new CustomEvent(type, {
|
|
373
|
+
detail,
|
|
374
|
+
composed: true,
|
|
375
|
+
bubbles: true
|
|
376
|
+
});
|
|
377
|
+
this.dispatchEvent(ev);
|
|
409
378
|
}
|
|
410
379
|
|
|
411
380
|
/**
|
|
@@ -427,38 +396,12 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
|
|
|
427
396
|
const params = TeiPublisher.url.searchParams && TeiPublisher.url.searchParams.getAll(name);
|
|
428
397
|
if (params && params.length == 1) {
|
|
429
398
|
return params[0];
|
|
430
|
-
}else if (params && params.length > 1) {
|
|
399
|
+
} else if (params && params.length > 1) {
|
|
431
400
|
return params
|
|
432
401
|
}
|
|
433
402
|
return fallback;
|
|
434
403
|
}
|
|
435
404
|
|
|
436
|
-
getParameterValues(name) {
|
|
437
|
-
return TeiPublisher.url.searchParams.getAll(name);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
setParameter(name, value) {
|
|
441
|
-
if (typeof value === 'undefined') {
|
|
442
|
-
TeiPublisher.url.searchParams.delete(name);
|
|
443
|
-
} else if (Array.isArray(value)) {
|
|
444
|
-
TeiPublisher.url.searchParams.delete(name);
|
|
445
|
-
value.forEach(function (val) {
|
|
446
|
-
TeiPublisher.url.searchParams.append(name, val);
|
|
447
|
-
});
|
|
448
|
-
} else {
|
|
449
|
-
TeiPublisher.url.searchParams.set(name, value);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
setParameters(obj) {
|
|
454
|
-
TeiPublisher.url.search = '';
|
|
455
|
-
for (let key in obj) {
|
|
456
|
-
if (obj.hasOwnProperty(key)) {
|
|
457
|
-
this.setParameter(key, obj[key]);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
405
|
getParameters() {
|
|
463
406
|
const params = {};
|
|
464
407
|
for (let key of TeiPublisher.url.searchParams.keys()) {
|
|
@@ -467,46 +410,10 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
|
|
|
467
410
|
return params;
|
|
468
411
|
}
|
|
469
412
|
|
|
470
|
-
getParametersMatching(regex) {
|
|
471
|
-
const params = {};
|
|
472
|
-
for (let pair of TeiPublisher.url.searchParams.entries()) {
|
|
473
|
-
if (regex.test(pair[0])) {
|
|
474
|
-
const param = params[pair[0]];
|
|
475
|
-
if (param) {
|
|
476
|
-
param.push(pair[1]);
|
|
477
|
-
} else {
|
|
478
|
-
params[pair[0]] = [pair[1]];
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
return params;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
clearParametersMatching(regex) {
|
|
486
|
-
for (let pair of TeiPublisher.url.searchParams.entries()) {
|
|
487
|
-
if (regex.test(pair[0])) {
|
|
488
|
-
TeiPublisher.url.searchParams.delete(pair[0]);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
setPath(path) {
|
|
494
|
-
const page = document.querySelector('pb-page');
|
|
495
|
-
if (page) {
|
|
496
|
-
const appRoot = page.appRoot;
|
|
497
|
-
|
|
498
|
-
this.getUrl().pathname = appRoot + '/' + path;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
413
|
getUrl() {
|
|
503
414
|
return TeiPublisher.url;
|
|
504
415
|
}
|
|
505
416
|
|
|
506
|
-
pushHistory(msg, state) {
|
|
507
|
-
history.pushState(state, msg, TeiPublisher.url.toString());
|
|
508
|
-
}
|
|
509
|
-
|
|
510
417
|
getEndpoint() {
|
|
511
418
|
return this._endpoint;
|
|
512
419
|
}
|
|
@@ -519,7 +426,7 @@ export const pbMixin = (superclass) => class PbMixin extends superclass {
|
|
|
519
426
|
let base;
|
|
520
427
|
if (endpoint === '.') {
|
|
521
428
|
base = new URL(window.location.href);
|
|
522
|
-
|
|
429
|
+
// loaded in iframe
|
|
523
430
|
} else if (window.location.protocol === 'about:') {
|
|
524
431
|
base = document.baseURI
|
|
525
432
|
} else {
|
package/src/pb-odd-editor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { LitElement, html, css } from 'lit-element'
|
|
3
|
-
import { pbMixin } from './pb-mixin.js';
|
|
3
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
4
4
|
import { pbHotkeys } from './pb-hotkeys.js';
|
|
5
5
|
import { repeat } from 'lit-html/directives/repeat';
|
|
6
6
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
@@ -433,7 +433,7 @@ export class PbOddEditor extends pbHotkeys(pbMixin(LitElement)) {
|
|
|
433
433
|
// it is unclear to me why root-path is not read from attribute without this explicit call
|
|
434
434
|
this.rootPath = this.getAttribute('root-path');
|
|
435
435
|
|
|
436
|
-
|
|
436
|
+
waitOnce('pb-page-ready', () => {
|
|
437
437
|
this.load();
|
|
438
438
|
this.inited = true;
|
|
439
439
|
});
|
package/src/pb-page.js
CHANGED
|
@@ -8,6 +8,7 @@ import { resolveURL } from './utils.js';
|
|
|
8
8
|
import { loadStylesheets } from "./theming.js";
|
|
9
9
|
import { initTranslation } from "./pb-i18n.js";
|
|
10
10
|
import { typesetMath } from "./pb-formula.js";
|
|
11
|
+
import { registry } from "./urls.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Make sure there's only one instance of pb-page active at any time.
|
|
@@ -38,6 +39,10 @@ export class PbPage extends pbMixin(LitElement) {
|
|
|
38
39
|
type: String,
|
|
39
40
|
attribute: 'app-root'
|
|
40
41
|
},
|
|
42
|
+
urlPath: {
|
|
43
|
+
type: String,
|
|
44
|
+
attribute: 'url-path'
|
|
45
|
+
},
|
|
41
46
|
/**
|
|
42
47
|
* TEI Publisher internal: set to the current page template.
|
|
43
48
|
*/
|
|
@@ -142,6 +147,7 @@ export class PbPage extends pbMixin(LitElement) {
|
|
|
142
147
|
super();
|
|
143
148
|
this.unresolved = true;
|
|
144
149
|
this.endpoint = ".";
|
|
150
|
+
this.urlPath = 'path';
|
|
145
151
|
this.apiVersion = undefined;
|
|
146
152
|
this.requireLanguage = false;
|
|
147
153
|
this.theme = null;
|
|
@@ -179,6 +185,12 @@ export class PbPage extends pbMixin(LitElement) {
|
|
|
179
185
|
return;
|
|
180
186
|
}
|
|
181
187
|
|
|
188
|
+
if (!this.appRoot) {
|
|
189
|
+
this.appRoot = window.location.pathname;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
registry.configure(this.urlPath === 'path', this.appRoot);
|
|
193
|
+
|
|
182
194
|
this.endpoint = this.endpoint.replace(/\/+$/, '');
|
|
183
195
|
|
|
184
196
|
if (this.locales && this._localeFallbacks.indexOf('app') === -1) {
|
|
@@ -186,12 +198,12 @@ export class PbPage extends pbMixin(LitElement) {
|
|
|
186
198
|
}
|
|
187
199
|
this._localeFallbacks.push('common');
|
|
188
200
|
|
|
189
|
-
const target =
|
|
201
|
+
const target = registry.state._target;
|
|
190
202
|
if (target) {
|
|
191
203
|
this.endpoint = target;
|
|
192
204
|
}
|
|
193
205
|
|
|
194
|
-
const apiVersion =
|
|
206
|
+
const apiVersion = registry.state._api;
|
|
195
207
|
if (apiVersion) {
|
|
196
208
|
this.apiVersion = apiVersion;
|
|
197
209
|
}
|
|
@@ -325,14 +337,14 @@ export class PbPage extends pbMixin(LitElement) {
|
|
|
325
337
|
this.subscribeTo('pb-i18n-language', ev => {
|
|
326
338
|
const { language } = ev.detail;
|
|
327
339
|
this._i18nInstance.changeLanguage(language).then(t => {
|
|
328
|
-
|
|
329
|
-
|
|
340
|
+
this._updateI18n(t);
|
|
341
|
+
this.emitTo('pb-i18n-update', { t, language: this._i18nInstance.language }, []);
|
|
330
342
|
}, []);
|
|
331
343
|
});
|
|
332
344
|
|
|
333
345
|
|
|
334
|
-
this.subscribeTo('pb-toggle', this._toggleFeatures.bind(this));
|
|
335
|
-
|
|
346
|
+
// this.subscribeTo('pb-global-toggle', this._toggleFeatures.bind(this));
|
|
347
|
+
this.addEventListener('pb-global-toggle', this._toggleFeatures.bind(this));
|
|
336
348
|
this.unresolved = false;
|
|
337
349
|
|
|
338
350
|
console.log('<pb-page> endpoint: %s; trigger window resize', this.endpoint);
|
|
@@ -367,21 +379,18 @@ export class PbPage extends pbMixin(LitElement) {
|
|
|
367
379
|
* and dispatch actions to the elements on the page.
|
|
368
380
|
*/
|
|
369
381
|
_toggleFeatures(ev) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
}
|
|
382
|
+
const sc = ev.detail;
|
|
383
|
+
this.querySelectorAll(sc.selector).forEach(node => {
|
|
384
|
+
const command = sc.command || 'toggle';
|
|
385
|
+
if (node.command) {
|
|
386
|
+
node.command(command, sc.state);
|
|
387
|
+
}
|
|
388
|
+
if (sc.state) {
|
|
389
|
+
node.classList.add(command);
|
|
390
|
+
} else {
|
|
391
|
+
node.classList.remove(command);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
385
394
|
}
|
|
386
395
|
|
|
387
396
|
render() {
|
package/src/pb-paginate.js
CHANGED
|
@@ -168,35 +168,40 @@ export class PbPaginate extends pbMixin(LitElement) {
|
|
|
168
168
|
|
|
169
169
|
_handleClick(item, index) {
|
|
170
170
|
this.start = (this.pages[index].label - 1) * this.perPage + 1;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
['pb-load', 'pb-paginate'].forEach((ev) => {
|
|
172
|
+
this.emitTo(ev, {
|
|
173
|
+
"params": {
|
|
174
|
+
"start": this.start,
|
|
175
|
+
"per-page": this.perPage,
|
|
176
|
+
"page": index
|
|
177
|
+
}
|
|
178
|
+
});
|
|
177
179
|
});
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
_handleFirst(ev) {
|
|
181
183
|
this.start = 1;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
['pb-load', 'pb-paginate'].forEach((event) => {
|
|
185
|
+
this.emitTo(event, {
|
|
186
|
+
"params": {
|
|
187
|
+
"start": 1,
|
|
188
|
+
"per-page": this.perPage,
|
|
189
|
+
"page": 0
|
|
190
|
+
}
|
|
191
|
+
});
|
|
188
192
|
});
|
|
189
193
|
}
|
|
190
194
|
|
|
191
195
|
_handleLast(ev) {
|
|
192
196
|
this.start = (this.pageCount - 1) * this.perPage + 1;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
['pb-load', 'pb-paginate'].forEach((event) => {
|
|
198
|
+
this.emitTo(event, {
|
|
199
|
+
"params": {
|
|
200
|
+
"start": this.start,
|
|
201
|
+
"per-page": this.perPage,
|
|
202
|
+
"page": this.pageCount - 1
|
|
203
|
+
}
|
|
204
|
+
});
|
|
200
205
|
});
|
|
201
206
|
}
|
|
202
207
|
}
|
package/src/pb-print-preview.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 { resolveURL } from './utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -65,7 +65,7 @@ export class PbPrintPreview extends pbMixin(LitElement) {
|
|
|
65
65
|
this.emitTo('pb-end-update');
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
waitOnce('pb-page-ready', () => {
|
|
69
69
|
this.refresh();
|
|
70
70
|
});
|
|
71
71
|
}
|
package/src/pb-repeat.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement, html } from 'lit-element';
|
|
2
2
|
import { pbMixin } from './pb-mixin.js';
|
|
3
|
+
import { registry } from "./urls.js";
|
|
3
4
|
import '@polymer/iron-icons';
|
|
4
5
|
import '@polymer/paper-icon-button';
|
|
5
6
|
|
|
@@ -42,7 +43,7 @@ export class PbRepeat extends pbMixin(LitElement) {
|
|
|
42
43
|
|
|
43
44
|
this.template = this.querySelector('template');
|
|
44
45
|
|
|
45
|
-
const params =
|
|
46
|
+
const params = registry.state;
|
|
46
47
|
this._computeInitial(params);
|
|
47
48
|
if (this._instances.length === 0) {
|
|
48
49
|
for (let i = 0; i < this.initial; i++) {
|