@teipublisher/pb-components 1.43.5 → 1.44.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.
@@ -0,0 +1,77 @@
1
+ import { PbLoad } from './pb-load.js';
2
+
3
+ /**
4
+ * Extends PbLoad to support browsing collections.
5
+ *
6
+ * This is a reduced version of `pb-browse-docs`, which differs
7
+ * from a plain `pb-load` only in that it scans the returned
8
+ * collection listing for links to subcollections and keeps
9
+ * track of the current collection.
10
+ *
11
+ * All UI elements present in `pb-browse-docs` have been removed.
12
+ */
13
+ export class PbBrowse extends PbLoad {
14
+
15
+ static get properties() {
16
+ return {
17
+ ...super.properties,
18
+ /** The collection currently being browsed (if any) */
19
+ collection: {
20
+ type: String
21
+ },
22
+ /**
23
+ * If set, rewrite URLs to load pages as static HTML files,
24
+ * so no TEI Publisher instance is required
25
+ */
26
+ static: {
27
+ type: Boolean
28
+ }
29
+ };
30
+ }
31
+
32
+ constructor() {
33
+ super();
34
+ this.collection = null;
35
+ this.static = false;
36
+ }
37
+
38
+ connectedCallback() {
39
+ super.connectedCallback();
40
+ this.collection = this.getParameter('collection');
41
+ }
42
+
43
+ getURL(params) {
44
+ if (this.static) {
45
+ // use a static URL
46
+ return `collections/${this.collection ? this.collection + '/' : ''}${params.start || '1'}.html`;
47
+ }
48
+ const url = super.getURL(params);
49
+ return this.collection ? `${url}/${this.collection}` : url;
50
+ }
51
+
52
+ _onLoad(content) {
53
+ window.scrollTo(0, 0);
54
+ const div = content.querySelector('[data-root]');
55
+ const collection = div && div.getAttribute('data-root');
56
+ const writable = div && div.classList.contains('writable');
57
+ this.emitTo('pb-collection', {
58
+ writable,
59
+ collection
60
+ });
61
+ document.querySelectorAll('[can-write]').forEach((elem) => {
62
+ elem.disabled = !writable;
63
+ });
64
+ content.querySelectorAll('[data-collection]').forEach(link => {
65
+ link.addEventListener('click', (ev) => {
66
+ ev.preventDefault();
67
+ this.collection = link.getAttribute('data-collection');
68
+ this.start = 1;
69
+ this.setParameter('collection', this.collection);
70
+ this.pushHistory('browse collection');
71
+ console.log('<pb-browse> loading collection %s', this.collection);
72
+ this.emitTo('pb-search-resubmit');
73
+ });
74
+ });
75
+ }
76
+ }
77
+ customElements.define('pb-browse', PbBrowse);
@@ -8,6 +8,7 @@ import './pb-link.js';
8
8
  import './pb-facs-link.js';
9
9
  import './pb-collapse.js';
10
10
  import './pb-browse-docs.js';
11
+ import './pb-browse.js';
11
12
  import './pb-document.js';
12
13
  import './pb-load.js';
13
14
  import './pb-navigation.js';
@@ -42,6 +42,13 @@ export class PbFacsimile extends pbMixin(LitElement) {
42
42
  type: Boolean,
43
43
  attribute: 'show-navigator'
44
44
  },
45
+
46
+ /** If true then the 'previous" and 'next' button is displayed switch between images. */
47
+ showSequenceMode: {
48
+ type: Boolean,
49
+ attribute: 'show-sequence-control'
50
+ },
51
+
45
52
  /** If true then the 'Go home' button is displayed to go back to the original zoom and pan. */
46
53
  showHomeControl: {
47
54
  type: Boolean,
@@ -143,6 +150,7 @@ export class PbFacsimile extends pbMixin(LitElement) {
143
150
  this.type = 'iiif';
144
151
  this.visibilityRatio = 1;
145
152
  this.defaultZoomLevel = 0;
153
+ this.sequenceMode = false;
146
154
  this.showHomeControl = false;
147
155
  this.showNavigator = false;
148
156
  this.showNavigationControl = false;
@@ -217,9 +225,9 @@ export class PbFacsimile extends pbMixin(LitElement) {
217
225
  const options = {
218
226
  element: this.shadowRoot.getElementById('viewer'),
219
227
  prefixUrl,
220
- preserveViewport: true,
221
- sequenceMode: true,
228
+ preserveViewport: true,
222
229
  showZoomControl: true,
230
+ sequenceMode: this.showSequenceMode,
223
231
  showHomeControl: this.showHomeControl,
224
232
  showFullPageControl: this.showFullPageControl,
225
233
  showNavigator: this.showNavigator,
package/src/pb-message.js CHANGED
@@ -6,13 +6,7 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
6
6
  import { translate } from "./pb-i18n.js";
7
7
 
8
8
  /**
9
- * Show a dialog with buttons. Used by editor.
10
- *
11
- *
12
- * todo:confirmation is only partly implemented needs some method to detect which button was clicked
13
- * @customElement
14
- * @polymer
15
- * @demo demo/pb-message.html
9
+ * Show a dialog with buttons. Used by ODD editor.
16
10
  */
17
11
  export class PbMessage extends LitElement {
18
12
 
@@ -58,14 +52,16 @@ export class PbMessage extends LitElement {
58
52
  super();
59
53
  this.title = '';
60
54
  this.message = '';
61
- this.type = 'message'; //defaults to 'message'
55
+ this.type = 'message'; // defaults to 'message'
62
56
  }
63
57
 
64
58
  render() {
65
59
  return html`
66
60
  <paper-dialog id="modal">
67
- <h2 id="title">${this.title}</h2>
68
- <paper-dialog-scrollable id="message" class="message" tabindex="0">${unsafeHTML(this.message)}</paper-dialog-scrollable>
61
+ <h2 id="title">${unsafeHTML(this.title)}</h2>
62
+ <paper-dialog-scrollable id="message" class="message" tabindex="0">
63
+ ${ this.message ? unsafeHTML(this.message) : html`<slot></slot>` }
64
+ </paper-dialog-scrollable>
69
65
 
70
66
  <div class="buttons">
71
67
  <paper-button dialog-confirm="dialog-confirm" autofocus="autofocus" ?hidden="${this.isConfirm()}">${translate('dialogs.close')}</paper-button>