@teipublisher/pb-components 2.0.0 → 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.
- package/CHANGELOG.md +16 -0
- package/dist/demo/demos.json +4 -0
- package/dist/demo/pb-image-strip-standalone.html +94 -0
- package/dist/demo/pb-image-strip-view.html +92 -0
- package/dist/pb-components-bundle.js +205 -195
- package/dist/pb-elements.json +155 -2
- package/package.json +1 -1
- package/pb-elements.json +155 -2
- package/src/pb-components.js +1 -0
- package/src/pb-facs-link.js +33 -9
- package/src/pb-facsimile.js +34 -31
- package/src/pb-image-strip.js +97 -0
package/dist/pb-elements.json
CHANGED
|
@@ -3912,6 +3912,16 @@
|
|
|
3912
3912
|
"type": "string",
|
|
3913
3913
|
"default": "\"mouseover\""
|
|
3914
3914
|
},
|
|
3915
|
+
{
|
|
3916
|
+
"name": "label",
|
|
3917
|
+
"type": "string",
|
|
3918
|
+
"default": "\"\""
|
|
3919
|
+
},
|
|
3920
|
+
{
|
|
3921
|
+
"name": "order",
|
|
3922
|
+
"type": "number",
|
|
3923
|
+
"default": "\"POSITIVE_INFINITY\""
|
|
3924
|
+
},
|
|
3915
3925
|
{
|
|
3916
3926
|
"name": "subscribe",
|
|
3917
3927
|
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
@@ -3935,7 +3945,8 @@
|
|
|
3935
3945
|
{
|
|
3936
3946
|
"name": "wait-for",
|
|
3937
3947
|
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
3938
|
-
"type": "string"
|
|
3948
|
+
"type": "string",
|
|
3949
|
+
"default": "\"pb-facsimile,pb-image-strip\""
|
|
3939
3950
|
},
|
|
3940
3951
|
{
|
|
3941
3952
|
"name": "disabled",
|
|
@@ -3970,6 +3981,23 @@
|
|
|
3970
3981
|
"type": "string",
|
|
3971
3982
|
"default": "\"mouseover\""
|
|
3972
3983
|
},
|
|
3984
|
+
{
|
|
3985
|
+
"name": "label",
|
|
3986
|
+
"attribute": "label",
|
|
3987
|
+
"type": "string",
|
|
3988
|
+
"default": "\"\""
|
|
3989
|
+
},
|
|
3990
|
+
{
|
|
3991
|
+
"name": "order",
|
|
3992
|
+
"attribute": "order",
|
|
3993
|
+
"type": "number",
|
|
3994
|
+
"default": "\"POSITIVE_INFINITY\""
|
|
3995
|
+
},
|
|
3996
|
+
{
|
|
3997
|
+
"name": "default",
|
|
3998
|
+
"type": "string",
|
|
3999
|
+
"default": "\"\""
|
|
4000
|
+
},
|
|
3973
4001
|
{
|
|
3974
4002
|
"name": "subscribe",
|
|
3975
4003
|
"attribute": "subscribe",
|
|
@@ -3998,7 +4026,8 @@
|
|
|
3998
4026
|
"name": "waitFor",
|
|
3999
4027
|
"attribute": "wait-for",
|
|
4000
4028
|
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
4001
|
-
"type": "string"
|
|
4029
|
+
"type": "string",
|
|
4030
|
+
"default": "\"pb-facsimile,pb-image-strip\""
|
|
4002
4031
|
},
|
|
4003
4032
|
{
|
|
4004
4033
|
"name": "disabled",
|
|
@@ -5089,6 +5118,130 @@
|
|
|
5089
5118
|
}
|
|
5090
5119
|
]
|
|
5091
5120
|
},
|
|
5121
|
+
{
|
|
5122
|
+
"name": "pb-image-strip",
|
|
5123
|
+
"path": "./src/pb-image-strip.js",
|
|
5124
|
+
"attributes": [
|
|
5125
|
+
{
|
|
5126
|
+
"name": "base-uri",
|
|
5127
|
+
"type": "string"
|
|
5128
|
+
},
|
|
5129
|
+
{
|
|
5130
|
+
"name": "items",
|
|
5131
|
+
"description": "Array of image",
|
|
5132
|
+
"type": "array",
|
|
5133
|
+
"default": "[]"
|
|
5134
|
+
},
|
|
5135
|
+
{
|
|
5136
|
+
"name": "image-height",
|
|
5137
|
+
"type": "number",
|
|
5138
|
+
"default": "80"
|
|
5139
|
+
},
|
|
5140
|
+
{
|
|
5141
|
+
"name": "image-width",
|
|
5142
|
+
"type": "number",
|
|
5143
|
+
"default": "64"
|
|
5144
|
+
},
|
|
5145
|
+
{
|
|
5146
|
+
"name": "subscribe",
|
|
5147
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
5148
|
+
"type": "string"
|
|
5149
|
+
},
|
|
5150
|
+
{
|
|
5151
|
+
"name": "subscribe-config",
|
|
5152
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
5153
|
+
"type": "object"
|
|
5154
|
+
},
|
|
5155
|
+
{
|
|
5156
|
+
"name": "emit",
|
|
5157
|
+
"description": "The name of the channel to send events to.",
|
|
5158
|
+
"type": "string"
|
|
5159
|
+
},
|
|
5160
|
+
{
|
|
5161
|
+
"name": "emit-config",
|
|
5162
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
5163
|
+
"type": "object"
|
|
5164
|
+
},
|
|
5165
|
+
{
|
|
5166
|
+
"name": "wait-for",
|
|
5167
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
5168
|
+
"type": "string"
|
|
5169
|
+
},
|
|
5170
|
+
{
|
|
5171
|
+
"name": "disabled",
|
|
5172
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
5173
|
+
"type": "boolean",
|
|
5174
|
+
"default": "false"
|
|
5175
|
+
}
|
|
5176
|
+
],
|
|
5177
|
+
"properties": [
|
|
5178
|
+
{
|
|
5179
|
+
"name": "baseUri",
|
|
5180
|
+
"attribute": "base-uri",
|
|
5181
|
+
"type": "string"
|
|
5182
|
+
},
|
|
5183
|
+
{
|
|
5184
|
+
"name": "items",
|
|
5185
|
+
"attribute": "items",
|
|
5186
|
+
"description": "Array of image",
|
|
5187
|
+
"type": "array",
|
|
5188
|
+
"default": "[]"
|
|
5189
|
+
},
|
|
5190
|
+
{
|
|
5191
|
+
"name": "urls",
|
|
5192
|
+
"type": "Set<any>"
|
|
5193
|
+
},
|
|
5194
|
+
{
|
|
5195
|
+
"name": "imageHeight",
|
|
5196
|
+
"attribute": "image-height",
|
|
5197
|
+
"type": "number",
|
|
5198
|
+
"default": "80"
|
|
5199
|
+
},
|
|
5200
|
+
{
|
|
5201
|
+
"name": "imageWidth",
|
|
5202
|
+
"attribute": "image-width",
|
|
5203
|
+
"type": "number",
|
|
5204
|
+
"default": "64"
|
|
5205
|
+
},
|
|
5206
|
+
{
|
|
5207
|
+
"name": "subscribe",
|
|
5208
|
+
"attribute": "subscribe",
|
|
5209
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
5210
|
+
"type": "string"
|
|
5211
|
+
},
|
|
5212
|
+
{
|
|
5213
|
+
"name": "subscribeConfig",
|
|
5214
|
+
"attribute": "subscribe-config",
|
|
5215
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
5216
|
+
"type": "object"
|
|
5217
|
+
},
|
|
5218
|
+
{
|
|
5219
|
+
"name": "emit",
|
|
5220
|
+
"attribute": "emit",
|
|
5221
|
+
"description": "The name of the channel to send events to.",
|
|
5222
|
+
"type": "string"
|
|
5223
|
+
},
|
|
5224
|
+
{
|
|
5225
|
+
"name": "emitConfig",
|
|
5226
|
+
"attribute": "emit-config",
|
|
5227
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
5228
|
+
"type": "object"
|
|
5229
|
+
},
|
|
5230
|
+
{
|
|
5231
|
+
"name": "waitFor",
|
|
5232
|
+
"attribute": "wait-for",
|
|
5233
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
5234
|
+
"type": "string"
|
|
5235
|
+
},
|
|
5236
|
+
{
|
|
5237
|
+
"name": "disabled",
|
|
5238
|
+
"attribute": "disabled",
|
|
5239
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
5240
|
+
"type": "boolean",
|
|
5241
|
+
"default": "false"
|
|
5242
|
+
}
|
|
5243
|
+
]
|
|
5244
|
+
},
|
|
5092
5245
|
{
|
|
5093
5246
|
"name": "pb-lang",
|
|
5094
5247
|
"path": "./src/pb-lang.js",
|
package/package.json
CHANGED
package/pb-elements.json
CHANGED
|
@@ -3912,6 +3912,16 @@
|
|
|
3912
3912
|
"type": "string",
|
|
3913
3913
|
"default": "\"mouseover\""
|
|
3914
3914
|
},
|
|
3915
|
+
{
|
|
3916
|
+
"name": "label",
|
|
3917
|
+
"type": "string",
|
|
3918
|
+
"default": "\"\""
|
|
3919
|
+
},
|
|
3920
|
+
{
|
|
3921
|
+
"name": "order",
|
|
3922
|
+
"type": "number",
|
|
3923
|
+
"default": "\"POSITIVE_INFINITY\""
|
|
3924
|
+
},
|
|
3915
3925
|
{
|
|
3916
3926
|
"name": "subscribe",
|
|
3917
3927
|
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
@@ -3935,7 +3945,8 @@
|
|
|
3935
3945
|
{
|
|
3936
3946
|
"name": "wait-for",
|
|
3937
3947
|
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
3938
|
-
"type": "string"
|
|
3948
|
+
"type": "string",
|
|
3949
|
+
"default": "\"pb-facsimile,pb-image-strip\""
|
|
3939
3950
|
},
|
|
3940
3951
|
{
|
|
3941
3952
|
"name": "disabled",
|
|
@@ -3970,6 +3981,23 @@
|
|
|
3970
3981
|
"type": "string",
|
|
3971
3982
|
"default": "\"mouseover\""
|
|
3972
3983
|
},
|
|
3984
|
+
{
|
|
3985
|
+
"name": "label",
|
|
3986
|
+
"attribute": "label",
|
|
3987
|
+
"type": "string",
|
|
3988
|
+
"default": "\"\""
|
|
3989
|
+
},
|
|
3990
|
+
{
|
|
3991
|
+
"name": "order",
|
|
3992
|
+
"attribute": "order",
|
|
3993
|
+
"type": "number",
|
|
3994
|
+
"default": "\"POSITIVE_INFINITY\""
|
|
3995
|
+
},
|
|
3996
|
+
{
|
|
3997
|
+
"name": "default",
|
|
3998
|
+
"type": "string",
|
|
3999
|
+
"default": "\"\""
|
|
4000
|
+
},
|
|
3973
4001
|
{
|
|
3974
4002
|
"name": "subscribe",
|
|
3975
4003
|
"attribute": "subscribe",
|
|
@@ -3998,7 +4026,8 @@
|
|
|
3998
4026
|
"name": "waitFor",
|
|
3999
4027
|
"attribute": "wait-for",
|
|
4000
4028
|
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
4001
|
-
"type": "string"
|
|
4029
|
+
"type": "string",
|
|
4030
|
+
"default": "\"pb-facsimile,pb-image-strip\""
|
|
4002
4031
|
},
|
|
4003
4032
|
{
|
|
4004
4033
|
"name": "disabled",
|
|
@@ -5089,6 +5118,130 @@
|
|
|
5089
5118
|
}
|
|
5090
5119
|
]
|
|
5091
5120
|
},
|
|
5121
|
+
{
|
|
5122
|
+
"name": "pb-image-strip",
|
|
5123
|
+
"path": "./src/pb-image-strip.js",
|
|
5124
|
+
"attributes": [
|
|
5125
|
+
{
|
|
5126
|
+
"name": "base-uri",
|
|
5127
|
+
"type": "string"
|
|
5128
|
+
},
|
|
5129
|
+
{
|
|
5130
|
+
"name": "items",
|
|
5131
|
+
"description": "Array of image",
|
|
5132
|
+
"type": "array",
|
|
5133
|
+
"default": "[]"
|
|
5134
|
+
},
|
|
5135
|
+
{
|
|
5136
|
+
"name": "image-height",
|
|
5137
|
+
"type": "number",
|
|
5138
|
+
"default": "80"
|
|
5139
|
+
},
|
|
5140
|
+
{
|
|
5141
|
+
"name": "image-width",
|
|
5142
|
+
"type": "number",
|
|
5143
|
+
"default": "64"
|
|
5144
|
+
},
|
|
5145
|
+
{
|
|
5146
|
+
"name": "subscribe",
|
|
5147
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
5148
|
+
"type": "string"
|
|
5149
|
+
},
|
|
5150
|
+
{
|
|
5151
|
+
"name": "subscribe-config",
|
|
5152
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
5153
|
+
"type": "object"
|
|
5154
|
+
},
|
|
5155
|
+
{
|
|
5156
|
+
"name": "emit",
|
|
5157
|
+
"description": "The name of the channel to send events to.",
|
|
5158
|
+
"type": "string"
|
|
5159
|
+
},
|
|
5160
|
+
{
|
|
5161
|
+
"name": "emit-config",
|
|
5162
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
5163
|
+
"type": "object"
|
|
5164
|
+
},
|
|
5165
|
+
{
|
|
5166
|
+
"name": "wait-for",
|
|
5167
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
5168
|
+
"type": "string"
|
|
5169
|
+
},
|
|
5170
|
+
{
|
|
5171
|
+
"name": "disabled",
|
|
5172
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
5173
|
+
"type": "boolean",
|
|
5174
|
+
"default": "false"
|
|
5175
|
+
}
|
|
5176
|
+
],
|
|
5177
|
+
"properties": [
|
|
5178
|
+
{
|
|
5179
|
+
"name": "baseUri",
|
|
5180
|
+
"attribute": "base-uri",
|
|
5181
|
+
"type": "string"
|
|
5182
|
+
},
|
|
5183
|
+
{
|
|
5184
|
+
"name": "items",
|
|
5185
|
+
"attribute": "items",
|
|
5186
|
+
"description": "Array of image",
|
|
5187
|
+
"type": "array",
|
|
5188
|
+
"default": "[]"
|
|
5189
|
+
},
|
|
5190
|
+
{
|
|
5191
|
+
"name": "urls",
|
|
5192
|
+
"type": "Set<any>"
|
|
5193
|
+
},
|
|
5194
|
+
{
|
|
5195
|
+
"name": "imageHeight",
|
|
5196
|
+
"attribute": "image-height",
|
|
5197
|
+
"type": "number",
|
|
5198
|
+
"default": "80"
|
|
5199
|
+
},
|
|
5200
|
+
{
|
|
5201
|
+
"name": "imageWidth",
|
|
5202
|
+
"attribute": "image-width",
|
|
5203
|
+
"type": "number",
|
|
5204
|
+
"default": "64"
|
|
5205
|
+
},
|
|
5206
|
+
{
|
|
5207
|
+
"name": "subscribe",
|
|
5208
|
+
"attribute": "subscribe",
|
|
5209
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
5210
|
+
"type": "string"
|
|
5211
|
+
},
|
|
5212
|
+
{
|
|
5213
|
+
"name": "subscribeConfig",
|
|
5214
|
+
"attribute": "subscribe-config",
|
|
5215
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
5216
|
+
"type": "object"
|
|
5217
|
+
},
|
|
5218
|
+
{
|
|
5219
|
+
"name": "emit",
|
|
5220
|
+
"attribute": "emit",
|
|
5221
|
+
"description": "The name of the channel to send events to.",
|
|
5222
|
+
"type": "string"
|
|
5223
|
+
},
|
|
5224
|
+
{
|
|
5225
|
+
"name": "emitConfig",
|
|
5226
|
+
"attribute": "emit-config",
|
|
5227
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
5228
|
+
"type": "object"
|
|
5229
|
+
},
|
|
5230
|
+
{
|
|
5231
|
+
"name": "waitFor",
|
|
5232
|
+
"attribute": "wait-for",
|
|
5233
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
5234
|
+
"type": "string"
|
|
5235
|
+
},
|
|
5236
|
+
{
|
|
5237
|
+
"name": "disabled",
|
|
5238
|
+
"attribute": "disabled",
|
|
5239
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
5240
|
+
"type": "boolean",
|
|
5241
|
+
"default": "false"
|
|
5242
|
+
}
|
|
5243
|
+
]
|
|
5244
|
+
},
|
|
5092
5245
|
{
|
|
5093
5246
|
"name": "pb-lang",
|
|
5094
5247
|
"path": "./src/pb-lang.js",
|
package/src/pb-components.js
CHANGED
package/src/pb-facs-link.js
CHANGED
|
@@ -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
|
-
|
|
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="
|
|
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
|
});
|
package/src/pb-facsimile.js
CHANGED
|
@@ -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-
|
|
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) {
|
|
289
|
-
|
|
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 `${
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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 =
|
|
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.
|
|
396
|
+
return this._facsimiles.findIndex(element => element.getImage() === file);
|
|
394
397
|
}
|
|
395
398
|
|
|
396
399
|
// reset zoom
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit-element';
|
|
2
|
+
import { pbMixin } from './pb-mixin.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* @returns {CustomElementConstructor} pb-image-strip
|
|
8
|
+
* @appliesMixin pbMixin
|
|
9
|
+
*/
|
|
10
|
+
export class PbImageStrip extends pbMixin(LitElement) {
|
|
11
|
+
static get properties() {
|
|
12
|
+
return {
|
|
13
|
+
...super.properties,
|
|
14
|
+
/**
|
|
15
|
+
* Array of image
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
items: {
|
|
19
|
+
type: Array
|
|
20
|
+
},
|
|
21
|
+
imageWidth: {
|
|
22
|
+
attribute: 'image-width',
|
|
23
|
+
type: Number
|
|
24
|
+
},
|
|
25
|
+
imageHeight: {
|
|
26
|
+
attribute: 'image-height',
|
|
27
|
+
type: Number
|
|
28
|
+
},
|
|
29
|
+
baseUri: {
|
|
30
|
+
attribute: 'base-uri',
|
|
31
|
+
type: String
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
this.items = []
|
|
39
|
+
this.urls = new Set()
|
|
40
|
+
this.imageHeight = 80
|
|
41
|
+
this.imageWidth = 64
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
super.connectedCallback();
|
|
46
|
+
this.subscribeTo('pb-start-update', () => {
|
|
47
|
+
this.items = []
|
|
48
|
+
this.urls = new Set()
|
|
49
|
+
this.requestUpdate(this.items)
|
|
50
|
+
});
|
|
51
|
+
this.subscribeTo('pb-load-facsimile', e => {
|
|
52
|
+
const { element, order } = e.detail
|
|
53
|
+
const url = element.getImage()
|
|
54
|
+
if (this.urls.has(url)) { return }
|
|
55
|
+
|
|
56
|
+
this.urls.add(url)
|
|
57
|
+
const itemOrder = this.items.map(item => item.getOrder())
|
|
58
|
+
const insertAt = itemOrder.reduce((result, next, index) => {
|
|
59
|
+
if (order < next) return result;
|
|
60
|
+
if (order === next) return index;
|
|
61
|
+
return index + 1;
|
|
62
|
+
}, 0)
|
|
63
|
+
|
|
64
|
+
this.items.splice(insertAt, 0, element)
|
|
65
|
+
this.requestUpdate()
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
showIt(element) {
|
|
70
|
+
this.emitTo('pb-show-annotation', { file: element.getImage(), element })
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
renderItem(item) {
|
|
74
|
+
return html`
|
|
75
|
+
<figure class="strip-item" @click="${() => this.showIt(item)}">
|
|
76
|
+
<img height="${this.imageHeight}" width="${this.imageWidth}"
|
|
77
|
+
src="${this.baseUri}${item.getImage()}/full/${this.imageWidth},${this.imageHeight}/0/default.jpg">
|
|
78
|
+
<figcaption>${item.getLabel()}</figcaption>
|
|
79
|
+
</figure>
|
|
80
|
+
`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
render() {
|
|
84
|
+
return html`${this.items.map(item => this.renderItem(item))}`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static get styles() {
|
|
88
|
+
return css`
|
|
89
|
+
:host {
|
|
90
|
+
display: block;
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!customElements.get('pb-image-strip')) {
|
|
96
|
+
customElements.define('pb-image-strip', PbImageStrip);
|
|
97
|
+
}
|