diva.js 6.0.2 → 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 (131) 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 -114
  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/build/diva.css +0 -554
  40. package/build/diva.css.map +0 -1
  41. package/build/diva.js +0 -9
  42. package/build/diva.js.map +0 -1
  43. package/build/plugins/download.js +0 -2
  44. package/build/plugins/download.js.map +0 -1
  45. package/build/plugins/manipulation.js +0 -2
  46. package/build/plugins/manipulation.js.map +0 -1
  47. package/build/plugins/metadata.js +0 -2
  48. package/build/plugins/metadata.js.map +0 -1
  49. package/index.html +0 -28
  50. package/karma.conf.js +0 -87
  51. package/source/css/_mixins.scss +0 -43
  52. package/source/css/_variables.scss +0 -50
  53. package/source/css/_viewer.scss +0 -462
  54. package/source/css/diva.scss +0 -15
  55. package/source/css/plugins/_manipulation.scss +0 -228
  56. package/source/css/plugins/_metadata.scss +0 -31
  57. package/source/img/adjust.svg +0 -11
  58. package/source/img/book-view.svg +0 -6
  59. package/source/img/close.svg +0 -6
  60. package/source/img/download.svg +0 -6
  61. package/source/img/from-fullscreen.svg +0 -8
  62. package/source/img/grid-fewer.svg +0 -6
  63. package/source/img/grid-more.svg +0 -6
  64. package/source/img/grid-view.svg +0 -6
  65. package/source/img/link.svg +0 -6
  66. package/source/img/metadata.svg +0 -9
  67. package/source/img/page-view.svg +0 -6
  68. package/source/img/to-fullscreen.svg +0 -11
  69. package/source/img/zoom-in.svg +0 -6
  70. package/source/img/zoom-out.svg +0 -7
  71. package/source/js/composite-image.js +0 -174
  72. package/source/js/diva-global.js +0 -7
  73. package/source/js/diva.js +0 -1543
  74. package/source/js/document-handler.js +0 -180
  75. package/source/js/document-layout.js +0 -286
  76. package/source/js/exceptions.js +0 -26
  77. package/source/js/gesture-events.js +0 -190
  78. package/source/js/grid-handler.js +0 -122
  79. package/source/js/iiif-source-adapter.js +0 -63
  80. package/source/js/image-cache.js +0 -113
  81. package/source/js/image-manifest.js +0 -157
  82. package/source/js/image-request-handler.js +0 -76
  83. package/source/js/interpolate-animation.js +0 -122
  84. package/source/js/page-layouts/book-layout.js +0 -161
  85. package/source/js/page-layouts/grid-layout.js +0 -97
  86. package/source/js/page-layouts/index.js +0 -38
  87. package/source/js/page-layouts/page-dimensions.js +0 -9
  88. package/source/js/page-layouts/singles-layout.js +0 -27
  89. package/source/js/page-overlay-manager.js +0 -102
  90. package/source/js/page-tools-overlay.js +0 -95
  91. package/source/js/parse-iiif-manifest.js +0 -302
  92. package/source/js/plugins/_filters.js +0 -679
  93. package/source/js/plugins/download.js +0 -83
  94. package/source/js/plugins/manipulation.js +0 -837
  95. package/source/js/plugins/metadata.js +0 -190
  96. package/source/js/renderer.js +0 -584
  97. package/source/js/settings-view.js +0 -30
  98. package/source/js/tile-coverage-map.js +0 -25
  99. package/source/js/toolbar.js +0 -573
  100. package/source/js/utils/dragscroll.js +0 -106
  101. package/source/js/utils/elt.js +0 -94
  102. package/source/js/utils/events.js +0 -190
  103. package/source/js/utils/get-scrollbar-width.js +0 -29
  104. package/source/js/utils/hash-params.js +0 -86
  105. package/source/js/utils/parse-label-value.js +0 -34
  106. package/source/js/utils/vanilla.kinetic.js +0 -527
  107. package/source/js/validation-runner.js +0 -177
  108. package/source/js/viewer-core.js +0 -1514
  109. package/source/js/viewport.js +0 -143
  110. package/test/_setup.js +0 -13
  111. package/test/composite-image_test.js +0 -94
  112. package/test/diva_test.js +0 -43
  113. package/test/hash-params_test.js +0 -221
  114. package/test/image-cache_test.js +0 -106
  115. package/test/main.js +0 -6
  116. package/test/manifests/beromunsterManifest.json +0 -15514
  117. package/test/manifests/iiifv2.json +0 -11032
  118. package/test/manifests/iiifv2pages.json +0 -30437
  119. package/test/manifests/iiifv3.json +0 -10965
  120. package/test/navigation_test.js +0 -355
  121. package/test/parse-iiif-manifest_test.js +0 -68
  122. package/test/public_test.js +0 -881
  123. package/test/settings_test.js +0 -487
  124. package/test/utils/book-layout_test.js +0 -148
  125. package/test/utils/elt_test.js +0 -102
  126. package/test/utils/events_test.js +0 -245
  127. package/test/utils/hash-params_test.js +0 -79
  128. package/test/utils/parse-label-value_test.js +0 -45
  129. package/test/z_plugins_test.js +0 -180
  130. package/webpack.config.js +0 -58
  131. package/webpack.config.test.js +0 -45
