diva.js 6.0.1 → 7.2.3

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 (133) hide show
  1. package/.clang-format +7 -0
  2. package/.github/workflows/npm-publish.yml +45 -0
  3. package/LICENSE +55 -0
  4. package/Makefile +75 -0
  5. package/README.md +15 -108
  6. package/elm.json +32 -0
  7. package/package.json +12 -59
  8. package/review/elm.json +52 -0
  9. package/review/src/ReviewConfig.elm +87 -0
  10. package/scripts/elm-esm.sh +40 -0
  11. package/scripts/minify-css.mjs +31 -0
  12. package/src/Filters.elm +1044 -0
  13. package/src/Main.elm +1217 -0
  14. package/src/Model.elm +213 -0
  15. package/src/Msg.elm +59 -0
  16. package/src/Utilities.elm +46 -0
  17. package/src/View/CollectionExplorer.elm +172 -0
  18. package/src/View/Helpers.elm +86 -0
  19. package/src/View/HtmlRenderer.elm +136 -0
  20. package/src/View/Icons.elm +159 -0
  21. package/src/View/ManifestInfoModal.elm +363 -0
  22. package/src/View/PageViewModal.elm +1046 -0
  23. package/src/View/Sidebar.elm +786 -0
  24. package/src/View/Toolbar.elm +189 -0
  25. package/src/View.elm +244 -0
  26. package/src/diva.ts +802 -0
  27. package/src/filters.ts +1843 -0
  28. package/src/styles/app.css +328 -0
  29. package/src/styles/collection.css +75 -0
  30. package/src/styles/modal.css +388 -0
  31. package/src/styles/sidebar.css +215 -0
  32. package/src/styles/theme.css +39 -0
  33. package/src/styles/toolbar.css +154 -0
  34. package/src/viewer-element.ts +1307 -0
  35. package/testing/index.html +52 -0
  36. package/testing/testing.html +231 -0
  37. package/tsconfig.json +12 -0
  38. package/AUTHORS +0 -22
  39. package/_site/diva.iml +0 -11
  40. package/build/diva.css +0 -554
  41. package/build/diva.css.map +0 -1
  42. package/build/diva.js +0 -9
  43. package/build/diva.js.map +0 -1
  44. package/build/plugins/download.js +0 -2
  45. package/build/plugins/download.js.map +0 -1
  46. package/build/plugins/manipulation.js +0 -2
  47. package/build/plugins/manipulation.js.map +0 -1
  48. package/build/plugins/metadata.js +0 -2
  49. package/build/plugins/metadata.js.map +0 -1
  50. package/diva.iml +0 -11
  51. package/index.html +0 -28
  52. package/karma.conf.js +0 -87
  53. package/source/css/_mixins.scss +0 -43
  54. package/source/css/_variables.scss +0 -50
  55. package/source/css/_viewer.scss +0 -462
  56. package/source/css/diva.scss +0 -15
  57. package/source/css/plugins/_manipulation.scss +0 -228
  58. package/source/css/plugins/_metadata.scss +0 -31
  59. package/source/img/adjust.svg +0 -11
  60. package/source/img/book-view.svg +0 -6
  61. package/source/img/close.svg +0 -6
  62. package/source/img/download.svg +0 -6
  63. package/source/img/from-fullscreen.svg +0 -8
  64. package/source/img/grid-fewer.svg +0 -6
  65. package/source/img/grid-more.svg +0 -6
  66. package/source/img/grid-view.svg +0 -6
  67. package/source/img/link.svg +0 -6
  68. package/source/img/metadata.svg +0 -9
  69. package/source/img/page-view.svg +0 -6
  70. package/source/img/to-fullscreen.svg +0 -11
  71. package/source/img/zoom-in.svg +0 -6
  72. package/source/img/zoom-out.svg +0 -7
  73. package/source/js/composite-image.js +0 -174
  74. package/source/js/diva-global.js +0 -7
  75. package/source/js/diva.js +0 -1543
  76. package/source/js/document-handler.js +0 -180
  77. package/source/js/document-layout.js +0 -286
  78. package/source/js/exceptions.js +0 -26
  79. package/source/js/gesture-events.js +0 -190
  80. package/source/js/grid-handler.js +0 -122
  81. package/source/js/iiif-source-adapter.js +0 -63
  82. package/source/js/image-cache.js +0 -113
  83. package/source/js/image-manifest.js +0 -157
  84. package/source/js/image-request-handler.js +0 -76
  85. package/source/js/interpolate-animation.js +0 -122
  86. package/source/js/page-layouts/book-layout.js +0 -161
  87. package/source/js/page-layouts/grid-layout.js +0 -97
  88. package/source/js/page-layouts/index.js +0 -38
  89. package/source/js/page-layouts/page-dimensions.js +0 -9
  90. package/source/js/page-layouts/singles-layout.js +0 -27
  91. package/source/js/page-overlay-manager.js +0 -102
  92. package/source/js/page-tools-overlay.js +0 -95
  93. package/source/js/parse-iiif-manifest.js +0 -302
  94. package/source/js/plugins/_filters.js +0 -679
  95. package/source/js/plugins/download.js +0 -83
  96. package/source/js/plugins/manipulation.js +0 -837
  97. package/source/js/plugins/metadata.js +0 -190
  98. package/source/js/renderer.js +0 -584
  99. package/source/js/settings-view.js +0 -30
  100. package/source/js/tile-coverage-map.js +0 -25
  101. package/source/js/toolbar.js +0 -572
  102. package/source/js/utils/dragscroll.js +0 -106
  103. package/source/js/utils/elt.js +0 -94
  104. package/source/js/utils/events.js +0 -190
  105. package/source/js/utils/get-scrollbar-width.js +0 -29
  106. package/source/js/utils/hash-params.js +0 -86
  107. package/source/js/utils/parse-label-value.js +0 -34
  108. package/source/js/utils/vanilla.kinetic.js +0 -527
  109. package/source/js/validation-runner.js +0 -177
  110. package/source/js/viewer-core.js +0 -1505
  111. package/source/js/viewport.js +0 -143
  112. package/test/_setup.js +0 -13
  113. package/test/composite-image_test.js +0 -94
  114. package/test/diva_test.js +0 -43
  115. package/test/hash-params_test.js +0 -221
  116. package/test/image-cache_test.js +0 -106
  117. package/test/main.js +0 -6
  118. package/test/manifests/beromunsterManifest.json +0 -15514
  119. package/test/manifests/iiifv2.json +0 -11032
  120. package/test/manifests/iiifv2pages.json +0 -30437
  121. package/test/manifests/iiifv3.json +0 -10965
  122. package/test/navigation_test.js +0 -355
  123. package/test/parse-iiif-manifest_test.js +0 -68
  124. package/test/public_test.js +0 -881
  125. package/test/settings_test.js +0 -487
  126. package/test/utils/book-layout_test.js +0 -148
  127. package/test/utils/elt_test.js +0 -102
  128. package/test/utils/events_test.js +0 -245
  129. package/test/utils/hash-params_test.js +0 -79
  130. package/test/utils/parse-label-value_test.js +0 -45
  131. package/test/z_plugins_test.js +0 -180
  132. package/webpack.config.js +0 -58
  133. package/webpack.config.test.js +0 -45
