@teipublisher/pb-components 1.44.2 → 2.1.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/dist/demo/demos.json +6 -1
  3. package/dist/demo/pb-browse-docs.html +2 -1
  4. package/dist/demo/pb-combo-box.html +1 -1
  5. package/dist/demo/pb-document.html +2 -2
  6. package/dist/demo/pb-image-strip-standalone.html +94 -0
  7. package/dist/demo/pb-image-strip-view.html +92 -0
  8. package/dist/demo/pb-load.html +2 -2
  9. package/dist/demo/pb-select-feature.html +1 -1
  10. package/dist/demo/pb-select-feature2.html +10 -3
  11. package/dist/demo/pb-select-feature3.html +1 -1
  12. package/dist/demo/pb-select-odd.html +1 -1
  13. package/dist/demo/pb-table-grid.html +1 -1
  14. package/dist/demo/pb-tabs.html +8 -2
  15. package/dist/demo/pb-toggle-feature.html +2 -2
  16. package/dist/demo/pb-toggle-feature2.html +2 -2
  17. package/dist/demo/pb-toggle-feature3.html +2 -2
  18. package/dist/demo/pb-view.html +1 -1
  19. package/dist/demo/pb-view4.html +86 -0
  20. package/dist/pb-code-editor.js +1 -1
  21. package/dist/pb-component-docs.js +33 -33
  22. package/dist/pb-components-bundle.js +271 -261
  23. package/dist/pb-edit-app.js +6 -6
  24. package/dist/pb-elements.json +248 -29
  25. package/dist/{pb-i18n-3963b098.js → pb-i18n-8a90c591.js} +1 -1
  26. package/dist/pb-leaflet-map.js +1 -1
  27. package/dist/pb-mixin-8a593923.js +158 -0
  28. package/dist/pb-odd-editor.js +47 -47
  29. package/dist/{vaadin-element-mixin-08cf11b5.js → vaadin-element-mixin-672938e3.js} +18 -18
  30. package/i18n/common/en.json +9 -1
  31. package/package.json +4 -3
  32. package/pb-elements.json +248 -29
  33. package/src/dts-client.js +14 -14
  34. package/src/dts-select-endpoint.js +5 -5
  35. package/src/pb-ajax.js +4 -4
  36. package/src/pb-authority-lookup.js +2 -2
  37. package/src/pb-autocomplete.js +9 -11
  38. package/src/pb-blacklab-highlight.js +3 -3
  39. package/src/pb-browse-docs.js +44 -27
  40. package/src/pb-browse.js +9 -3
  41. package/src/pb-combo-box.js +2 -2
  42. package/src/pb-components.js +1 -0
  43. package/src/pb-document.js +15 -1
  44. package/src/pb-download.js +2 -2
  45. package/src/pb-edit-app.js +2 -2
  46. package/src/pb-edit-xml.js +2 -2
  47. package/src/pb-events.js +26 -18
  48. package/src/pb-facs-link.js +33 -9
  49. package/src/pb-facsimile.js +34 -31
  50. package/src/pb-grid.js +55 -53
  51. package/src/pb-image-strip.js +97 -0
  52. package/src/pb-lang.js +2 -2
  53. package/src/pb-link.js +10 -16
  54. package/src/pb-load.js +35 -25
  55. package/src/pb-login.js +2 -2
  56. package/src/pb-manage-odds.js +2 -2
  57. package/src/pb-markdown.js +2 -2
  58. package/src/pb-mei.js +2 -2
  59. package/src/pb-mixin.js +103 -196
  60. package/src/pb-odd-editor.js +2 -2
  61. package/src/pb-page.js +30 -21
  62. package/src/pb-paginate.js +24 -19
  63. package/src/pb-print-preview.js +2 -2
  64. package/src/pb-repeat.js +2 -1
  65. package/src/pb-search.js +34 -8
  66. package/src/pb-select-feature.js +62 -39
  67. package/src/pb-select-odd.js +8 -7
  68. package/src/pb-select-template.js +5 -4
  69. package/src/pb-select.js +31 -28
  70. package/src/pb-split-list.js +18 -11
  71. package/src/pb-table-grid.js +9 -8
  72. package/src/pb-tabs.js +29 -12
  73. package/src/pb-toggle-feature.js +51 -55
  74. package/src/pb-upload.js +10 -3
  75. package/src/pb-view.js +118 -95
  76. package/src/theming.js +148 -149
  77. package/src/urls.js +233 -0
  78. package/dist/pb-mixin-88125cb2.js +0 -158