@@ -1,190 +0,0 @@
1
- /**
2
- * A simple plugin that implements a button to view the IIIF manifest metadata block. Plugins
3
- * should register themselves as a class in the global Diva namespace, e.g., global.Diva.MetadataPlugin.
4
- * Plugins are then included as *uninstantiated* references within a plugin configuration. To enable them, simply include
5
- * plugins: [Diva.MetadataPlugin] when creating a Diva instance.
6
- * When the viewer is instantiated it will also instantiate the plugin, which
7
- * will then configure itself.
8
- *
9
- * Plugin constructors should take one argument, which is an instance of a ViewerCore object.
10
- *
11
- *
12
- * Plugins should implement the following interface:
13
- *
14
- * {boolean} isPageTool - Added to the class prototype. Whether the plugin icon should be included for each page as a page tool
15
- * {string} pluginName - Added to the class prototype. Defines the name for the plugin.
16
- *
17
- * @method createIcon - A div representing the icon. This *should* be implemented using SVG.
18
- * @method handleClick - The click handler for the icon.
19
- *
20
- * Toolbar plugins must have a toolbarIcon and toolbarSide attribute, with toolbarSide being either 'left' or 'right'
21
- **/
22
-
23
- import parseLabelValue from '../utils/parse-label-value';
24
-
25
- export default class MetadataPlugin
26
- {
27
- constructor (core)
28
- {
29
- this.core = core;
30
- this.toolbarIcon;
31
- this.toolbarSide = 'right';
32
-
33
- // helpers for handleClick
34
- this.firstClick = true;
35
- this.isVisible = false;
36
- }
37
-
38
- /**
39
- * Display a modal with the IIIF manifest metadata.
40
- **/
41
- handleClick ()
42
- {
43
- // if first click create div elements
44
- let metadataDiv;
45
-
46
- let metadata = this.core.viewerState.manifest.metadata;
47
-
48
- if (this.firstClick)
49
- {
50
- metadataDiv = document.createElement('div');
51
- metadataDiv.id = 'metadata-modal';
52
- metadataDiv.className = 'diva-modal';
53
-
54
- let metadataHeaderBlock = document.createElement('div');
55
-
56
- let metadataTitle = document.createElement('h2');
57
- metadataTitle.innerText = "About this item";
58
- metadataTitle.id = "metadata-title";
59
-
60
- let closeButton = document.createElement('button');
61
- closeButton.innerHTML = '&#10006';
62
- closeButton.classList.add('close-button');
63
- closeButton.onclick = () =>
64
- {
65
- metadataDiv.style.display = 'none';
66
- this.isVisible = false;
67
- };
68
-
69
- let contentDiv = document.createElement('div');
70
- contentDiv.id = 'metadata-content';
71
-
72
- let contentDefinitionList = document.createElement('dl');
73
-
74
- for (let i = 0, len = metadata.length; i < len; i++)
75
- {
76
- let key = metadata[i];
77
-
78
- let header = document.createElement('dt');
79
- header.innerHTML = parseLabelValue(key).label;
80
-
81
- let value = document.createElement('dd');
82
- value.innerHTML = parseLabelValue(key).value;
83
-
84
- contentDefinitionList.appendChild(header);
85
- contentDefinitionList.appendChild(value);
86
- }
87
-
88
- contentDiv.appendChild(contentDefinitionList);
89
-
90
- // add link to manifest
91
- let linkToManifest = document.createElement('p');
92
- let manifestAnchor = document.createElement('a');
93
- manifestAnchor.setAttribute("target", "_blank");
94
- manifestAnchor.setAttribute("href", `${this.core.settings.objectData}`);
95
- manifestAnchor.innerHTML = "IIIF Manifest";
96
- linkToManifest.appendChild(manifestAnchor);
97
- contentDiv.appendChild(linkToManifest);
98
-
99
- metadataHeaderBlock.appendChild(closeButton);
100
- metadataHeaderBlock.appendChild(metadataTitle);
101
- metadataDiv.appendChild(metadataHeaderBlock);
102
- metadataDiv.appendChild(contentDiv);
103
- document.body.appendChild(metadataDiv);
104
-
105
- this.firstClick = false;
106
- }
107
- else
108
- {
109
- metadataDiv = document.getElementById('metadata-modal');
110
- }
111
-
112
- if (this.isVisible)
113
- {
114
- metadataDiv.style.display = 'none';
115
- this.isVisible = false;
116
- }
117
- else
118
- {
119
- metadataDiv.style.display = 'block';
120
- this.isVisible = true;
121
- }
122
-
123
- // attach drag listeners
124
- let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
125
- metadataDiv.onmousedown = (e) =>
126
- {
127
- pos3 = e.clientX;
128
- pos4 = e.clientY;
129
-
130
- document.onmousemove = (e) =>
131
- {
132
- pos1 = pos3 - e.clientX;
133
- pos2 = pos4 - e.clientY;
134
- pos3 = e.clientX;
135
- pos4 = e.clientY;
136
- metadataDiv.style.top = `${(metadataDiv.offsetTop - pos2)}px`;
137
- metadataDiv.style.left = `${(metadataDiv.offsetLeft - pos1)}px`;
138
- };
139
-
140
- document.onmouseup = () =>
141
- {
142
- document.onmouseup = null;
143
- document.onmousemove = null;
144
- };
145
- };
146
- }
147
-
148
- /**
149
- * See img/metadata.svg for the standalone source code for this.
150
- **/
151
- createIcon ()
152
- {
153
- if (!this.core.viewerState.manifest.metadata)
154
- return;
155
-
156
- const toolbarIcon = document.createElement('div');
157
- toolbarIcon.classList.add('diva-metadata-icon', 'diva-button');
158
-
159
- let root = document.createElementNS("http://www.w3.org/2000/svg", "svg");
160
- root.setAttribute("viewBox", "0 0 20 20");
161
- root.setAttribute('style', 'display: block; padding: 7%');
162
- root.id = `${this.core.settings.selector}metadata-icon`;
163
-
164
- let g = document.createElementNS("http://www.w3.org/2000/svg", "g");
165
- g.id = `${this.core.settings.selector}metadata-icon-glyph`;
166
- g.setAttribute("class", "diva-toolbar-icon");
167
-
168
- let path = document.createElementNS("http://www.w3.org/2000/svg", "path");
169
- path.setAttribute("d", "M5.379,0.681 L5.289,0.771 L5.255,0.736 C4.401,-0.118 2.98,-0.082 2.082,0.816 L1.827,1.07 C0.931,1.967 0.894,3.388 1.749,4.243 L1.783,4.277 L1.619,4.442 C0.846,5.214 0.818,6.441 1.559,7.18 L9.884,15.508 C10.626,16.248 11.851,16.22 12.626,15.447 L16.384,11.689 C17.156,10.916 17.185,9.69 16.445,8.95 L8.117,0.622 C7.377,-0.118 6.15,-0.091 5.379,0.681 L5.379,0.681 Z M4.523,5.108 C3.645,5.108 2.931,4.393 2.931,3.508 C2.931,2.627 3.645,1.911 4.523,1.911 C5.404,1.911 6.115,2.627 6.119,3.508 C6.115,4.395 5.404,5.108 4.523,5.108 L4.523,5.108 Z");
170
-
171
- g.appendChild(path);
172
- root.appendChild(g);
173
-
174
- toolbarIcon.appendChild(root);
175
-
176
- return toolbarIcon;
177
- }
178
- }
179
-
180
- MetadataPlugin.prototype.pluginName = "metadata";
181
- MetadataPlugin.prototype.isPageTool = false;
182
-
183
- /**
184
- * Make this plugin available in the global context
185
- * as part of the 'Diva' namespace.
186
- **/
187
- (function (global)
188
- {
189
- global.Diva.MetadataPlugin = MetadataPlugin;
190
- })(window);