diva.js 6.0.2 → 7.2.4
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/.clang-format +7 -0
- package/.github/workflows/npm-publish.yml +45 -0
- package/LICENSE +55 -0
- package/Makefile +75 -0
- package/README.md +15 -114
- package/elm.json +32 -0
- package/package.json +12 -59
- package/review/elm.json +52 -0
- package/review/src/ReviewConfig.elm +87 -0
- package/scripts/elm-esm.sh +40 -0
- package/scripts/minify-css.mjs +31 -0
- package/src/Filters.elm +1044 -0
- package/src/Main.elm +1217 -0
- package/src/Model.elm +213 -0
- package/src/Msg.elm +59 -0
- package/src/Utilities.elm +46 -0
- package/src/View/CollectionExplorer.elm +172 -0
- package/src/View/Helpers.elm +86 -0
- package/src/View/HtmlRenderer.elm +136 -0
- package/src/View/Icons.elm +159 -0
- package/src/View/ManifestInfoModal.elm +363 -0
- package/src/View/PageViewModal.elm +1046 -0
- package/src/View/Sidebar.elm +786 -0
- package/src/View/Toolbar.elm +189 -0
- package/src/View.elm +244 -0
- package/src/diva.ts +802 -0
- package/src/filters.ts +1843 -0
- package/src/styles/app.css +328 -0
- package/src/styles/collection.css +75 -0
- package/src/styles/modal.css +388 -0
- package/src/styles/sidebar.css +215 -0
- package/src/styles/theme.css +39 -0
- package/src/styles/toolbar.css +154 -0
- package/src/viewer-element.ts +1307 -0
- package/testing/index.html +52 -0
- package/testing/testing.html +231 -0
- package/tsconfig.json +12 -0
- package/AUTHORS +0 -22
- package/build/diva.css +0 -554
- package/build/diva.css.map +0 -1
- package/build/diva.js +0 -9
- package/build/diva.js.map +0 -1
- package/build/plugins/download.js +0 -2
- package/build/plugins/download.js.map +0 -1
- package/build/plugins/manipulation.js +0 -2
- package/build/plugins/manipulation.js.map +0 -1
- package/build/plugins/metadata.js +0 -2
- package/build/plugins/metadata.js.map +0 -1
- package/index.html +0 -28
- package/karma.conf.js +0 -87
- package/source/css/_mixins.scss +0 -43
- package/source/css/_variables.scss +0 -50
- package/source/css/_viewer.scss +0 -462
- package/source/css/diva.scss +0 -15
- package/source/css/plugins/_manipulation.scss +0 -228
- package/source/css/plugins/_metadata.scss +0 -31
- package/source/img/adjust.svg +0 -11
- package/source/img/book-view.svg +0 -6
- package/source/img/close.svg +0 -6
- package/source/img/download.svg +0 -6
- package/source/img/from-fullscreen.svg +0 -8
- package/source/img/grid-fewer.svg +0 -6
- package/source/img/grid-more.svg +0 -6
- package/source/img/grid-view.svg +0 -6
- package/source/img/link.svg +0 -6
- package/source/img/metadata.svg +0 -9
- package/source/img/page-view.svg +0 -6
- package/source/img/to-fullscreen.svg +0 -11
- package/source/img/zoom-in.svg +0 -6
- package/source/img/zoom-out.svg +0 -7
- package/source/js/composite-image.js +0 -174
- package/source/js/diva-global.js +0 -7
- package/source/js/diva.js +0 -1543
- package/source/js/document-handler.js +0 -180
- package/source/js/document-layout.js +0 -286
- package/source/js/exceptions.js +0 -26
- package/source/js/gesture-events.js +0 -190
- package/source/js/grid-handler.js +0 -122
- package/source/js/iiif-source-adapter.js +0 -63
- package/source/js/image-cache.js +0 -113
- package/source/js/image-manifest.js +0 -157
- package/source/js/image-request-handler.js +0 -76
- package/source/js/interpolate-animation.js +0 -122
- package/source/js/page-layouts/book-layout.js +0 -161
- package/source/js/page-layouts/grid-layout.js +0 -97
- package/source/js/page-layouts/index.js +0 -38
- package/source/js/page-layouts/page-dimensions.js +0 -9
- package/source/js/page-layouts/singles-layout.js +0 -27
- package/source/js/page-overlay-manager.js +0 -102
- package/source/js/page-tools-overlay.js +0 -95
- package/source/js/parse-iiif-manifest.js +0 -302
- package/source/js/plugins/_filters.js +0 -679
- package/source/js/plugins/download.js +0 -83
- package/source/js/plugins/manipulation.js +0 -837
- package/source/js/plugins/metadata.js +0 -190
- package/source/js/renderer.js +0 -584
- package/source/js/settings-view.js +0 -30
- package/source/js/tile-coverage-map.js +0 -25
- package/source/js/toolbar.js +0 -573
- package/source/js/utils/dragscroll.js +0 -106
- package/source/js/utils/elt.js +0 -94
- package/source/js/utils/events.js +0 -190
- package/source/js/utils/get-scrollbar-width.js +0 -29
- package/source/js/utils/hash-params.js +0 -86
- package/source/js/utils/parse-label-value.js +0 -34
- package/source/js/utils/vanilla.kinetic.js +0 -527
- package/source/js/validation-runner.js +0 -177
- package/source/js/viewer-core.js +0 -1514
- package/source/js/viewport.js +0 -143
- package/test/_setup.js +0 -13
- package/test/composite-image_test.js +0 -94
- package/test/diva_test.js +0 -43
- package/test/hash-params_test.js +0 -221
- package/test/image-cache_test.js +0 -106
- package/test/main.js +0 -6
- package/test/manifests/beromunsterManifest.json +0 -15514
- package/test/manifests/iiifv2.json +0 -11032
- package/test/manifests/iiifv2pages.json +0 -30437
- package/test/manifests/iiifv3.json +0 -10965
- package/test/navigation_test.js +0 -355
- package/test/parse-iiif-manifest_test.js +0 -68
- package/test/public_test.js +0 -881
- package/test/settings_test.js +0 -487
- package/test/utils/book-layout_test.js +0 -148
- package/test/utils/elt_test.js +0 -102
- package/test/utils/events_test.js +0 -245
- package/test/utils/hash-params_test.js +0 -79
- package/test/utils/parse-label-value_test.js +0 -45
- package/test/z_plugins_test.js +0 -180
- package/webpack.config.js +0 -58
- package/webpack.config.test.js +0 -45
package/test/public_test.js
DELETED
|
@@ -1,881 +0,0 @@
|
|
|
1
|
-
import Diva from '../source/js/diva';
|
|
2
|
-
|
|
3
|
-
describe('Public Functions', function ()
|
|
4
|
-
{
|
|
5
|
-
beforeEach(function ()
|
|
6
|
-
{
|
|
7
|
-
// recreate diva instance
|
|
8
|
-
let oldWrapper = document.getElementById('parent-wrapper');
|
|
9
|
-
oldWrapper.parentNode.removeChild(oldWrapper);
|
|
10
|
-
let newWrapper = document.createElement('div');
|
|
11
|
-
newWrapper.id = 'parent-wrapper';
|
|
12
|
-
newWrapper.setAttribute('style', 'width: 984px;');
|
|
13
|
-
let div = document.createElement('div');
|
|
14
|
-
div.id = 'diva-wrapper';
|
|
15
|
-
newWrapper.appendChild(div);
|
|
16
|
-
document.body.appendChild(newWrapper);
|
|
17
|
-
|
|
18
|
-
Diva.Events.unsubscribeAll();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('getItemTitle()', function (done)
|
|
22
|
-
{
|
|
23
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
24
|
-
{
|
|
25
|
-
assert.strictEqual(this.getItemTitle(), "Salzinnes, CDN-Hsmu M2149.L4", "The title should be Salzinnes, CDN-Hsmu M2149.L4");
|
|
26
|
-
done();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
30
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("getCurrentPage()", function (done)
|
|
35
|
-
{
|
|
36
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
37
|
-
{
|
|
38
|
-
assert.strictEqual(this.getActivePageIndex(), 0, "Initial page should be 0");
|
|
39
|
-
this.gotoPageByIndex(200); // Go to page index 200
|
|
40
|
-
assert.strictEqual(this.getActivePageIndex(), 200, "The page index should now be 200");
|
|
41
|
-
this.gotoPageByIndex(5);
|
|
42
|
-
assert.strictEqual(this.getActivePageIndex(), 5, "The page index should now be 5");
|
|
43
|
-
|
|
44
|
-
Diva.Events.subscribe('ViewDidSwitch', function ()
|
|
45
|
-
{
|
|
46
|
-
this.gotoPageByIndex(100);
|
|
47
|
-
assert.strictEqual(this.getActivePageIndex(), 100, 'Transitions in grid mode should work');
|
|
48
|
-
|
|
49
|
-
done();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
this.enterGridView();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
56
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("getActivePageIndex()", function (done)
|
|
61
|
-
{
|
|
62
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
63
|
-
{
|
|
64
|
-
assert.strictEqual(this.getActivePageIndex(), 0, "Initial page should be 0");
|
|
65
|
-
this.gotoPageByIndex(300);
|
|
66
|
-
assert.strictEqual(this.getActivePageIndex(), 300, "The page index should now be 300");
|
|
67
|
-
|
|
68
|
-
// Reset it to the first page
|
|
69
|
-
this.gotoPageByIndex(0);
|
|
70
|
-
assert.strictEqual(this.getActivePageIndex(), 0, "The page index should now be 0");
|
|
71
|
-
done();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
75
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("get/setZoomLevel(), zoomIn() and zoomOut()", function (done)
|
|
80
|
-
{
|
|
81
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
82
|
-
{
|
|
83
|
-
assert.strictEqual(this.getZoomLevel(), 2, "Initial zoom level should be 2");
|
|
84
|
-
assert.isOk(this.zoomOut(), "It should be possible to zoom out once");
|
|
85
|
-
assert.strictEqual(this.getZoomLevel(), 1, "Zoom level should now be 1");
|
|
86
|
-
assert.isOk(!this.zoomOut(), "It should not be possible to zoom out again");
|
|
87
|
-
assert.strictEqual(this.getZoomLevel(), 1, "Zoom level should still be 1");
|
|
88
|
-
|
|
89
|
-
assert.isOk(this.zoomIn(), "It should be possible to zoom in");
|
|
90
|
-
assert.strictEqual(this.getZoomLevel(), 2, "Zoom level should now be 2");
|
|
91
|
-
assert.isOk(this.zoomIn(), "Zooming in again");
|
|
92
|
-
assert.strictEqual(this.getZoomLevel(), 3, "Zoom level should now be 3");
|
|
93
|
-
assert.isOk(!this.zoomIn(), "It should not be possible to zoom in again (hit max)");
|
|
94
|
-
assert.strictEqual(this.getZoomLevel(), 3, "Zoom level should still be 3");
|
|
95
|
-
|
|
96
|
-
assert.isOk(!this.setZoomLevel(5), "Setting zoom level to 5 should fail");
|
|
97
|
-
assert.strictEqual(this.getZoomLevel(), 3, "Zoom level should still be 3");
|
|
98
|
-
|
|
99
|
-
this.changeView('grid');
|
|
100
|
-
assert.isOk(this.setZoomLevel(2), "Setting zoom level to 2 from grid should be fine");
|
|
101
|
-
assert.strictEqual(this.getZoomLevel(), 2, "Zoom level should now be 2");
|
|
102
|
-
|
|
103
|
-
this.changeView('book');
|
|
104
|
-
this.changeView(' ');
|
|
105
|
-
done();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
109
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
110
|
-
zoomLevel: 2,
|
|
111
|
-
minZoomLevel: 1,
|
|
112
|
-
maxZoomLevel: 3
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("isRegionInViewport()", function (done)
|
|
117
|
-
{
|
|
118
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
119
|
-
{
|
|
120
|
-
// Can only do fairly simple checks
|
|
121
|
-
assert.isOk(this.isRegionInViewport(0, 100, 200, 100, 150));
|
|
122
|
-
assert.isOk(!this.isRegionInViewport(0, 100, -200, 100, 100));
|
|
123
|
-
assert.isOk(!this.isRegionInViewport(40, 100, 50, 100, 200));
|
|
124
|
-
|
|
125
|
-
done();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
129
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
130
|
-
viewportMargin: 0
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("isPageInViewport()", function (done)
|
|
135
|
-
{
|
|
136
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
137
|
-
{
|
|
138
|
-
assert.isOk(this.isPageInViewport(0), 'The first page should be in the viewport');
|
|
139
|
-
assert.isOk(!this.isPageInViewport(100), 'The hundredth page should not be in the viewport');
|
|
140
|
-
|
|
141
|
-
this.enterGridView();
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
Diva.Events.subscribe('ViewDidSwitch', function ()
|
|
145
|
-
{
|
|
146
|
-
assert.isOk(this.isPageInViewport(0), 'The first page should be in the viewport grid');
|
|
147
|
-
assert.isOk(this.isPageInViewport(5), 'The fifth page should be in the viewport grid');
|
|
148
|
-
assert.isOk(!this.isPageInViewport(100), 'The hundredth page should not be in the viewport grid');
|
|
149
|
-
|
|
150
|
-
done();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
154
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("toggleFullscreenMode(), enterFullscreenMode(), leaveFullscreenMode()", function (done)
|
|
159
|
-
{
|
|
160
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
161
|
-
{
|
|
162
|
-
assert.isOk(!settings.inFullscreen, "Should not be in fullscreen initially");
|
|
163
|
-
this.toggleFullscreenMode();
|
|
164
|
-
assert.isOk(settings.inFullscreen, "Should now be in fullscreen");
|
|
165
|
-
assert.isOk(!this.enterFullscreenMode(), "Should not be possible to enter fullscreen");
|
|
166
|
-
assert.isOk(settings.inFullscreen, "Should still be in fullscreen");
|
|
167
|
-
assert.isOk(this.leaveFullscreenMode(), "Should be possible to exit fullscreen");
|
|
168
|
-
assert.isOk(!settings.inFullscreen, "No longer in fullscreen");
|
|
169
|
-
assert.isOk(!this.leaveFullscreenMode(), "Should not be possible to exit fullscreen");
|
|
170
|
-
assert.isOk(!settings.inFullscreen, "Still not in fullscreen");
|
|
171
|
-
assert.isOk(this.enterFullscreenMode(), "Should be possible to enter fullscreen");
|
|
172
|
-
this.toggleFullscreenMode();
|
|
173
|
-
assert.isOk(!settings.inFullscreen, "Should now be out of fullscreen");
|
|
174
|
-
done();
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
178
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("enterGridView(), leaveGridView()", function (done)
|
|
183
|
-
{
|
|
184
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
185
|
-
{
|
|
186
|
-
assert.isOk(!settings.inGrid, "Should not be in grid initially");
|
|
187
|
-
this.enterGridView();
|
|
188
|
-
assert.isOk(settings.inGrid, "Should now be in grid");
|
|
189
|
-
assert.isOk(!this.enterGridView(), "Should not be possible to enter grid");
|
|
190
|
-
assert.isOk(settings.inGrid, "Should still be in grid");
|
|
191
|
-
assert.isOk(this.leaveGridView(), "Should be possible to exit grid");
|
|
192
|
-
assert.isOk(!settings.inGrid, "No longer in grid");
|
|
193
|
-
assert.isOk(!this.leaveGridView(), "Should not be possible to exit grid");
|
|
194
|
-
assert.isOk(!settings.inGrid, "Still not in grid");
|
|
195
|
-
assert.isOk(this.enterGridView(), "Should be possible to enter grid");
|
|
196
|
-
done();
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
200
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('goToPageByName(filename, xAnchor, yAnchor)', function (done)
|
|
205
|
-
{
|
|
206
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
207
|
-
{
|
|
208
|
-
assert.isOk(this.gotoPageByName('https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_001v.jp2', "right", "center"), "It should find the page index for folio-001v");
|
|
209
|
-
assert.strictEqual(settings.activePageIndex, 1, "Now the page number should be 2 (index 1)");
|
|
210
|
-
assert.strictEqual(settings.viewport.top, 1103, "The page should be anchored to the center (vertically)");
|
|
211
|
-
assert.strictEqual(settings.viewport.left, 0, "The page should be anchored to the right");
|
|
212
|
-
|
|
213
|
-
done();
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
217
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it("gotoPageByURI(uri, xAnchor, yAnchor)", function (done)
|
|
222
|
-
{
|
|
223
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
224
|
-
{
|
|
225
|
-
assert.strictEqual(settings.activePageIndex, 0, "Initial page number should be 1");
|
|
226
|
-
assert.isOk(!this.gotoPageByURI('https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_000r.jp2'), "It should not find anything for 000r.jp2");
|
|
227
|
-
assert.isOk(this.gotoPageByURI('https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_001v.jp2', "right", "center"), "It should find the page index for folio-001v");
|
|
228
|
-
assert.strictEqual(settings.activePageIndex, 1, "Now the page number should be 2");
|
|
229
|
-
|
|
230
|
-
assert.strictEqual(settings.viewport.top, 1103, "The page should be anchored to the center (vertically)");
|
|
231
|
-
assert.strictEqual(settings.viewport.left, 0, "The page should be anchored to the right");
|
|
232
|
-
this.gotoPageByIndex(1, "left", "top");
|
|
233
|
-
assert.strictEqual(settings.viewport.top, 917, "The page should be anchored to the top");
|
|
234
|
-
assert.strictEqual(settings.viewport.left, 0, "The page should be anchored to the left");
|
|
235
|
-
this.gotoPageByIndex(2, "right", "bottom");
|
|
236
|
-
assert.strictEqual(settings.viewport.bottom, 2700, "The page should be anchored to the bottom");
|
|
237
|
-
|
|
238
|
-
done();
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
242
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it("getPageIndex()", function (done)
|
|
247
|
-
{
|
|
248
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
249
|
-
{
|
|
250
|
-
assert.strictEqual(this._getPageIndex('https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_001v.jp2'), 1, "Valid filename");
|
|
251
|
-
assert.strictEqual(this._getPageIndex('https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_001lolv.jp2'), -1, "Invalid filename");
|
|
252
|
-
|
|
253
|
-
done();
|
|
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
|
-
});
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
// Can't really test the getCurrentURL function
|
|
262
|
-
|
|
263
|
-
// Can't really test getURLHash easily either
|
|
264
|
-
// Since it relies on getState, we can test the public version of that instead
|
|
265
|
-
|
|
266
|
-
it("getState()", function (done)
|
|
267
|
-
{
|
|
268
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
269
|
-
{
|
|
270
|
-
var viewportHeight = 494;
|
|
271
|
-
var pageDimens = this.getCurrentPageDimensionsAtCurrentZoomLevel();
|
|
272
|
-
|
|
273
|
-
var expected = {
|
|
274
|
-
f: false,
|
|
275
|
-
v: 'd',
|
|
276
|
-
i: 'https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_001r.jp2',
|
|
277
|
-
n: 5,
|
|
278
|
-
p: false,
|
|
279
|
-
x: pageDimens.width / 2,
|
|
280
|
-
y: viewportHeight / 2,
|
|
281
|
-
z: 2
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
var actual = this.getState();
|
|
285
|
-
|
|
286
|
-
// Sanity check
|
|
287
|
-
assert.deepEqual(Object.keys(actual).sort(), Object.keys(expected).sort(), 'State shape should be as expected');
|
|
288
|
-
|
|
289
|
-
Object.keys(expected).forEach(function (key)
|
|
290
|
-
{
|
|
291
|
-
if (key === 'x')
|
|
292
|
-
assert.closeTo(actual[key], 456, 1, "State key '" + key + "'");
|
|
293
|
-
else
|
|
294
|
-
assert.strictEqual(actual[key], expected[key], "State key '" + key + "'");
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
this.changeView('book');
|
|
298
|
-
assert.strictEqual(this.getState().v, 'b', 'View state should be book');
|
|
299
|
-
|
|
300
|
-
done();
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
304
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it("setState()", function (done)
|
|
309
|
-
{
|
|
310
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
311
|
-
{
|
|
312
|
-
var state = {
|
|
313
|
-
f: true,
|
|
314
|
-
v: 'd',
|
|
315
|
-
i: "https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_003r.jp2",
|
|
316
|
-
n: 3,
|
|
317
|
-
p: false,
|
|
318
|
-
x: 500,
|
|
319
|
-
y: 300,
|
|
320
|
-
z: 3
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
this.setState(state);
|
|
324
|
-
assert.isOk(settings.inFullscreen, "Should now be in fullscreen");
|
|
325
|
-
assert.isOk(!settings.inGrid, "Should not be in grid");
|
|
326
|
-
assert.isOk(!settings.inBookLayout, "Should not be in book view");
|
|
327
|
-
assert.strictEqual(settings.activePageIndex, 4, "Current page should be 5 (index of 4)");
|
|
328
|
-
assert.strictEqual(settings.pagesPerRow, 3, "Pages per row should be 3");
|
|
329
|
-
assert.strictEqual(settings.zoomLevel, 3, "Zoom level should be 3");
|
|
330
|
-
|
|
331
|
-
// Recompute the offsets from first principles
|
|
332
|
-
var index = this._getPageIndex("https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_003r.jp2");
|
|
333
|
-
var offset = this.getPageOffset(index);
|
|
334
|
-
var viewportElem = settings.viewportElement;
|
|
335
|
-
// var x = viewportElem.scrollLeft - offset.left + (viewportElem.clientWidth / 2);
|
|
336
|
-
var y = viewportElem.scrollTop - offset.top + (viewportElem.clientHeight / 2);
|
|
337
|
-
|
|
338
|
-
// NOTE: throws error in headless for some reason, works fine in debug though
|
|
339
|
-
// assert.closeTo(x, 925, 1, "x offset should be the specified value");
|
|
340
|
-
assert.closeTo(y, 300, 1, "y offset should be the specified value");
|
|
341
|
-
|
|
342
|
-
state = {
|
|
343
|
-
f: false,
|
|
344
|
-
v: 'g',
|
|
345
|
-
i: "https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_005v.jp2",
|
|
346
|
-
n: 4,
|
|
347
|
-
p: true,
|
|
348
|
-
x: 100,
|
|
349
|
-
y: 200,
|
|
350
|
-
z: 4
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
this.setState(state);
|
|
354
|
-
assert.isOk(!settings.inFullscreen, "Should not be in fullscreen");
|
|
355
|
-
assert.isOk(settings.inGrid, "Should be in grid");
|
|
356
|
-
assert.strictEqual(settings.activePageIndex, 9, "Current page should be 005v.jp2 (index of 9)");
|
|
357
|
-
assert.strictEqual(settings.pagesPerRow, 4, "Pages per row should be 4");
|
|
358
|
-
assert.strictEqual(settings.zoomLevel, 4, "Zoom level should be 4");
|
|
359
|
-
|
|
360
|
-
done();
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
364
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
it("translateFromMaxZoomLevel()", function (done)
|
|
369
|
-
{
|
|
370
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
371
|
-
{
|
|
372
|
-
var state = {
|
|
373
|
-
f: true,
|
|
374
|
-
v: 'd',
|
|
375
|
-
i: "https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_003r.jp2",
|
|
376
|
-
n: 3,
|
|
377
|
-
p: false,
|
|
378
|
-
x: 500,
|
|
379
|
-
y: 300,
|
|
380
|
-
z: this.getMaxZoomLevel()
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
this.setState(state);
|
|
384
|
-
|
|
385
|
-
var boxOnMaxPage = {x: 100, y: 100, width:1234, height:1324};
|
|
386
|
-
|
|
387
|
-
// first check to make sure the box on the max zoom level is the same as the box we feed in.
|
|
388
|
-
assert.strictEqual(this.translateFromMaxZoomLevel(100), boxOnMaxPage.x);
|
|
389
|
-
assert.strictEqual(this.translateFromMaxZoomLevel(100), boxOnMaxPage.y);
|
|
390
|
-
assert.strictEqual(this.translateFromMaxZoomLevel(1234), boxOnMaxPage.width);
|
|
391
|
-
assert.strictEqual(this.translateFromMaxZoomLevel(1324), boxOnMaxPage.height);
|
|
392
|
-
|
|
393
|
-
// reset the state to a different zoom level
|
|
394
|
-
state = {
|
|
395
|
-
f: true,
|
|
396
|
-
v: 'd',
|
|
397
|
-
i: "https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_003r.jp2",
|
|
398
|
-
n: 3,
|
|
399
|
-
p: false,
|
|
400
|
-
x: 500,
|
|
401
|
-
y: 300,
|
|
402
|
-
z: 2
|
|
403
|
-
};
|
|
404
|
-
this.setState(state);
|
|
405
|
-
|
|
406
|
-
// check that the box translation has changed accordingly.
|
|
407
|
-
assert.strictEqual(this.translateFromMaxZoomLevel(boxOnMaxPage.x), 12.5);
|
|
408
|
-
assert.strictEqual(this.translateFromMaxZoomLevel(boxOnMaxPage.y), 12.5);
|
|
409
|
-
assert.strictEqual(this.translateFromMaxZoomLevel(boxOnMaxPage.width), 154.25);
|
|
410
|
-
assert.strictEqual(this.translateFromMaxZoomLevel(boxOnMaxPage.height), 165.5);
|
|
411
|
-
|
|
412
|
-
done();
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
416
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
417
|
-
});
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
it("translateToMaxZoomLevel()", function (done)
|
|
421
|
-
{
|
|
422
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
423
|
-
{
|
|
424
|
-
var state = {
|
|
425
|
-
f: true,
|
|
426
|
-
v: 'd',
|
|
427
|
-
i: "https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_003r.jp2",
|
|
428
|
-
n: 3,
|
|
429
|
-
p: false,
|
|
430
|
-
x: 500,
|
|
431
|
-
y: 300,
|
|
432
|
-
z: this.getMaxZoomLevel()
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
this.setState(state);
|
|
436
|
-
|
|
437
|
-
var boxOnThisPage = {x: 10, y: 10, width:123, height:132};
|
|
438
|
-
|
|
439
|
-
// first check to make sure the box on the max zoom level is the same as the box we feed in.
|
|
440
|
-
assert.strictEqual(this.translateToMaxZoomLevel(10), boxOnThisPage.x);
|
|
441
|
-
assert.strictEqual(this.translateToMaxZoomLevel(10), boxOnThisPage.y);
|
|
442
|
-
assert.strictEqual(this.translateToMaxZoomLevel(123), boxOnThisPage.width);
|
|
443
|
-
assert.strictEqual(this.translateToMaxZoomLevel(132), boxOnThisPage.height);
|
|
444
|
-
|
|
445
|
-
// reset the state to a different zoom level
|
|
446
|
-
state = {
|
|
447
|
-
f: true,
|
|
448
|
-
v: 'd',
|
|
449
|
-
i: "https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_003r.jp2",
|
|
450
|
-
n: 3,
|
|
451
|
-
p: false,
|
|
452
|
-
x: 500,
|
|
453
|
-
y: 300,
|
|
454
|
-
z: 2
|
|
455
|
-
};
|
|
456
|
-
this.setState(state);
|
|
457
|
-
|
|
458
|
-
// console.log(this.translateToMaxZoomLevel(boxOnThisPage.x));
|
|
459
|
-
// check that the box translation has changed accordingly. This assumes that
|
|
460
|
-
// the co-ordinate we want to translate is on the current zoom level (2), and we want
|
|
461
|
-
// to get it on the max page. Thus: 123 * (4-2)^2 = 984
|
|
462
|
-
assert.strictEqual(this.translateToMaxZoomLevel(boxOnThisPage.x), 80);
|
|
463
|
-
assert.strictEqual(this.translateToMaxZoomLevel(boxOnThisPage.y), 80);
|
|
464
|
-
assert.strictEqual(this.translateToMaxZoomLevel(boxOnThisPage.width), 984);
|
|
465
|
-
assert.strictEqual(this.translateToMaxZoomLevel(boxOnThisPage.height), 1056);
|
|
466
|
-
|
|
467
|
-
done();
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
471
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
it("getPageDimensionsAtCurrentZoomLevel([pageIndex])", function (done)
|
|
476
|
-
{
|
|
477
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
478
|
-
{
|
|
479
|
-
var current = this.getCurrentPageDimensionsAtCurrentZoomLevel();
|
|
480
|
-
var page10 = this.getCurrentPageDimensionsAtCurrentZoomLevel();
|
|
481
|
-
|
|
482
|
-
assert.deepEqual(current, page10, 'It should default to the current page');
|
|
483
|
-
assert.ok(typeof page10.height === 'number' && typeof page10.width === 'number', 'It should ... have numbers?');
|
|
484
|
-
|
|
485
|
-
this.leaveGridView();
|
|
486
|
-
|
|
487
|
-
let fcn = () => { this.getPageDimensionsAtCurrentZoomLevel(-5); };
|
|
488
|
-
expect(fcn).to.throw('Invalid Page Index');
|
|
489
|
-
|
|
490
|
-
done();
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
494
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
495
|
-
goDirectlyTo: 10,
|
|
496
|
-
inGrid: true
|
|
497
|
-
});
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
it('toggleOrientation()', function (done)
|
|
501
|
-
{
|
|
502
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
503
|
-
{
|
|
504
|
-
assert.isOk(this.isVerticallyOriented(), 'Should be vertically oriented');
|
|
505
|
-
this.toggleOrientation();
|
|
506
|
-
assert.isOk(!this.isVerticallyOriented(), 'Should no longer be vertically oriented');
|
|
507
|
-
done();
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
511
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
it('toggleNonPagedPagesVisibility()', function (done)
|
|
516
|
-
{
|
|
517
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
518
|
-
{
|
|
519
|
-
assert.isOk(!this.settings.showNonPagedPages, 'Should not show non paged pages');
|
|
520
|
-
this.toggleNonPagedPagesVisibility();
|
|
521
|
-
assert.isOk(this.settings.showNonPagedPages, 'Should show non paged pages');
|
|
522
|
-
|
|
523
|
-
this.showNonPagedPages();
|
|
524
|
-
this.hideNonPagedPages();
|
|
525
|
-
done();
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
529
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
530
|
-
});
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
it('setGridPagesPerRow(pagesPerRow)', function (done)
|
|
534
|
-
{
|
|
535
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
536
|
-
{
|
|
537
|
-
this.setGridPagesPerRow(4);
|
|
538
|
-
assert.isOk(this.settings.inGrid, 'Should now be in grid');
|
|
539
|
-
assert.strictEqual(this.getGridPagesPerRow(), 4, 'Should be 4 pages per row');
|
|
540
|
-
done();
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
544
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
it('isInFullscreen()', function (done)
|
|
549
|
-
{
|
|
550
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
551
|
-
{
|
|
552
|
-
assert.isOk(!this.isInFullscreen(), 'Should not be in fullscreen');
|
|
553
|
-
done();
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
557
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
558
|
-
});
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
it('isReady()', function (done)
|
|
562
|
-
{
|
|
563
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
564
|
-
{
|
|
565
|
-
assert.isOk(this.isReady(), 'Viewer loaded, should be ready');
|
|
566
|
-
done();
|
|
567
|
-
});
|
|
568
|
-
|
|
569
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
570
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
assert.isOk(!diva.isReady(), 'Should not be ready yet');
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
it('isPageIndexValid(pageIndex)', function (done)
|
|
577
|
-
{
|
|
578
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
579
|
-
{
|
|
580
|
-
assert.isOk(this.isPageIndexValid(2), 'Page index 2 should be valid');
|
|
581
|
-
assert.isOk(!this.isPageIndexValid(-5), 'Page index -5 should not be valid');
|
|
582
|
-
done();
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
586
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
587
|
-
});
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
it('hasOtherImages(pageIndex)', function (done)
|
|
591
|
-
{
|
|
592
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
593
|
-
{
|
|
594
|
-
assert.isOk(!this.hasOtherImages(1), 'Page 1 should not have other images');
|
|
595
|
-
done();
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
599
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
600
|
-
});
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
it('gotoPageByLabel(label)', function (done)
|
|
604
|
-
{
|
|
605
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
606
|
-
{
|
|
607
|
-
this.gotoPageByLabel('folio 001v');
|
|
608
|
-
assert.strictEqual(this.getActivePageIndex(), 1, 'Should now be at page 2 (index 1)');
|
|
609
|
-
|
|
610
|
-
// try with number instead of label
|
|
611
|
-
this.gotoPageByLabel('asdfjkl');
|
|
612
|
-
assert.strictEqual(this.getActivePageIndex(), 1, 'Should still be on page 2');
|
|
613
|
-
done();
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
617
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
618
|
-
});
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
it('getPageIndexForPageXYValues(pageX, pageY)', function (done)
|
|
622
|
-
{
|
|
623
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
624
|
-
{
|
|
625
|
-
assert.strictEqual(this.getPageIndexForPageXYValues(-500, -500), -1, 'Index at (-500, -500) should be -1 (dne)');
|
|
626
|
-
done();
|
|
627
|
-
});
|
|
628
|
-
|
|
629
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
630
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
631
|
-
});
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
it('getPageDimensionsAtZoomLevel(pageIdx, zoomLevel)', function (done)
|
|
635
|
-
{
|
|
636
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
637
|
-
{
|
|
638
|
-
let dims = this.getPageDimensionsAtZoomLevel(0, 2);
|
|
639
|
-
assert.strictEqual(dims.width, 551, 'Width of first page at zoom 2 should be 551');
|
|
640
|
-
|
|
641
|
-
dims = this.getPageDimensionsAtZoomLevel(0, 10);
|
|
642
|
-
assert.strictEqual(dims.width, 4414, 'Zoom 10 should default to max, width should be 4414');
|
|
643
|
-
|
|
644
|
-
done();
|
|
645
|
-
});
|
|
646
|
-
|
|
647
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
648
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
assert.isOk(!diva.getPageDimensionsAtZoomLevel(0, 1), 'Page not loaded should return false');
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
it('getPageDimensions(pageIndex)', function (done)
|
|
655
|
-
{
|
|
656
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
657
|
-
{
|
|
658
|
-
assert.strictEqual(this.getPageDimensions(0).height, 874, 'Page 1 height should be 874');
|
|
659
|
-
assert.strictEqual(this.getPageDimensions(251).height, 866, 'Page 252 height should be 866');
|
|
660
|
-
|
|
661
|
-
done();
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
665
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
666
|
-
});
|
|
667
|
-
|
|
668
|
-
assert.isNull(diva.getPageDimensions(0), 'Should return null if diva not loaded yet');
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
it('getOtherImages(pageIndex)', function (done)
|
|
672
|
-
{
|
|
673
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
674
|
-
{
|
|
675
|
-
assert.isEmpty(this.getOtherImages(0), 'Page 1 should have no other images');
|
|
676
|
-
done();
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
680
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
681
|
-
});
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
it('getNumberOfPages() viewer not loaded', function ()
|
|
685
|
-
{
|
|
686
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
687
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
assert.isFalse(diva.getNumberOfPages(), 'Should return false if diva not loaded yet');
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
it('getMinZoomLevel()', function (done)
|
|
694
|
-
{
|
|
695
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
696
|
-
{
|
|
697
|
-
assert.strictEqual(this.getMinZoomLevel(), 0, 'Min zoom should be 0');
|
|
698
|
-
done();
|
|
699
|
-
});
|
|
700
|
-
|
|
701
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
702
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
703
|
-
});
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
it('getMaxZoomLevelForPage(pageIdx)', function (done)
|
|
707
|
-
{
|
|
708
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
709
|
-
{
|
|
710
|
-
assert.strictEqual(this.getMaxZoomLevelForPage(10), 5, 'Max zoom of page 10 should be 5');
|
|
711
|
-
done();
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
715
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
assert.isFalse(diva.getMaxZoomLevelForPage(0), 'Should return false if diva not loaded yet');
|
|
719
|
-
});
|
|
720
|
-
|
|
721
|
-
it('getInstanceSelector()', function (done)
|
|
722
|
-
{
|
|
723
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
724
|
-
{
|
|
725
|
-
// seems this function is actually broken (returns undefined). adding for coverage
|
|
726
|
-
this.getInstanceSelector();
|
|
727
|
-
done();
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
731
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
732
|
-
});
|
|
733
|
-
});
|
|
734
|
-
|
|
735
|
-
it('getFilenames()', function (done)
|
|
736
|
-
{
|
|
737
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
738
|
-
{
|
|
739
|
-
let filenames = this.getFilenames();
|
|
740
|
-
assert.strictEqual(filenames[0], 'https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_001r.jp2', 'First page URI should be right');
|
|
741
|
-
|
|
742
|
-
done();
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
746
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
747
|
-
});
|
|
748
|
-
});
|
|
749
|
-
|
|
750
|
-
it('getAllPageURIs()', function (done)
|
|
751
|
-
{
|
|
752
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
753
|
-
{
|
|
754
|
-
let URIs = this.getAllPageURIs();
|
|
755
|
-
assert.strictEqual(URIs[0], 'https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_001r.jp2', 'First page URI should be right');
|
|
756
|
-
|
|
757
|
-
done();
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
761
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
762
|
-
});
|
|
763
|
-
});
|
|
764
|
-
|
|
765
|
-
it('getCurrentPageFilename()', function (done)
|
|
766
|
-
{
|
|
767
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
768
|
-
{
|
|
769
|
-
assert.strictEqual(this.getCurrentPageFilename(), 'https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_006r.jp2', 'Page 10 filename should be right');
|
|
770
|
-
done();
|
|
771
|
-
});
|
|
772
|
-
|
|
773
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
774
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
775
|
-
goDirectlyTo: 10
|
|
776
|
-
});
|
|
777
|
-
});
|
|
778
|
-
|
|
779
|
-
it('getCurrentPageURI()', function (done)
|
|
780
|
-
{
|
|
781
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
782
|
-
{
|
|
783
|
-
assert.strictEqual(this.getCurrentPageURI(), 'https://images.simssa.ca/iiif/image/cdn-hsmu-m2149l4/cdn-hsmu-m2149l4_006r.jp2', 'Page 10 URI should be right');
|
|
784
|
-
done();
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
788
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
789
|
-
goDirectlyTo: 10
|
|
790
|
-
});
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
it('getCurrentCanvas()', function (done)
|
|
794
|
-
{
|
|
795
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
796
|
-
{
|
|
797
|
-
assert.strictEqual(this.getCurrentCanvas(), 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/canvas/folio-001r.json', 'Page 1 canvas should be right');
|
|
798
|
-
done();
|
|
799
|
-
});
|
|
800
|
-
|
|
801
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
802
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
803
|
-
});
|
|
804
|
-
});
|
|
805
|
-
|
|
806
|
-
it('getCurrentPageOffset()', function (done)
|
|
807
|
-
{
|
|
808
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
809
|
-
{
|
|
810
|
-
assert.strictEqual(this.getCurrentPageOffset().left, 27, 'First page left offset should be 27');
|
|
811
|
-
done();
|
|
812
|
-
});
|
|
813
|
-
|
|
814
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
815
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
816
|
-
});
|
|
817
|
-
});
|
|
818
|
-
|
|
819
|
-
it('getCurrentURL()', function (done)
|
|
820
|
-
{
|
|
821
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
822
|
-
{
|
|
823
|
-
// can't really assert this since it could change based on testing environment
|
|
824
|
-
this.getCurrentURL();
|
|
825
|
-
done();
|
|
826
|
-
});
|
|
827
|
-
|
|
828
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
829
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
830
|
-
});
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
it('disableDragScrollable(), enableDragScrollable()', function (done)
|
|
834
|
-
{
|
|
835
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
836
|
-
{
|
|
837
|
-
this.disableDragScrollable();
|
|
838
|
-
assert.isTrue(this.viewerState.viewportObject.hasAttribute('nochilddrag'), 'Should not be draggable');
|
|
839
|
-
this.enableDragScrollable();
|
|
840
|
-
assert.isFalse(this.viewerState.viewportObject.hasAttribute('nochilddrag'), 'Should be draggable');
|
|
841
|
-
|
|
842
|
-
done();
|
|
843
|
-
});
|
|
844
|
-
|
|
845
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
846
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
847
|
-
});
|
|
848
|
-
});
|
|
849
|
-
|
|
850
|
-
it('disableScrollable(), enableScrollable()', function (done)
|
|
851
|
-
{
|
|
852
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
853
|
-
{
|
|
854
|
-
this.disableScrollable();
|
|
855
|
-
assert.isFalse(this.viewerState.isScrollable, 'Should not be scrollable');
|
|
856
|
-
this.enableScrollable();
|
|
857
|
-
assert.isTrue(this.viewerState.isScrollable, 'Should be scrollable');
|
|
858
|
-
|
|
859
|
-
done();
|
|
860
|
-
});
|
|
861
|
-
|
|
862
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
863
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
864
|
-
});
|
|
865
|
-
});
|
|
866
|
-
|
|
867
|
-
it('deactivate()', function (done)
|
|
868
|
-
{
|
|
869
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
870
|
-
{
|
|
871
|
-
this.deactivate();
|
|
872
|
-
assert.isFalse(this.viewerState.isActiveDiva, 'Diva should no longer be active');
|
|
873
|
-
|
|
874
|
-
done();
|
|
875
|
-
});
|
|
876
|
-
|
|
877
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
878
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
879
|
-
});
|
|
880
|
-
});
|
|
881
|
-
});
|