@@ -1,102 +0,0 @@
1
- import {elt} from '../../source/js/utils/elt';
2
-
3
- describe('elt util', function ()
4
- {
5
- it("elt() function works", function ()
6
- {
7
- // Serialize node type and text content (not attributes, because those are more complicated)
8
- var serialize = function (node)
9
- {
10
- if (node.nodeName === '#text')
11
- return node.textContent;
12
-
13
- return {
14
- name: node.nodeName.toLowerCase(),
15
- childNodes: Array.prototype.map.call(node.childNodes, serialize)
16
- };
17
- };
18
-
19
- var simple = elt('span');
20
- var expectedSimple = { name: 'span', childNodes: [] };
21
- assert.deepEqual(serialize(simple), expectedSimple, 'It should create nodes with the given tag');
22
-
23
- var withNull = elt('span', null, undefined);
24
- var expectedWithNull = { name: 'span', childNodes: [] };
25
- assert.deepEqual(serialize(withNull), expectedWithNull, 'It should ignore null and undefined values');
26
-
27
- var withText = elt('span', 'A', 'B');
28
- var expectedWithText = { name: 'span', childNodes: ['A', 'B'] };
29
- assert.deepEqual(serialize(withText), expectedWithText, 'It should add additional string arguments as text');
30
-
31
- var withArray = elt('ol', [
32
- elt('li', 'first'),
33
- elt('li', 'second'),
34
- [
35
- elt('li', 'more'),
36
- elt('li', 'and more')
37
- ]
38
- ]);
39
- var expectedWithArray = {
40
- name: 'ol',
41
- childNodes: [
42
- { name: 'li', childNodes: ['first'] },
43
- { name: 'li', childNodes: ['second'] },
44
- { name: 'li', childNodes: ['more'] },
45
- { name: 'li', childNodes: ['and more'] }
46
- ]
47
- };
48
- assert.deepEqual(serialize(withArray), expectedWithArray, 'It should recurse on nested arrays');
49
-
50
- var withOther = elt('span', 2, false);
51
- var expectedWithOther = { name: 'span', childNodes: ['2', 'false'] };
52
- assert.deepEqual(serialize(withOther), expectedWithOther, 'It should coerce other arguments to strings');
53
-
54
- var link = elt('a',
55
- { href: 'http://example.org/', title: 'overridden' },
56
- 'Hello world!',
57
- { title: 'additional argument' }
58
- );
59
- var expectedLink = {
60
- name: 'a',
61
- childNodes: ['Hello world!']
62
- };
63
- assert.strictEqual(link.href, 'http://example.org/', 'It should set attributes from object arguments');
64
- assert.strictEqual(link.title, 'additional argument', 'It should handle multiple attribute arguments');
65
- assert.deepEqual(serialize(link), expectedLink, 'It should handle children along with attribute arguments');
66
-
67
- var fragment = document.createDocumentFragment();
68
- fragment.appendChild(document.createTextNode(', very'));
69
-
70
- var compound = elt('span',
71
- 'This is ', elt('em', 'very'), fragment, document.createTextNode(' exciting')
72
- );
73
- var expectedCompound = {
74
- name: 'span',
75
- childNodes: [
76
- 'This is ',
77
- {
78
- name: 'em',
79
- childNodes: ['very']
80
- },
81
- ', very',
82
- ' exciting'
83
- ]
84
- };
85
- assert.deepEqual(serialize(compound), expectedCompound, 'It should append DOM node arguments');
86
-
87
- var hidden = elt('span', {
88
- style: { display: 'none' }
89
- });
90
- assert.strictEqual(hidden.style.display, 'none', 'It should handle objects for the style attribute');
91
-
92
- var hiddenAsText = elt('span', {
93
- style: 'display: none;'
94
- });
95
- assert.strictEqual(hiddenAsText.style.display, 'none', 'It should handle strings for the style attribute');
96
-
97
- var nullStyle = elt('span', {
98
- style: null
99
- });
100
- assert.strictEqual(nullStyle.style.cssText, '', 'It should ignore a null style');
101
- });
102
- });
@@ -1,245 +0,0 @@
1
- 'use strict';
2
-
3
- import {Events} from '../../source/js/utils/events';
4
-
5
- describe('Events', function ()
6
- {
7
- it('subscribe(topic, callback[, instanceID])', function ()
8
- {
9
- var events = Events;
10
-
11
- var callback = function () {};
12
- assert.deepEqual(events.subscribe('Topic', callback), ['Topic', callback], 'Global callback handles should have no scope');
13
- assert.deepEqual(events.subscribe('Topic', callback, 'A'), ['Topic', callback, 'A'], 'Scoped callback handles should have a scope');
14
- });
15
-
16
- it('publish(topic[, args])', function ()
17
- {
18
- var events = Events;
19
- var calls = [];
20
-
21
- events.subscribe('MyTopic', function ()
22
- {
23
- calls.push(['callback 1', this, Array.prototype.slice.call(arguments)]);
24
- });
25
-
26
- events.subscribe('MyTopic', function ()
27
- {
28
- calls.push(['callback 2', this, Array.prototype.slice.call(arguments)]);
29
- });
30
-
31
- events.subscribe('MyTopic', function ()
32
- {
33
- calls.push(['scoped callback', this, Array.prototype.slice.call(arguments)]);
34
- }, 'some scope');
35
-
36
- events.publish('OtherTopic', []);
37
- events.publish('MyTopic', [1, 2, 3]);
38
- events.publish('MyTopic');
39
-
40
- assert.deepEqual(calls, [
41
- ['callback 1', null, [1, 2, 3]],
42
- ['callback 2', null, [1, 2, 3]],
43
- ['callback 1', null, []],
44
- ['callback 2', null, []]
45
- ], 'Global callbacks should be called for the topic with the arguments in the order subscribed');
46
- });
47
-
48
- it('publish(topic, args, scope)', function ()
49
- {
50
- var scopeID = '1000';
51
-
52
- var scopeObject = {
53
- getInstanceId: function ()
54
- {
55
- return scopeID;
56
- }
57
- };
58
-
59
- var events = Events;
60
- var calls = [];
61
-
62
- events.subscribe('MyTopic', function ()
63
- {
64
- calls.push(['global callback', this, Array.prototype.slice.call(arguments)]);
65
- });
66
-
67
- events.subscribe('MyTopic', function ()
68
- {
69
- calls.push(['scoped callback', this, Array.prototype.slice.call(arguments)]);
70
- }, scopeID);
71
-
72
- events.subscribe('MyTopic', function ()
73
- {
74
- calls.push(['global callback after scoped', this, Array.prototype.slice.call(arguments)]);
75
- });
76
-
77
- events.subscribe('MyTopic', function ()
78
- {
79
- calls.push(['irrelevant callback', this, Array.prototype.slice.call(arguments)]);
80
- }, 'irrelevant');
81
-
82
- events.publish('OtherTopic', ['should not be called'], scopeObject);
83
- events.publish('MyTopic', [1, 2, 3], scopeObject);
84
- events.publish('MyTopic', null, scopeObject); // Null arguments should work
85
-
86
- assert.deepEqual(calls, [
87
- ['global callback', scopeObject, [1, 2, 3]],
88
- ['global callback after scoped', scopeObject, [1, 2, 3]],
89
- ['scoped callback', scopeObject, [1, 2, 3]],
90
- ['global callback', scopeObject, []],
91
- ['global callback after scoped', scopeObject, []],
92
- ['scoped callback', scopeObject, []]
93
- ], 'Global and relevant scoped callbacks should be called, with globals first');
94
-
95
- calls = [];
96
-
97
- var invalidScope = null;
98
-
99
- events.publish('MyTopic', [3, 2, 1], invalidScope);
100
-
101
- // I don't know if this is really desirable behaviour, but it's what happens
102
- assert.deepEqual(calls, [
103
- ['global callback', invalidScope, [3, 2, 1]],
104
- ['global callback after scoped', invalidScope, [3, 2, 1]]
105
- ], 'Only global callbacks should be called for invalid scope objects');
106
- });
107
-
108
- it('unsubscribe(Array<topic, callback[, instanceId]>[, completely])', function ()
109
- {
110
- var events = Events;
111
- events.unsubscribeAll();
112
-
113
- var callback = function () {};
114
- var otherCallback = function () {};
115
-
116
- events.subscribe('MyTopic', callback);
117
- events.subscribe('MyTopic', otherCallback);
118
- events.subscribe('MyTopic', callback, 'some scope');
119
- events.subscribe('MyTopic', otherCallback, 'some scope');
120
- events.subscribe('MyTopic', callback, 'another scope');
121
- events.subscribe('MyTopic', otherCallback, 'another scope');
122
-
123
- assert.deepEqual(getTestSubscriptions(), {
124
- 'global': [callback, otherCallback],
125
- 'some scope': [callback, otherCallback],
126
- 'another scope': [callback, otherCallback]
127
- }, 'The callbacks should be subscribed (sanity check)');
128
-
129
- assert.ok(events.unsubscribe(['MyTopic', callback]), 'It should return true if events are unsubscribed');
130
- assert.ok(!events.unsubscribe(['MyTopic', callback, 'unknown']), 'It should return false if the scope is unknown');
131
- assert.ok(!events.unsubscribe(['Blueberries', callback]), 'It should return false if the topic is unknown');
132
-
133
- assert.deepEqual(getTestSubscriptions(), {
134
- 'global': [otherCallback],
135
- 'some scope': [callback, otherCallback],
136
- 'another scope': [callback, otherCallback]
137
- }, 'The global callback should be removed');
138
-
139
- assert.ok(!events.unsubscribe(['MyTopic', callback]), 'It should return false if no events are unsubscribed');
140
-
141
- events.unsubscribe(['MyTopic', callback, 'some scope']);
142
-
143
- assert.deepEqual(getTestSubscriptions(), {
144
- 'global': [otherCallback],
145
- 'some scope': [otherCallback],
146
- 'another scope': [callback, otherCallback]
147
- }, 'The relevant scoped callback should be removed');
148
-
149
- assert.ok(events.unsubscribe(['MyTopic', callback, 'another scope'], true), 'It should return true if events are unsubscribed (completely)');
150
- assert.ok(!events.unsubscribe(['MyTopic', callback, 'another scope'], true), 'It should return false if no events are unsubscribed (completely)');
151
-
152
- assert.deepEqual(getTestSubscriptions(), {
153
- 'global': [otherCallback],
154
- 'some scope': [otherCallback],
155
- 'another scope': []
156
- }, 'All scoped callbacks should be removed when `completely` is true');
157
-
158
- events.unsubscribe(['MyTopic', callback], true);
159
-
160
- assert.deepEqual(getTestSubscriptions(), {
161
- 'global': [],
162
- 'some scope': [otherCallback],
163
- 'another scope': []
164
- }, 'All global callbacks should be removed when `completely` is true');
165
-
166
- function getTestSubscriptions()
167
- {
168
- return {
169
- 'global': subscriptions(events, 'MyTopic'),
170
- 'some scope': subscriptions(events, 'MyTopic', 'some scope'),
171
- 'another scope': subscriptions(events, 'MyTopic', 'another scope')
172
- };
173
- }
174
- });
175
-
176
- it('unsubscribeAll([instanceID])', function ()
177
- {
178
- var events = Events;
179
- events.unsubscribeAll();
180
-
181
- var callback = function () {};
182
-
183
- events.subscribe('MyTopic', callback);
184
- events.subscribe('MyTopic', callback, 'some scope');
185
- events.subscribe('MyTopic', callback, 'another scope');
186
-
187
- assert.deepEqual(getTestSubscriptions(), {
188
- 'global': [callback],
189
- 'some scope': [callback],
190
- 'another scope': [callback]
191
- }, 'The callbacks should be subscribed (sanity check)');
192
-
193
- events.unsubscribeAll('some scope');
194
-
195
- assert.deepEqual(getTestSubscriptions(), {
196
- 'global': [callback],
197
- 'some scope': [],
198
- 'another scope': [callback]
199
- }, 'All topics for the scope should be unsubscribed');
200
-
201
- events.unsubscribeAll('this is not actually a scope');
202
-
203
- assert.deepEqual(getTestSubscriptions(), {
204
- 'global': [callback],
205
- 'some scope': [],
206
- 'another scope': [callback]
207
- }, 'Unsubscribing from an unknown topic should not blow things up');
208
-
209
- events.unsubscribeAll();
210
-
211
- assert.deepEqual(getTestSubscriptions(), {
212
- 'global': [],
213
- 'some scope': [],
214
- 'another scope': []
215
- }, 'Unsubscribing without a topic should clear everything');
216
-
217
- function getTestSubscriptions()
218
- {
219
- return {
220
- 'global': subscriptions(events, 'MyTopic'),
221
- 'some scope': subscriptions(events, 'MyTopic', 'some scope'),
222
- 'another scope': subscriptions(events, 'MyTopic', 'another scope')
223
- };
224
- }
225
- });
226
-
227
- /** Reach into an events instance to check private state **/
228
- function subscriptions(events, topic, instanceID)
229
- {
230
- if (typeof instanceID === 'undefined')
231
- instanceID = 'global';
232
-
233
- var topicSubs = events._cache[topic];
234
-
235
- if (!topicSubs)
236
- return [];
237
-
238
- var instanceSubs = topicSubs[instanceID];
239
-
240
- if (!instanceSubs)
241
- return [];
242
-
243
- return instanceSubs.slice();
244
- }
245
- });
@@ -1,79 +0,0 @@
1
- import HashParams from '../../source/js/utils/hash-params';
2
-
3
- describe('HashParams', function ()
4
- {
5
- it("HashParams.get", function ()
6
- {
7
- // First try it with no hash params - should return false
8
- assert.ok(!HashParams.get('anything'), "No hash params, should return false");
9
-
10
- // Now set the current URL to something
11
- window.location.hash = '#p=149&z=2';
12
- var nonexistentParam = HashParams.get('lol');
13
- var firstParam = HashParams.get('p');
14
- var secondParam = HashParams.get('z');
15
- assert.ok(!nonexistentParam, "The nonexistent param should return false");
16
- assert.strictEqual(firstParam, '149', "The 'p' param should be 149 (string)");
17
- assert.strictEqual(secondParam, '2', "The 'z' param should be 2 (string)");
18
-
19
- // Now let there be only one element in the URL
20
- window.location.hash = '#p=149';
21
- var soleParam = HashParams.get('p');
22
- assert.strictEqual(soleParam, '149', "The 'p' param should be 149 when it is the sole param");
23
-
24
- // Now let there be other elements in the URL
25
- window.location.hash = '#z=2&p=100&lol=lol';
26
- var anotherFirstParam = HashParams.get('z');
27
- var anotherSecondParam = HashParams.get('p');
28
- var thirdParam = HashParams.get('lol');
29
- assert.strictEqual(anotherFirstParam, '2', "The 'z' param should be '2' when it is the first param");
30
- assert.strictEqual(anotherSecondParam, '100', "The 'p' param should be '100' when it is the middle param");
31
- assert.strictEqual(thirdParam, 'lol', "The last param should be 'lol'");
32
- window.location.hash = '';
33
- });
34
-
35
- it("HashParams.update", function ()
36
- {
37
- window.location.hash = '';
38
- // First try it with no hash params in the URL
39
- HashParams.update('p', '1');
40
- assert.strictEqual(window.location.hash, '#p=1');
41
-
42
- // The key is present but there is no value
43
- window.location.hash = '#p=';
44
- HashParams.update('p', '2');
45
- assert.strictEqual(window.location.hash, '#p=2');
46
-
47
- // Then, with a bunch of irrelevant ones
48
- window.location.hash = '#key=2&another=3';
49
- HashParams.update('p', '3');
50
- assert.strictEqual(window.location.hash, '#key=2&another=3&p=3');
51
-
52
- // One irrelevant one
53
- window.location.hash = '#a=b';
54
- HashParams.update('p', '4');
55
- assert.strictEqual(window.location.hash, '#a=b&p=4');
56
-
57
- // Only one hash param, and it's the one we want to update
58
- window.location.hash = '#p=1';
59
- HashParams.update('p', '9001');
60
- assert.strictEqual(window.location.hash, '#p=9001');
61
-
62
- // Two hash params, one of which is the one we want to update
63
- window.location.hash = '#p=4&h=1';
64
- HashParams.update('p', '1');
65
- assert.strictEqual(window.location.hash, '#p=1&h=1');
66
- HashParams.update('h', '100');
67
- assert.strictEqual(window.location.hash, '#p=1&h=100');
68
-
69
- // Two hash params, both are which are right (choose one)
70
- // Should never happen unless the user is being malicious
71
- window.location.hash = '#p=4&p=2';
72
- HashParams.update('p', '5');
73
- assert.strictEqual(window.location.hash, '#p=4&p=5');
74
- // Not actually sure why it chooses the first one to update
75
-
76
- // Restore the URL
77
- window.location.hash = '';
78
- });
79
- });
@@ -1,45 +0,0 @@
1
- import parseLabelValue from '../../source/js/utils/parse-label-value';
2
-
3
- describe('Parse Label Value', function ()
4
- {
5
- it('Should parse object -> array -> objects', function ()
6
- {
7
- let key = {
8
- "label" : "Date",
9
- "value" : [
10
- {
11
- "@value" : "1101-1125"
12
- }, {
13
- "@value" : "1301-1400"
14
- }
15
- ]
16
- };
17
-
18
- let obj = parseLabelValue(key);
19
-
20
- assert.strictEqual(obj.label, 'Date', 'Label should be "Date"');
21
- assert.strictEqual(obj.value, '1101-1125, 1301-1400', 'Value should be the date string');
22
- });
23
-
24
- it('Should parse object -> array', function ()
25
- {
26
- let key = {
27
- "label": {
28
- "en": [
29
- "Date Statement"
30
- ]
31
- },
32
- "value": {
33
- "en": [
34
- "1401",
35
- "1500"
36
- ]
37
- }
38
- };
39
-
40
- let obj = parseLabelValue(key);
41
-
42
- assert.strictEqual(obj.label, 'Date Statement', 'Label should be "Date Statement"');
43
- assert.strictEqual(obj.value, '1401, 1500', 'Value should be the date string');
44
- });
45
- });
@@ -1,180 +0,0 @@
1
- import Diva from '../source/js/diva';
2
-
3
- let v3Manifest = require('./manifests/iiifv3.json');
4
-
5
- describe('Plugins', function ()
6
- {
7
- beforeEach(function ()
8
- {
9
- // reset event subscription so only current test is subscribed
10
- Diva.Events.unsubscribeAll();
11
-
12
- // recreate diva instance
13
- let oldWrapper = document.getElementById('parent-wrapper');
14
- oldWrapper.parentNode.removeChild(oldWrapper);
15
- let newWrapper = document.createElement('div');
16
- newWrapper.id = 'parent-wrapper';
17
- newWrapper.setAttribute('style', 'width: 984px;');
18
- let div = document.createElement('div');
19
- div.id = 'diva-wrapper';
20
- newWrapper.appendChild(div);
21
- document.body.appendChild(newWrapper);
22
- });
23
-
24
- //METADATA PLUGIN
25
- it('Metadata plugin is created when added as a Diva plugin', function (done)
26
- {
27
- Diva.Events.subscribe('ViewerDidLoad', function ()
28
- {
29
- let icon = document.getElementsByClassName('diva-metadata-icon')[0];
30
- assert.isNotNull(icon, 'Metadata icon should exist');
31
- done();
32
- });
33
-
34
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
35
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
36
- plugins: [Diva.MetadataPlugin]
37
- });
38
- });
39
-
40
- it('Metadata div can be opened and closed', function (done)
41
- {
42
- Diva.Events.subscribe('ViewerDidLoad', function ()
43
- {
44
- let icon = document.getElementsByClassName('diva-metadata-icon')[0];
45
-
46
- assert.isNull(document.getElementById('metadataDiv'), 'Metadata div should not exist yet');
47
-
48
- icon.click();
49
-
50
- let div = document.getElementById('metadataDiv');
51
- assert.isNotNull(div, 'Metadata div should exist');
52
-
53
- icon.click();
54
- assert.strictEqual(div.style.display, 'none', 'Div should be hidden');
55
-
56
- icon.click();
57
- document.getElementsByClassName('close-button')[0].click();
58
- assert.strictEqual(div.style.display, 'none', 'Div should be hidden from close button');
59
-
60
- // trigger drag events
61
- icon.click();
62
- let e = new Event('mousedown');
63
- div.dispatchEvent(e);
64
- e = new Event('mousemove');
65
- document.dispatchEvent(e);
66
- e = new Event('mouseup');
67
- document.dispatchEvent(e);
68
- icon.click();
69
-
70
- done();
71
- });
72
-
73
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
74
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
75
- plugins: [Diva.MetadataPlugin]
76
- });
77
- });
78
-
79
- // hard to test dragging the element with just javascript, skipping
80
-
81
- // DOWNLOAD PLUGIN
82
- it('Download plugin is created when added as a Diva plugin', function (done)
83
- {
84
- Diva.Events.subscribe('ViewerDidLoad', function ()
85
- {
86
- let icon = document.getElementsByClassName('diva-download-icon')[0];
87
- assert.isNotNull(icon, 'Download icon should exist');
88
- done();
89
- });
90
-
91
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
92
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
93
- plugins: [Diva.DownloadPlugin]
94
- });
95
- });
96
-
97
- it('Download icon can be clicked', function (done)
98
- {
99
- Diva.Events.subscribe('ViewerDidLoad', function ()
100
- {
101
- let icon = document.getElementsByClassName('diva-download-icon')[0];
102
- icon.click();
103
- done();
104
- });
105
-
106
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
107
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
108
- plugins: [Diva.DownloadPlugin]
109
- });
110
- });
111
-
112
- // MANIPULATION PLUGIN
113
- it('Manipulation plugin is created when added as a Diva plugin', function (done)
114
- {
115
- Diva.Events.subscribe('ViewerDidLoad', function ()
116
- {
117
- let icon = document.getElementsByClassName('diva-manipulation-icon')[0];
118
- assert.isNotNull(icon, 'Manipulation icon should exist');
119
- done();
120
- });
121
-
122
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
123
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
124
- plugins: [Diva.ManipulationPlugin]
125
- });
126
- });
127
-
128
- it('Manipulation controls can be used', function (done)
129
- {
130
- Diva.Events.subscribe('ViewerDidLoad', function ()
131
- {
132
- let icon = document.getElementsByClassName('diva-manipulation-icon')[0];
133
- icon.click();
134
-
135
- let controls = document.getElementsByClassName('manipulation-tools-mobile')[0];
136
- assert.isNotNull(controls, 'Controls exist once icon is clicked');
137
-
138
- // give main image some time to load
139
- setTimeout(() =>
140
- {
141
- // do all control related tests
142
- let view = document.getElementsByClassName('manipulation-main-area-mobile')[0];
143
-
144
- let event = new MouseEvent('dblclick', {
145
- 'view': window,
146
- 'bubbles': true,
147
- 'cancelable': true
148
- });
149
-
150
- view.dispatchEvent(event);
151
-
152
- let zoomSlider = document.getElementById('zoom-slider');
153
- assert.strictEqual(zoomSlider.value, '2', 'Zoom should now be 2');
154
-
155
- // click on hamburger
156
- document.getElementsByClassName('burger-menu')[0].click();
157
-
158
- // click on first color filter button (grayscale rn)
159
- document.getElementsByClassName('color-filters')[0].click();
160
- let log = document.getElementById('filter-log');
161
-
162
- // change select to threshold
163
- let select = document.getElementById('filter-select');
164
- select.value = 'threshold';
165
- event = new Event('change');
166
- select.dispatchEvent(event);
167
- assert.isFalse(log.innerText.includes('Grayscale'), 'Log should be reset');
168
-
169
- done();
170
- }, 1000);
171
- });
172
-
173
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
174
- objectData: v3Manifest,
175
- plugins: [Diva.ManipulationPlugin]
176
- });
177
- });
178
-
179
- // hard to test dragging the sliders to manipulate the image with just javascript, skipping
180
- });