@@ -1,7 +1,11 @@
1
1
  import { html, css } from 'lit-element';
2
2
  import { PbLoad } from './pb-load.js';
3
+ import { waitOnce } from './pb-mixin.js';
3
4
  import { translate } from "./pb-i18n.js";
4
5
  import { themableMixin } from "./theming.js";
6
+ import { cmpVersion } from './utils.js';
7
+ import { registry } from "./urls.js";
8
+
5
9
  import '@polymer/paper-input/paper-input.js';
6
10
  import '@polymer/paper-button';
7
11
  import '@polymer/paper-dropdown-menu/paper-dropdown-menu.js';
@@ -10,7 +14,6 @@ import '@polymer/paper-dialog';
10
14
  import '@polymer/paper-dialog-scrollable';
11
15
  import '@polymer/iron-ajax';
12
16
  import '@cwmr/paper-autocomplete/paper-autocomplete-suggestions.js';
13
- import { cmpVersion } from './utils.js';
14
17
 
15
18
  /**
16
19
  * Component to browse through a collection of documents with sorting, filtering and facets.
@@ -135,21 +138,43 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
135
138
  connectedCallback() {
136
139
  super.connectedCallback();
137
140
 
138
- const sortParam = this.getParameter('sort');
139
- if (sortParam) {
140
- this.sortBy = sortParam;
141
- }
141
+ waitOnce('pb-page-ready', () => {
142
+ if (registry.state.sort) {
143
+ this.sortBy = registry.state.sort;
144
+ }
142
145
 
143
- const filterParam = this.getParameter('filter');
144
- if (filterParam) {
145
- this.filter = filterParam;
146
- this.filterBy = this.getParameter('filterBy', this.filterBy);
147
- }
146
+ if (registry.state.filter) {
147
+ this.filter = registry.state.filter;
148
+ this.filterBy = registry.state.filterBy || this.filterBy;
149
+ }
148
150
 
149
- this.facets = this.getParametersMatching(/^facet-.*$/);
151
+ this.facets = {};
152
+ // registry get state by regex
153
+ // this.facets = registry.getParametersMatching(this, /^facet-.*$/)
154
+ Object.keys(registry.state).forEach((key) => {
155
+ if (/^facet-.*$/.test(key)) {
156
+ const param = registry.state[key];
157
+ if (this.facets[key]) {
158
+ this.facets[key].push(param);
159
+ } else {
160
+ this.facets[key] = [param];
161
+ }
162
+ }
163
+ });
150
164
 
151
- this.collection = this.getParameter('collection');
165
+ this.collection = registry.state.collection;
152
166
 
167
+ if (this.collection) {
168
+ registry.replace(this, {
169
+ collection: this.collection
170
+ });
171
+ }
172
+ registry.subscribe(this, (state) => {
173
+ this.collection = state.collection;
174
+ this.load();
175
+ });
176
+ });
177
+
153
178
  this.subscribeTo('pb-search-resubmit', this._facets.bind(this));
154
179
  this.subscribeTo('pb-login', (ev) => {
155
180
  if (ev.detail.userChanged) {
@@ -171,7 +196,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
171
196
  }
172
197
 
173
198
  firstUpdated() {
174
- PbBrowseDocs.waitOnce('pb-page-ready', (options) => {
199
+ waitOnce('pb-page-ready', (options) => {
175
200
  const loader = this.shadowRoot.getElementById('autocompleteLoader');
176
201
  if (cmpVersion(options.apiVersion, '1.0.0') >= 0) {
177
202
  loader.url = `${options.endpoint}/api/search/autocomplete`;
@@ -384,10 +409,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
384
409
  if (typeof filter !== 'undefined') {
385
410
  console.log('<pb-browse-docs> Filter by %s', filter);
386
411
  this.filter = filter;
387
- this.setParameter('filter', filter);
388
- this.setParameter('filterBy', filterBy);
389
- this.pushHistory('filter docs');
390
-
412
+ registry.commit(this, { filter, filterBy })
391
413
  this.load();
392
414
  }
393
415
  }
@@ -405,8 +427,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
405
427
  if (sortBy && sortBy !== this.sortBy) {
406
428
  console.log('<pb-browse-docs> Sorting by %s', sortBy);
407
429
  this.sortBy = sortBy;
408
- this.setParameter('sort', sortBy);
409
- this.pushHistory('sort docs');
430
+ registry.commit(this, { sort: sortBy })
410
431
 
411
432
  this.load();
412
433
  }
@@ -414,13 +435,10 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
414
435
 
415
436
  _facets(ev) {
416
437
  if (ev.detail && ev.detail.params) {
417
- this.clearParametersMatching(/^(all-|facet-).*/);
418
- for (let param in ev.detail.params) {
419
- this.setParameter(param, ev.detail.params[param]);
420
- }
438
+ registry.clearParametersMatching(this, /^(all-|facet-).*/);
421
439
  this.facets = ev.detail.params;
