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,355 +0,0 @@
1
- import Diva from '../source/js/diva';
2
-
3
- // jQuery mimic
4
- let el = document.getElementById.bind(document);
5
-
6
- describe('Navigation', function ()
7
- {
8
- beforeEach(function ()
9
- {
10
- // reset event subscription so only current test is subscribed
11
- Diva.Events.unsubscribeAll();
12
-
13
- // recreate diva instance
14
- let oldWrapper = document.getElementById('parent-wrapper');
15
- oldWrapper.parentNode.removeChild(oldWrapper);
16
- let newWrapper = document.createElement('div');
17
- newWrapper.id = 'parent-wrapper';
18
- newWrapper.setAttribute('style', 'width: 984px;');
19
- let div = document.createElement('div');
20
- div.id = 'diva-wrapper';
21
- newWrapper.appendChild(div);
22
- document.body.appendChild(newWrapper);
23
- });
24
-
25
- // FIXME: This test pattern is pretty iffy. There should be more robust ways to do this than
26
- // with a timeout, and the toolbar and page index are kind of separate concerns.
27
- var assertPageAfterScroll = function (scroll, index, divaInst, done, label)
28
- {
29
- var viewportObject = divaInst.getSettings().viewportObject;
30
-
31
- if ('left' in scroll)
32
- viewportObject.scrollLeft = scroll.left; // does this trigger a scroll event?
33
-
34
- viewportObject.addEventListener('scroll', function handleScroll ()
35
- {
36
- setTimeout(function ()
37
- {
38
- var rendered = label;
39
-
40
- var actualIndex = divaInst.getActivePageIndex();
41
- assert.strictEqual(actualIndex, index, "The page should now be " + rendered + " (index of " + index + ")");
42
-
43
- var actualRendered = el(divaInst.getSettings().selector + 'current-page').innerText;
44
- assert.strictEqual(actualRendered, rendered, "The toolbar should have been updated");
45
-
46
- viewportObject.removeEventListener('scroll', handleScroll);
47
-
48
- done();
49
- }, 10);
50
- });
51
-
52
- viewportObject.scrollTop = scroll.top;
53
- };
54
-
55
- var assertZoomIs = function (level, divaInst, controlName)
56
- {
57
- var actualLevel = divaInst.getZoomLevel();
58
- var renderedLevel = el(divaInst.getSettings().selector + 'zoom-level').innerText;
59
-
60
- assert.strictEqual(actualLevel, level, "Zoom level should now be " + level);
61
- assert.strictEqual(renderedLevel, (level + 1).toFixed(), "The " + controlName + " label should have been updated");
62
- };
63
-
64
- it("Scrolling in document view", function (done)
65
- {
66
- Diva.Events.subscribe('ViewerDidLoad', function ()
67
- {
68
- assertPageAfterScroll({ top: 10000 }, 40, this, done, 'Folio 020r - Folio 021r');
69
- });
70
-
71
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
72
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
73
- zoomLevel: 0,
74
- adaptivePadding: 0,
75
- fixedPadding: 40
76
- });
77
- });
78
-
79
- it("Scrolling in grid view", function (done)
80
- {
81
- Diva.Events.subscribe('ViewerDidLoad', function ()
82
- {
83
- assertPageAfterScroll({ top: 10000 }, 26, this, done, 'Folio 014r - Folio 014v');
84
- });
85
-
86
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
87
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
88
- inGrid: true,
89
- pagesPerRow: 2,
90
- fixedHeightGrid: false
91
- });
92
- });
93
-
94
- it("Scrolling in book view", function (done)
95
- {
96
- Diva.Events.subscribe('ViewerDidLoad', function ()
97
- {
98
- assertPageAfterScroll({ left: 200, top: 10000 }, 18, this, done, 'Bm 019 - Bm 020');
99
- });
100
-
101
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
102
- objectData: 'https://ddmal.github.io/diva.js/try/demo/beromunster-iiif.json'
103
- });
104
- });
105
-
106
- // Try to verify that zoom animation can be gracefully interrupted
107
- it('View change during zoom animation', function (done)
108
- {
109
- var gridViewSeen = false;
110
-
111
- Diva.Events.subscribe('ViewerDidLoad', function ()
112
- {
113
- Diva.Events.subscribe('ZoomLevelDidChange', function ()
114
- {
115
- this.enterGridView();
116
- }, this.getInstanceId());
117
-
118
- Diva.Events.subscribe('ViewDidSwitch', function (inGrid)
119
- {
120
- // debugger
121
- if (inGrid)
122
- {
123
- gridViewSeen = true;
124
- assert.strictEqual(this.getZoomLevel(), 3, 'Updated zoom level should be set');
125
-
126
- defer(this.leaveGridView, this);
127
- }
128
- else
129
- {
130
- assert.isOk(gridViewSeen, 'Grid view should have been entered');
131
- assert.strictEqual(this.getZoomLevel(), 3, 'Zoom level should still be 3');
132
-
133
- done();
134
- }
135
- }, this.getInstanceId());
136
-
137
- // debugger
138
- this.zoomIn();
139
- });
140
-
141
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
142
- objectData: 'https://ddmal.github.io/diva.js/try/demo/beromunster-iiif.json',
143
- zoomLevel: 2
144
- });
145
-
146
- function defer(callback, ctx)
147
- {
148
- setTimeout(callback.bind(ctx), 10);
149
- }
150
- });
151
-
152
- it("Zooming using +/- buttons", function (done)
153
- {
154
- Diva.Events.subscribe('ViewerDidLoad', function (settings)
155
- {
156
- el(settings.selector + 'zoom-out-button').click();
157
- assertZoomIs(4, this, 'zoom buttons');
158
-
159
- setTimeout(() =>
160
- {
161
- el(settings.selector + 'zoom-in-button').click();
162
- assertZoomIs(5, this, 'zoom buttons');
163
-
164
- done();
165
- }, 600);
166
- });
167
-
168
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
169
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
170
- zoomLevel: 5
171
- });
172
- });
173
-
174
- it("Scrolling and subsequently zooming in Grid view", function (done)
175
- {
176
- Diva.Events.subscribe('ViewerDidLoad', function(settings)
177
- {
178
- settings.viewportObject.scrollTop = 10050;
179
-
180
- setTimeout(() =>
181
- {
182
- assert.strictEqual(this.getActivePageIndex(), 165, "The current page should be 165 (10050px down, 1871px viewport)");
183
-
184
- el(settings.selector + 'grid-out-button').click();
185
- el(settings.selector + 'grid-out-button').click();
186
- assert.strictEqual(this.getActivePageIndex(), 165, "The current page should still be 85");
187
-
188
- for (var i = 0; i < 5; i++)
189
- {
190
- el(settings.selector + 'grid-in-button').click();
191
- }
192
- assert.strictEqual(this.getActivePageIndex(), 165, "The current page should still be 85");
193
-
194
- done();
195
- }, 10);
196
- });
197
-
198
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
199
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
200
- inGrid: true,
201
- pagesPerRow: 5,
202
- fixedHeightGrid: false
203
- });
204
- });
205
-
206
- it("Changing pages per row in Grid view using +/- buttons", function (done)
207
- {
208
- Diva.Events.subscribe('ViewerDidLoad', function (settings)
209
- {
210
- this.enterGridView();
211
- for (var i = 0; i < 6; i++)
212
- {
213
- el(settings.selector + 'grid-in-button').click();
214
- }
215
- assert.strictEqual(this.getState().n, 8, "Pages per row should now be 8");
216
- assert.strictEqual(el(settings.selector + 'pages-per-row').innerText, '8', "The grid buttons label should have been updated");
217
-
218
- for (i = 0; i < 6; i++)
219
- {
220
- el(settings.selector + 'grid-out-button').click();
221
- }
222
- assert.strictEqual(this.getState().n, 2, "Pages per row should now be 2");
223
- assert.strictEqual(el(settings.selector + 'pages-per-row').innerText, '2', "The grid buttons label should have been updated");
224
-
225
- done();
226
- });
227
-
228
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
229
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
230
- pagesPerRow: 2
231
- });
232
- });
233
-
234
- it("Zooming by double-clicking", function (done)
235
- {
236
- Diva.Events.subscribe('ViewerDidLoad', function (settings)
237
- {
238
- var dblClick = new MouseEvent('dblclick', {
239
- 'view': window,
240
- 'bubbles': true,
241
- 'cancelable': true
242
- });
243
-
244
- setTimeout(function ()
245
- {
246
- diva.settings.innerElement.dispatchEvent(dblClick);
247
- setTimeout(function ()
248
- {
249
- assert.strictEqual(settings.zoomLevel, 2, "Zoom level should now be 2");
250
- assert.strictEqual(settings.activePageIndex, 100, "Should still be on page 100");
251
- done();
252
- }, 10);
253
- }, 10);
254
- });
255
-
256
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
257
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
258
- zoomLevel: 1,
259
- goDirectlyTo: 100
260
- });
261
- });
262
-
263
- it("Switching between document and grid view", function (done)
264
- {
265
- Diva.Events.subscribe('ViewerDidLoad', function (settings)
266
- {
267
- assert.ok(!settings.inGrid, "Not in grid initially");
268
- el(settings.selector + 'grid-icon').click();
269
-
270
- // Click the grid icon, then wait a bit for the event to be triggered
271
- setTimeout(function ()
272
- {
273
- assert.isOk(settings.inGrid, "Should now be in grid");
274
- assert.isDefined(el(settings.selector + 'grid-out-button'), "Grid buttons should be visible (-)");
275
- assert.isDefined(el(settings.selector + 'grid-in-button'), "Grid buttons should be visible (+)");
276
- assert.isNull(el(settings.selector + 'zoom-out-buttons'), "Zoom buttons should not be visible (-)");
277
- assert.isNull(el(settings.selector + 'zoom-in-buttons'), "Zoom buttons should not be visible (+)");
278
- done();
279
- }, 10);
280
- });
281
-
282
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
283
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
284
- });
285
- });
286
-
287
- it("Switching between regular and fullscreen mode", function (done)
288
- {
289
- var initialX = null;
290
- var initialY = null;
291
-
292
- Diva.Events.subscribe('ViewerDidLoad', function (settings)
293
- {
294
- assert.isOk(!settings.inFullscreen, "Not in fullscreen initially");
295
-
296
- var state = this.getState();
297
- initialX = state.x;
298
- initialY = state.y;
299
-
300
- this.enterFullscreenMode();
301
- });
302
-
303
- Diva.Events.subscribe('ModeDidSwitch', function (inFullscreen)
304
- {
305
- if (inFullscreen)
306
- {
307
- assert.isOk(this.getSettings().inFullscreen, "Should now be in fullscreen");
308
- assert.isOk(document.body.classList.contains('diva-hide-scrollbar'), "Body should have the hide-scrollbar class");
309
-
310
- this.leaveFullscreenMode();
311
- }
312
- else
313
- {
314
- var state = this.getState();
315
-
316
- assert.isOk(!this.getSettings().inFullscreen, "Should now not be in fullscreen");
317
- assert.strictEqual(state.x, initialX, 'Entering and leaving fullscreen mode should not change the x position');
318
- assert.strictEqual(state.y, initialY, 'Entering and leaving fullscreen mode should not change the y position');
319
-
320
- done();
321
- }
322
- });
323
-
324
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
325
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
326
- });
327
- });
328
-
329
- it("Jumping to page in Book view", function (done)
330
- {
331
- Diva.Events.subscribe('ViewerDidLoad', function (settings)
332
- {
333
- this.gotoPageByIndex(5);
334
-
335
- assert.isOk(settings.inBookLayout, "Should be in book layout");
336
- assert.strictEqual(el(settings.selector + 'current-page').innerText, 'Folio 003r - Folio 004r', "Toolbar should indicate label for page 6");
337
-
338
- setTimeout(() =>
339
- {
340
- assert.isOk(this.isPageInViewport(5), "Page 6 (index 5) should be loaded");
341
-
342
- this.gotoPageByIndex(6);
343
- assert.strictEqual(el(settings.selector + 'current-page').innerText, 'Folio 003r - Folio 004r', "Toolbar should stay the same");
344
- assert.isOk(this.isPageInViewport(6), "Page 7 (index 6) should be loaded");
345
-
346
- done();
347
- }, 10);
348
- });
349
-
350
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
351
- objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
352
- inBookLayout: true
353
- });
354
- });
355
- });
@@ -1,68 +0,0 @@
1
- import Diva from '../source/js/diva';
2
- let v2Manifest = require('./manifests/iiifv2.json');
3
- let v3Manifest = require('./manifests/iiifv3.json');
4
-
5
- describe('IIIF Manifest Parsing', function ()
6
- {
7
- beforeEach(function ()
8
- {
9
- // recreate diva instance
10
- let oldWrapper = document.getElementById('parent-wrapper');
11
- oldWrapper.parentNode.removeChild(oldWrapper);
12
- let newWrapper = document.createElement('div');
13
- newWrapper.id = 'parent-wrapper';
14
- newWrapper.setAttribute('style', 'width: 984px;');
15
- let div = document.createElement('div');
16
- div.id = 'diva-wrapper';
17
- newWrapper.appendChild(div);
18
- document.body.appendChild(newWrapper);
19
-
20
- Diva.Events.unsubscribeAll();
21
- });
22
-
23
- it('can parse an IIIF v2 Manifest', function (done)
24
- {
25
- Diva.Events.subscribe('ObjectDidLoad', function (settings)
26
- {
27
- let m = settings.manifest;
28
- assert.isOk(m, 'Manifest should exist');
29
-
30
- assert.strictEqual(m.pages.length, 479, 'Manifest should have 479 pages');
31
- assert.strictEqual(m.maxZoom, 5, 'Manifest should have maxZoom of 5');
32
- assert.strictEqual(m.maxRatio, 1.584277299501586, 'Max ratio should be 1.5842...');
33
- assert.strictEqual(m.minRatio, 1.4961486180335297, 'Min ratio should be 1.4961...');
34
- assert.strictEqual(m.itemTitle, 'Salzinnes, CDN-Hsmu M2149.L4', 'Item title should be right');
35
- assert.isFalse(m.paged, 'Should not be paged');
36
- assert.strictEqual(m.pages[0].l, 'Folio 001r', 'First page should be Folio 001r');
37
-
38
- done();
39
- });
40
-
41
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
42
- objectData: v2Manifest
43
- });
44
- });
45
-
46
- it('can parse an IIIF v3 Manifest', function (done)
47
- {
48
- Diva.Events.subscribe('ObjectDidLoad', function (settings)
49
- {
50
- let m = settings.manifest;
51
- assert.isOk(m, 'Manifest should exist');
52
-
53
- assert.strictEqual(m.pages.length, 299, 'Manifest should have 299 pages');
54
- assert.strictEqual(m.maxZoom, 5, 'Manifest should have maxZoom of 5');
55
- assert.strictEqual(m.maxRatio, 1.495655771617708, 'Max ratio should be 1.4956...');
56
- assert.strictEqual(m.minRatio, 1.187177597641857, 'Min ratio should be 1.1871...');
57
- assert.strictEqual(m.itemTitle, 'Bodleian Library: MS. Canon. Misc. 213', 'Item title should be right');
58
- assert.isTrue(m.paged, 'Should be paged');
59
- assert.strictEqual(m.pages[0].l, 'Upper board', 'First page should be Upper board');
60
-
61
- done();
62
- });
63
-
64
- let diva = new Diva('diva-wrapper', { // jshint ignore:line
65
- objectData: v3Manifest
66
- });
67
- });
68
- });