-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-wc.html
59 lines (50 loc) · 1.98 KB
/
test-wc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<html>
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="./dist/web-components/style.css" />
<title>Document</title>
</head>
<body>
<script src="./dist/web-components/index.umd.js"></script>
<button id="thumbnail-panel-next">Next</button>
<button id="thumbnail-panel-previous">Previous</button>
<thumbnail-panel id="tp" iiif-content="https://digirati-co-uk.github.io/wunder.json"></thumbnail-panel>
<script>
const tp = document.getElementById('tp');
const nextButton = document.getElementById('thumbnail-panel-next');
const previousButton = document.getElementById('thumbnail-panel-previous');
tp.addEventListener('resource-changed', (e) => {
console.log('e', e);
const { resourceIds } = e.detail;
const target = e.target.querySelector('[thumbnail-panel]');
if (target) {
nextButton.setAttribute('data-id', resourceIds.next);
if (!resourceIds.next) {
nextButton.setAttribute('disabled', true);
} else {
nextButton.removeAttribute('disabled');
}
previousButton.setAttribute('data-id', resourceIds.previous);
if (!resourceIds.previous) {
previousButton.setAttribute('disabled', true);
} else {
previousButton.removeAttribute('disabled');
}
}
});
nextButton.addEventListener('click', (e) => {
const next = e.target.getAttribute('data-id');
if (next != 'null') tp.setAttribute('current-resource-id', next);
});
previousButton.addEventListener('click', (e) => {
const prev = e.target.getAttribute('data-id');
if (prev !== 'null') tp.setAttribute('current-resource-id', prev);
});
</script>
</body>
</html>