422
440
  this.start = 1;
423
- this.pushHistory('facets');
441
+ registry.commit(this, ev.detail.params)
424
442
  }
425
443
  this.load();
426
444
  }
@@ -442,8 +460,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
442
460
  ev.preventDefault();
443
461
  this.collection = link.getAttribute('data-collection');
444
462
  this.start = 1;
445
- this.setParameter('collection', this.collection);
446
- this.pushHistory('browse collection');
463
+ registry.commit(this, { collection: this.collection });
447
464
  console.log('<pb-browse-docs> loading collection %s', this.collection);
448
465
  this.load();
449
466
  });
@@ -513,7 +530,7 @@ export class PbBrowseDocs extends themableMixin(PbLoad) {
513
530
  }
514
531
 
515
532
  _handleEnter(e) {
516
- if (e.keyCode == 13) {
533
+ if (e.keyCode === 13) {
517
534
  this._filter();
518
535
  }
519
536
  }
package/src/pb-browse.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { PbLoad } from './pb-load.js';
2
+ import { registry } from './urls.js';
3
+ import { waitOnce } from "./pb-mixin.js";
2
4
 
3
5
  /**
4
6
  * Extends PbLoad to support browsing collections.
@@ -37,7 +39,10 @@ export class PbBrowse extends PbLoad {
37
39
 
38
40
  connectedCallback() {
39
41
  super.connectedCallback();
40
- this.collection = this.getParameter('collection');
42
+ waitOnce('pb-page-ready', () => {
43
+ this.collection = registry.state.collection;
44
+ registry.subscribe(this, (state) => { this.collection = state.collection; });
45
+ });
41
46
  }
42
47
 
43
48
  getURL(params) {
@@ -66,8 +71,9 @@ export class PbBrowse extends PbLoad {
66
71
  ev.preventDefault();
67
72
  this.collection = link.getAttribute('data-collection');
68
73
  this.start = 1;
69
- this.setParameter('collection', this.collection);
70
- this.pushHistory('browse collection');
74
+ if (this.history) {
75
+ registry.commit(this, { collection: this.collection });
76
+ }
71
77
  console.log('<pb-browse> loading collection %s', this.collection);
72
78
  this.emitTo('pb-search-resubmit');
73
79
  });
@@ -1,6 +1,6 @@
1
1
  import { LitElement } from 'lit-element';
2
2
  import TomSelect from "tom-select";
3
- import { pbMixin } from './pb-mixin.js';
3
+ import { pbMixin, waitOnce } from './pb-mixin.js';
4
4
  import { resolveURL } from './utils.js';
5
5
 
6
6
  function importTheme(theme) {
@@ -114,7 +114,7 @@ export class PbComboBox extends pbMixin(LitElement) {
114
114
  }
115
115
  input.autocomplete = false;
116
116
 
117
- PbComboBox.waitOnce('pb-page-ready', () => {
117
+ waitOnce('pb-page-ready', () => {
118
118
  const options = {};
119
119
  if (this.source) {
120
120
  const url = this.toAbsoluteURL(this.source);
@@ -6,6 +6,7 @@ import './pb-popover.js';
6
6
  import './pb-highlight.js';
7
7
  import './pb-link.js';
8
8
  import './pb-facs-link.js';
9
+ import './pb-image-strip.js';
9
10
  import './pb-collapse.js';
10
11
  import './pb-browse-docs.js';
11
12
  import './pb-browse.js';
@@ -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) {
@@ -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
- PbDownload.waitOnce('pb-page-ready', () => {
107
+ waitOnce('pb-page-ready', () => {
108
108
  this._target = this._computeTarget();
109
109
  this._href = this._computeURL();
110
110
  });
@@ -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
- PbEditApp.waitOnce('pb-page-ready', (detail) => {
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`;
@@ -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
- PbEditXml.waitOnce('pb-page-ready', (options) => {
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
- if (channels && !Array.isArray(channels)) {
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 ((!channels && !(ev.detail && ev.detail.key)) ||
21
- (channels && ev.detail && ev.detail.key && channels.indexOf(ev.detail.key) > -1)) {
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
- if (channels && !Array.isArray(channels)) {
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 ((!channels && !(ev.detail && ev.detail.key)) ||
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
- if (channel) {
66
- options.key = channel;
67
- }
75
+ options.key = channel || defaultChannel;
68
76
  const ev = new CustomEvent(type, {
69
77
  detail: options
70
78
  });
@@ -18,6 +18,12 @@ export class PbFacsLink extends pbMixin(LitElement) {
18
18
  coordinates: {
19
19
  type: Array
20
20
  },
21
+ label: {
22
+ type: String
23
+ },
24
+ order: {
25
+ type: Number
26
+ },
21
27
  /**
22
28
  * Type of event which should trigger the facsimile to display.
23
29
  * Either 'click' or 'mouseover' (default). */
@@ -39,29 +45,46 @@ export class PbFacsLink extends pbMixin(LitElement) {
39
45
  constructor() {
40
46
  super();
41
47
  this.trigger = 'mouseover';
48
+ this.label = '';
49
+ this.order = Number.POSITIVE_INFINITY;
50
+ this.waitFor = 'pb-facsimile,pb-image-strip';
51
+ this.default = '';
42
52
  }
43
53
 
44
54
  connectedCallback() {
45
55
  super.connectedCallback();
56
+
57
+ this.wait(() => {
58
+ this.emitTo('pb-load-facsimile', {
59
+ url: this.getImage(),
60
+ order: this.getOrder(),
61
+ element: this
62
+ });
63
+ });
64
+ }
65
+
66
+ getImage() {
67
+ return this.facs
68
+ }
69
+
70
+ getLabel() {
71
+ return this.label
72
+ }
73
+
74
+ getOrder() {
75
+ return this.order
46
76
  }
47
77
 
48
78
  firstUpdated() {
49
79
  const link = this.shadowRoot.querySelector('a');
50
- switch (this.trigger) {
51
- case 'click':
52
- link.addEventListener('click', this._linkListener.bind(this));
53
- break;
54
- default:
55
- link.addEventListener('mouseover', this._linkListener.bind(this));
56
- break;
57
- }
80
+ link.addEventListener(this.trigger, this._linkListener.bind(this));
58
81
  if (this.emitOnLoad) {
59
82
  this._trigger();
60
83
  }
61
84
  }
62
85
 
63
86
  render() {
64
- return html`<a href="#"><slot></slot></a>`;
87
+ return html`<a href="javascript:;"><slot>${this.default}</slot></a>`;
65
88
  }
66
89
 
67
90
  static get styles() {
@@ -84,6 +107,7 @@ export class PbFacsLink extends pbMixin(LitElement) {
84
107
  _trigger() {
85
108
  console.log("<facs-link> %s %o", this.facs, this.coordinates);
86
109
  this.emitTo('pb-show-annotation', {
110
+ element: this,
87
111
  file: this.facs,
88
112
  coordinates: this.coordinates
89
113
  });
@@ -173,7 +173,19 @@ export class PbFacsimile extends pbMixin(LitElement) {
173
173
  connectedCallback() {
174
174
  super.connectedCallback();
175
175
  this.subscribeTo('pb-start-update', this._clearAll.bind(this));
176
- this.subscribeTo('pb-update', this._fragmentUpdateListener.bind(this));
176
+ this.subscribeTo('pb-load-facsimile', (e) => {
177
+ const { element, order } = e.detail
178
+ const itemOrder = this._facsimiles.map(item => item.getOrder ? item.getOrder() : Number.POSITIVE_INFINITY )
179
+ const insertAt = itemOrder.reduce((result, next, index) => {
180
+ if (order < next) return result;
181
+ if (order === next) return index;
182
+ return index + 1;
183
+ }, 0)
184
+
185
+ this._facsimiles.splice(insertAt, 0, element)
186
+
187
+ this._facsimileObserver()
188
+ });
177
189
  this.subscribeTo('pb-show-annotation', this._showAnnotationListener.bind(this));
178
190
  }
179
191
 
@@ -247,7 +259,7 @@ export class PbFacsimile extends pbMixin(LitElement) {
247
259
 
248
260
  this.viewer.addHandler('open', () => {
249
261
  this.resetZoom();
250
- this.emitTo('pb-facsimile-status', { status: 'loaded' });
262
+ this.emitTo('pb-facsimile-status', { status: 'loaded', facsimiles: this._facsimiles });
251
263
  });
252
264
  this.viewer.addHandler('open-failed', (ev) => {
253
265
  console.error('<pb-facsimile> open failed: %s', ev.message);
@@ -285,17 +297,19 @@ export class PbFacsimile extends pbMixin(LitElement) {
285
297
  if (!this.viewer) {
286
298
  return;
287
299
  }
288
- if (this._facsimiles.length === 0) { return this.viewer.close() }
289
- const uris = this._facsimiles.map(fac => {
300
+ if (this._facsimiles.length === 0) {
301
+ return this.viewer.close()
302
+ }
303
+ const uris = this._facsimiles.map(facsLink => {
304
+ const url = this.baseUri + (facsLink.getImage ? facsLink.getImage() : facsLink)
290
305
  if (this.type === 'iiif') {
291
- return `${this.baseUri}${fac}/info.json`;
292
- } else {
293
- return {
294
- tileSource: {
295
- type: 'image',
296
- url: `${this.baseUri}${fac}`,
297
- buildPyramid: false
298
- }
306
+ return `${url}/info.json`;
307
+ }
308
+ return {
309
+ tileSource: {
310
+ type: 'image',
311
+ url,
312
+ buildPyramid: false
299
313
  }
300
314
  }
301
315
  });
@@ -313,22 +327,6 @@ export class PbFacsimile extends pbMixin(LitElement) {
313
327
  this.facsimiles = [];
314
328
  }
315
329
 
316
- _fragmentUpdateListener(event) {
317
- this.facsimiles = this._getFacsimilesFromData(event.detail.root)
318
- this._facsimileObserver();
319
- }
320
-
321
- _getFacsimilesFromData(elem) {
322
- const facsimiles = [];
323
- elem.querySelectorAll('pb-facs-link').forEach(cb => {
324
- if (cb.facs) {
325
- facsimiles.push(cb.facs);
326
- }
327
- });
328
- console.log('<pb-facsimile> _getFacsimilesFromData', facsimiles);
329
- return facsimiles;
330
- }
331
-
332
330
  _showAnnotationListener(event) {
333
331
  if (!this.viewer) {
334
332
  return;
@@ -352,7 +350,7 @@ export class PbFacsimile extends pbMixin(LitElement) {
352
350
  }
353
351
 
354
352
  // find page to show
355
- const page = this._pageIndexByUrl(event.detail.file)
353
+ const page = event.detail.element ? this._pageByElement(event.detail.element) : this._pageIndexByUrl(event.detail.file);
356
354
 
357
355
  if (page < 0) {
358
356
  return console.error('page not found', event.detail)
@@ -376,7 +374,8 @@ export class PbFacsimile extends pbMixin(LitElement) {
376
374
  }
377
375
 
378
376
  // create new overlay
379
- const overlay = this.overlay = document.createElement('div');
377
+ const overlay = document.createElement('div');
378
+ this.overlay = overlay
380
379
  overlay.id = overlayId;
381
380
 
382
381
  // place marker
@@ -389,8 +388,12 @@ export class PbFacsimile extends pbMixin(LitElement) {
389
388
  }
390
389
  }
391
390
 
391
+ _pageByElement(element) {
392
+ return this._facsimiles.indexOf(element);
393
+ }
394
+
392
395
  _pageIndexByUrl(file) {
393
- return this._facsimiles.indexOf(file);
396
+ return this._facsimiles.findIndex(element => element.getImage() === file);
394
397
  }
395
398
 
396
399
  // reset zoom