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/settings_test.js
DELETED
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
import Diva from '../source/js/diva';
|
|
2
|
-
|
|
3
|
-
// jQuery mimic
|
|
4
|
-
let el = document.getElementById.bind(document);
|
|
5
|
-
|
|
6
|
-
describe('Settings', 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
|
-
|
|
26
|
-
it("adaptivePadding enabled", function (done)
|
|
27
|
-
{
|
|
28
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings) {
|
|
29
|
-
assert.notStrictEqual(settings.verticalPadding, 10, "Adaptive padding should be used, overrides vertical/horizontal");
|
|
30
|
-
assert.notStrictEqual(settings.horizontalPadding, 10, "Horizontal padding should be overridden by adaptive");
|
|
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
|
-
adaptivePadding: 0.10
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("adaptivePadding disabled, fixedPadding set", function (done)
|
|
41
|
-
{
|
|
42
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
43
|
-
{
|
|
44
|
-
assert.strictEqual(settings.verticalPadding, 11, "Vertical padding should be 11 (no plugins enabled)");
|
|
45
|
-
assert.strictEqual(settings.horizontalPadding, 11, "Horizontal padding should be 11 (fixedPadding)");
|
|
46
|
-
done();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
50
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
51
|
-
adaptivePadding: 0,
|
|
52
|
-
fixedPadding: 11,
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("enableFullscreen false", function (done)
|
|
57
|
-
{
|
|
58
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
59
|
-
{
|
|
60
|
-
// Make sure the fullscreen icon is not there
|
|
61
|
-
assert.isNull(el(settings.selector + 'fullscreen-icon'), "Fullscreen icon should not be present");
|
|
62
|
-
done();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
66
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
67
|
-
enableFullscreen: false
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("enableFullscreen true", function (done)
|
|
72
|
-
{
|
|
73
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
74
|
-
{
|
|
75
|
-
// Make sure the fullscreen icon is there
|
|
76
|
-
assert.isNotNull(el(settings.selector + 'fullscreen-icon'), "Fullscreen icon should be present");
|
|
77
|
-
done();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
81
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
82
|
-
enableFullscreen: true
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("enableGotoPage false", function (done)
|
|
87
|
-
{
|
|
88
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
89
|
-
{
|
|
90
|
-
assert.isNull(el(settings.selector + 'goto-page'), "Go-to-page box should not be present");
|
|
91
|
-
done();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
95
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
96
|
-
enableGotoPage: false
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("enableGotoPage true", function (done)
|
|
101
|
-
{
|
|
102
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
103
|
-
{
|
|
104
|
-
assert.isNotNull(el(settings.selector + 'goto-page'), "Go-to-page box should be present");
|
|
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
|
-
enableGotoPage: true
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("fixedHeightGrid false", function (done)
|
|
115
|
-
{
|
|
116
|
-
Diva.Events.subscribe('ViewerDidLoad', function()
|
|
117
|
-
{
|
|
118
|
-
this.enterGridView();
|
|
119
|
-
|
|
120
|
-
assert.isOk(pagesHaveEqualDimension(this, 'width'), 'All page widths should be equal');
|
|
121
|
-
assert.isNotOk(pagesHaveEqualDimension(this, 'height'), 'All page heights should NOT be equal');
|
|
122
|
-
|
|
123
|
-
done();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
127
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
128
|
-
fixedHeightGrid: false
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("fixedHeightGrid true", function (done)
|
|
133
|
-
{
|
|
134
|
-
Diva.Events.subscribe('ViewerDidLoad', function()
|
|
135
|
-
{
|
|
136
|
-
this.enterGridView();
|
|
137
|
-
|
|
138
|
-
assert.isNotOk(pagesHaveEqualDimension(this, 'width'), 'All page widths should NOT be equal');
|
|
139
|
-
assert.isOk(pagesHaveEqualDimension(this, 'height'), 'All page heights should be equal');
|
|
140
|
-
|
|
141
|
-
done();
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
145
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
146
|
-
fixedHeightGrid: true
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
function pagesHaveEqualDimension(viewer, dimension)
|
|
151
|
-
{
|
|
152
|
-
var dimensions = [];
|
|
153
|
-
|
|
154
|
-
var numPages = viewer.getNumberOfPages();
|
|
155
|
-
|
|
156
|
-
for (var i = 0; i < numPages; i++)
|
|
157
|
-
dimensions.push(viewer.getPageDimensionsAtCurrentZoomLevel(i)[dimension]);
|
|
158
|
-
|
|
159
|
-
var first = dimensions[0];
|
|
160
|
-
|
|
161
|
-
return dimensions.every(function (dim)
|
|
162
|
-
{
|
|
163
|
-
// FIXME: Should floating point numbers happen here?
|
|
164
|
-
return Math.abs(dim - first) < 0.5;
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
it("goDirectlyTo, valid", function (done)
|
|
169
|
-
{
|
|
170
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
171
|
-
{
|
|
172
|
-
assert.strictEqual(settings.activePageIndex, 10, "The initial page index should be 10");
|
|
173
|
-
done();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
177
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
178
|
-
goDirectlyTo: 10
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("goDirectlyTo, invalid", function (done)
|
|
183
|
-
{
|
|
184
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
185
|
-
{
|
|
186
|
-
assert.strictEqual(settings.activePageIndex, 0, "The initial page index should be 0 (the fallback)");
|
|
187
|
-
done();
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
191
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
192
|
-
goDirectlyTo: -10
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('hashParamSuffix, omitted', function (done)
|
|
197
|
-
{
|
|
198
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
199
|
-
{
|
|
200
|
-
assert.strictEqual(typeof settings.hashParamSuffix, 'string', "If omitted, hashParamSuffix should default to... some string");
|
|
201
|
-
done();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
205
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json'
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('hashParamSuffix, provided', function (done)
|
|
210
|
-
{
|
|
211
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
212
|
-
{
|
|
213
|
-
assert.strictEqual(settings.hashParamSuffix, '!!!!!!!', 'User hashParamSuffix should be honoured');
|
|
214
|
-
done();
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
218
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
219
|
-
hashParamSuffix: '!!!!!!!'
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it("inBookLayout true", function (done)
|
|
224
|
-
{
|
|
225
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
226
|
-
{
|
|
227
|
-
assert.ok(settings.inBookLayout, 'inBookLayout should remain true after initialization');
|
|
228
|
-
assert.ok(this.getPageOffset(1).left < this.getPageOffset(2).left, 'Page 1 should be to the left of page 2');
|
|
229
|
-
assert.ok(this.getPageOffset(2).left > this.getPageOffset(3).left, 'Page 2 should be to the right of page 3');
|
|
230
|
-
done();
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
234
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
235
|
-
inBookLayout: true
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it("manifest.paged triggers inBookLayout", function (done)
|
|
240
|
-
{
|
|
241
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
242
|
-
{
|
|
243
|
-
assert.isOk(settings.manifest.paged, 'settings.manifest.paged should be true when manifest has viewingHint: paged');
|
|
244
|
-
assert.isOk(settings.inBookLayout, 'settings.inBookLayout should be true when manifest.paged is true');
|
|
245
|
-
|
|
246
|
-
done();
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
250
|
-
objectData: 'https://ddmal.github.io/diva.js/try/demo/beromunster-iiif.json'
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it("inGrid false", function (done)
|
|
255
|
-
{
|
|
256
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
257
|
-
{
|
|
258
|
-
assert.isOk(!settings.inGrid, "inGrid setting should still be false");
|
|
259
|
-
assert.strictEqual(el(settings.selector + 'view-menu').children[0].classList[0], 'diva-document-icon', "Current toolbar view icon should be the document icon");
|
|
260
|
-
done();
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
264
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
265
|
-
inGrid: false
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
it("inGrid true", function (done)
|
|
270
|
-
{
|
|
271
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
272
|
-
{
|
|
273
|
-
assert.isOk(settings.inGrid, "inGrid setting should be preserved");
|
|
274
|
-
assert.strictEqual(el(settings.selector + 'view-menu').children[0].classList[0], 'diva-grid-icon', "Current toolbar view icon should be the grid icon");
|
|
275
|
-
done();
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
279
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
280
|
-
inGrid: true
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// // imageDir cannot really be tested either
|
|
285
|
-
|
|
286
|
-
it("valid max/minPagesPerRow, valid pagesPerRow", function (done)
|
|
287
|
-
{
|
|
288
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
289
|
-
{
|
|
290
|
-
assert.strictEqual(settings.minPagesPerRow, 3, "minPagesPerRow should be 3");
|
|
291
|
-
assert.strictEqual(settings.maxPagesPerRow, 5, "maxPagesPerRow should be 5");
|
|
292
|
-
assert.strictEqual(settings.pagesPerRow, 5, "pagesPerRow is valid");
|
|
293
|
-
done();
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
297
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
298
|
-
minPagesPerRow: 3,
|
|
299
|
-
maxPagesPerRow: 5,
|
|
300
|
-
pagesPerRow: 5
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
it("invalid max/minPagesPerRow, invalid pagesPerRow", function (done)
|
|
305
|
-
{
|
|
306
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
307
|
-
{
|
|
308
|
-
assert.strictEqual(settings.minPagesPerRow, 2, "minPagesPerRow is invalid, set to 2");
|
|
309
|
-
assert.strictEqual(settings.maxPagesPerRow, 2, "maxPagesPerRow should be set to min");
|
|
310
|
-
assert.strictEqual(settings.pagesPerRow, 2, "invalid pages per row should be set to min");
|
|
311
|
-
done();
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
315
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
316
|
-
minPagesPerRow: 1,
|
|
317
|
-
maxPagesPerRow: 0,
|
|
318
|
-
pagesPerRow: 4
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it("max/minZoomLevel, invalid values", function (done)
|
|
323
|
-
{
|
|
324
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
325
|
-
{
|
|
326
|
-
assert.strictEqual(settings.minZoomLevel, 0, "minZoomLevel should be set to 0");
|
|
327
|
-
assert.strictEqual(settings.maxZoomLevel, 5, "maxZoomLevel should be set to 5");
|
|
328
|
-
done();
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
332
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
333
|
-
minZoomLevel: -2,
|
|
334
|
-
maxZoomLevel: 6,
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it("max/minZoomLevel, valid values, valid zoomLevel", function (done)
|
|
339
|
-
{
|
|
340
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
341
|
-
{
|
|
342
|
-
assert.strictEqual(settings.minZoomLevel, 1, "minZoomLevel should be set to 1");
|
|
343
|
-
assert.strictEqual(settings.maxZoomLevel, 3, "maxZoomLevel should be set to 3");
|
|
344
|
-
assert.strictEqual(settings.zoomLevel, 2, "zoomLevel should be 2");
|
|
345
|
-
done();
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
349
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
350
|
-
minZoomLevel: 1,
|
|
351
|
-
maxZoomLevel: 3,
|
|
352
|
-
zoomLevel: 2
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
it("max/minZoomLevel, valid values, invalid zoomLevel", function (done)
|
|
357
|
-
{
|
|
358
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
359
|
-
{
|
|
360
|
-
assert.strictEqual(settings.zoomLevel, 1, "Zoom level should be the minZoomLevel (1)");
|
|
361
|
-
done();
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
365
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
366
|
-
minZoomLevel: 1,
|
|
367
|
-
maxZoomLevel: 3,
|
|
368
|
-
zoomLevel: 0
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
it("max/minZoomLevel, invalid/valid values, invalid zoomLevel", function (done)
|
|
373
|
-
{
|
|
374
|
-
Diva.Events.subscribe('ViewerDidLoad', function (settings)
|
|
375
|
-
{
|
|
376
|
-
assert.strictEqual(settings.minZoomLevel, 2, "minZoomLevel should be set to 2 (valid)");
|
|
377
|
-
assert.strictEqual(settings.maxZoomLevel, 5, "maxZoomLevel should be set to 5 (invalid)");
|
|
378
|
-
assert.strictEqual(settings.zoomLevel, 2, "zoomLevel should be 2 (the minimum)");
|
|
379
|
-
done();
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
383
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
384
|
-
minZoomLevel: 2,
|
|
385
|
-
maxZoomLevel: -2,
|
|
386
|
-
zoomLevel: -2
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
it("object for objectData", function (done)
|
|
391
|
-
{
|
|
392
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
393
|
-
{
|
|
394
|
-
assert.strictEqual(this.getItemTitle(), "First page of Beromunster", "Should process an object for objectData like a normal manifest");
|
|
395
|
-
done();
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
399
|
-
objectData: {
|
|
400
|
-
"@context": "http://iiif.io/api/presentation/2/context.json",
|
|
401
|
-
"@id": "https://images.simssa.ca/iiif/image/beromunster/manifest.json",
|
|
402
|
-
"@type": "sc:Manifest",
|
|
403
|
-
"label": "First page of Beromunster",
|
|
404
|
-
"viewingHint": "paged",
|
|
405
|
-
"sequences": [
|
|
406
|
-
{
|
|
407
|
-
"@type": "sc:Sequence",
|
|
408
|
-
"canvases": [
|
|
409
|
-
{
|
|
410
|
-
"@id": "https://images.simssa.ca/iiif/image/beromunster/canvas/bm_001.json",
|
|
411
|
-
"@type": "sc:Canvas",
|
|
412
|
-
"label": "Bm 001",
|
|
413
|
-
"height": 4445,
|
|
414
|
-
"width": 2846,
|
|
415
|
-
"images": [
|
|
416
|
-
{
|
|
417
|
-
"@type": "oa:Annotation",
|
|
418
|
-
"motivation": "sc:painting",
|
|
419
|
-
"resource": {
|
|
420
|
-
"@id": "https://images.simssa.ca/iiif/image/beromunster/bm_001.tif/full/full/0/default.jpg",
|
|
421
|
-
"@type": "dctypes:Image",
|
|
422
|
-
"format": "image/jpeg",
|
|
423
|
-
"height": 4445,
|
|
424
|
-
"width": 2846,
|
|
425
|
-
"service": {
|
|
426
|
-
"@context": "http://iiif.io/api/image/2/context.json",
|
|
427
|
-
"@id": "https://images.simssa.ca/iiif/image/beromunster/bm_001.tif",
|
|
428
|
-
"profile": "http://iiif.io/api/image/2/level2.json"
|
|
429
|
-
}
|
|
430
|
-
},
|
|
431
|
-
"on": "https://images.simssa.ca/iiif/image/beromunster/canvas/bm_001.json"
|
|
432
|
-
}
|
|
433
|
-
]
|
|
434
|
-
}
|
|
435
|
-
]
|
|
436
|
-
}
|
|
437
|
-
]
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
// // pageLoadTimeout is a bit weird to test, but the code is simple so it should be fine
|
|
443
|
-
|
|
444
|
-
// // pagesPerRow is tested above, along with max/minPagesPerRow
|
|
445
|
-
|
|
446
|
-
// // No real point testing tileHeight/Width as we don't have images of different tile sizes
|
|
447
|
-
|
|
448
|
-
it("viewportMargin, value of 0", function (done)
|
|
449
|
-
{
|
|
450
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
451
|
-
{
|
|
452
|
-
var dv = this;
|
|
453
|
-
|
|
454
|
-
setTimeout(function ()
|
|
455
|
-
{
|
|
456
|
-
assert.isOk(dv.isPageInViewport(0), "The first page should be loaded");
|
|
457
|
-
assert.isNotOk(dv.isPageInViewport(1), "The second page should not be loaded");
|
|
458
|
-
done();
|
|
459
|
-
}, 100);
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
463
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
464
|
-
viewportMargin: 0
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
it("viewportMargin, value of 1000", function (done)
|
|
469
|
-
{
|
|
470
|
-
Diva.Events.subscribe('ViewerDidLoad', function ()
|
|
471
|
-
{
|
|
472
|
-
var dv = this;
|
|
473
|
-
|
|
474
|
-
// The second page should be visible after a timeout
|
|
475
|
-
setTimeout(function () {
|
|
476
|
-
assert.isOk(dv.isPageInViewport(0), "The first page should be loaded");
|
|
477
|
-
assert.isOk(dv.isPageInViewport(1), "The second page should be loaded");
|
|
478
|
-
done();
|
|
479
|
-
}, 100);
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
let diva = new Diva('diva-wrapper', { // jshint ignore:line
|
|
483
|
-
objectData: 'https://images.simssa.ca/iiif/manuscripts/cdn-hsmu-m2149l4/manifest.json',
|
|
484
|
-
viewportMargin: 1000
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
});
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import ImageManifest from '../../source/js/image-manifest';
|
|
2
|
-
import getBookLayout from '../../source/js/page-layouts/book-layout';
|
|
3
|
-
|
|
4
|
-
var beromunsterManifest = require('../manifests/beromunsterManifest.json');
|
|
5
|
-
var manifest = ImageManifest.fromIIIF(beromunsterManifest);
|
|
6
|
-
|
|
7
|
-
describe('Get Book Layout', function ()
|
|
8
|
-
{
|
|
9
|
-
it('In vertical orientation positions first page to the right', function ()
|
|
10
|
-
{
|
|
11
|
-
var layouts = getBookLayout({
|
|
12
|
-
manifest: manifest,
|
|
13
|
-
verticallyOriented: true
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
var firstGroup = layouts[0];
|
|
17
|
-
var width = manifest.getMaxPageDimensions(0).width;
|
|
18
|
-
|
|
19
|
-
assert.strictEqual(firstGroup.pages.length, 1, 'First group should be a single page');
|
|
20
|
-
assert.strictEqual(firstGroup.dimensions.width, 2 * width, 1, 'Group size should be twice page width');
|
|
21
|
-
assert.strictEqual(firstGroup.pages[0].groupOffset.left, width, 1, 'Page should be offset to the left by its width');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('In horizontal orientation, shrink first group to single page size', function ()
|
|
25
|
-
{
|
|
26
|
-
var layouts = getBookLayout({
|
|
27
|
-
manifest: manifest,
|
|
28
|
-
verticallyOriented: false
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
var firstGroup = layouts[0];
|
|
32
|
-
var width = manifest.getMaxPageDimensions(0).width;
|
|
33
|
-
|
|
34
|
-
assert.strictEqual(firstGroup.pages.length, 1, 'First group should be a single page');
|
|
35
|
-
assert.strictEqual(firstGroup.dimensions.width, width, 1, 'Group width should be page width');
|
|
36
|
-
assert.strictEqual(firstGroup.pages[0].groupOffset.left, 0, 1, 'Page should not be offset to the left');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('In vertical orientation, facing pages groups fit max height, width', function ()
|
|
40
|
-
{
|
|
41
|
-
var layouts = getBookLayout({
|
|
42
|
-
manifest: manifest,
|
|
43
|
-
verticallyOriented: true
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var group = layouts[1];
|
|
47
|
-
|
|
48
|
-
assertDifferentSizePages(group);
|
|
49
|
-
|
|
50
|
-
assertFitsMax(group, 'width');
|
|
51
|
-
assertFitsMax(group, 'height');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('In horizontal orientation, facing pages groups fit max height, tight width', function ()
|
|
55
|
-
{
|
|
56
|
-
var layouts = getBookLayout({
|
|
57
|
-
manifest: manifest,
|
|
58
|
-
verticallyOriented: false
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
var group = layouts[1];
|
|
62
|
-
|
|
63
|
-
assertDifferentSizePages(group);
|
|
64
|
-
assertFitsMax(group, 'height');
|
|
65
|
-
|
|
66
|
-
var width1 = group.pages[0].dimensions.width;
|
|
67
|
-
var width2 = group.pages[1].dimensions.width;
|
|
68
|
-
var groupWidth = group.dimensions.width;
|
|
69
|
-
|
|
70
|
-
assert.closeTo(groupWidth, width1 + width2, 1, 'Group width should be sum of page widths');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('In vertical orientation, final left page is left-aligned', function ()
|
|
74
|
-
{
|
|
75
|
-
var layouts = getBookLayout({
|
|
76
|
-
manifest: manifest,
|
|
77
|
-
verticallyOriented: true
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
var lastGroup = layouts[layouts.length - 1];
|
|
81
|
-
|
|
82
|
-
assert.strictEqual(lastGroup.pages.length, 1, 'Sanity check: Last group should be a single page');
|
|
83
|
-
|
|
84
|
-
assert.closeTo(lastGroup.dimensions.width,
|
|
85
|
-
lastGroup.pages[0].dimensions.width * 2,
|
|
86
|
-
1,
|
|
87
|
-
'Group width should be twice page width');
|
|
88
|
-
|
|
89
|
-
assert.strictEqual(lastGroup.dimensions.height,
|
|
90
|
-
lastGroup.pages[0].dimensions.height,
|
|
91
|
-
'Group height should be page height');
|
|
92
|
-
|
|
93
|
-
assert.closeTo(lastGroup.pages[0].groupOffset.left, 0, 1, 'Page should not be offset to the left');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('In horizontal orientation, final left page is is in tight-fit group', function ()
|
|
97
|
-
{
|
|
98
|
-
var layouts = getBookLayout({
|
|
99
|
-
manifest: manifest,
|
|
100
|
-
verticallyOriented: false
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
var lastGroup = layouts[layouts.length - 1];
|
|
104
|
-
|
|
105
|
-
assert.strictEqual(lastGroup.pages.length, 1, 'Sanity check: Last group should be a single page');
|
|
106
|
-
|
|
107
|
-
assert.deepEqual(lastGroup.dimensions, lastGroup.pages[0].dimensions, 1, 'Group size should be page size');
|
|
108
|
-
assert.closeTo(lastGroup.pages[0].groupOffset.left, 0, 1, 'Page should not be offset to the left');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('Displays facing pages in tight-fit group', function ()
|
|
112
|
-
{
|
|
113
|
-
var layouts = getBookLayout({
|
|
114
|
-
manifest: manifest,
|
|
115
|
-
verticallyOriented: true
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
var group = layouts[17];
|
|
119
|
-
|
|
120
|
-
assert.strictEqual(group.pages.length, 1, 'In own group');
|
|
121
|
-
assert.strictEqual(group.dimensions.width, group.pages[0].dimensions.width, 'Tight fit width');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
function assertFitsMax(group, dimension)
|
|
125
|
-
{
|
|
126
|
-
var p1 = group.pages[0].dimensions[dimension];
|
|
127
|
-
var p2 = group.pages[1].dimensions[dimension];
|
|
128
|
-
var g = group.dimensions[dimension];
|
|
129
|
-
|
|
130
|
-
var times = dimension === 'width' ? 2 : 1;
|
|
131
|
-
|
|
132
|
-
assert.closeTo(g, Math.max(p1, p2) * times, 1, 'Group ' + dimension + ' should be derived from max page ' + dimension);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function assertDifferentSizePages(group)
|
|
136
|
-
{
|
|
137
|
-
assertDimenDiffers(group, 'height');
|
|
138
|
-
assertDimenDiffers(group, 'width');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function assertDimenDiffers(group, dimension)
|
|
142
|
-
{
|
|
143
|
-
var p1 = group.pages[0].dimensions[dimension];
|
|
144
|
-
var p2 = group.pages[1].dimensions[dimension];
|
|
145
|
-
|
|
146
|
-
assert.notStrictEqual(p1, p2, 'Sanity check: page ' + dimension + ' differs');
|
|
147
|
-
}
|
|
148
|
-
});
|