@panoramax/web-viewer 3.2.3-develop-d7e5a16d → 3.2.3-develop-6257391e

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 (221) hide show
  1. package/.gitlab-ci.yml +3 -0
  2. package/CHANGELOG.md +19 -0
  3. package/CODE_OF_CONDUCT.md +1 -1
  4. package/README.md +1 -1
  5. package/build/editor.html +10 -1
  6. package/build/index.css +2 -2
  7. package/build/index.css.map +1 -1
  8. package/build/index.html +1 -1
  9. package/build/index.js +1682 -5
  10. package/build/index.js.map +1 -1
  11. package/build/map.html +1 -1
  12. package/build/viewer.html +10 -1
  13. package/build/widgets.html +1 -0
  14. package/config/jest/mocks.js +172 -0
  15. package/config/paths.js +1 -0
  16. package/config/webpack.config.js +26 -0
  17. package/docs/03_URL_settings.md +3 -11
  18. package/docs/05_Compatibility.md +59 -76
  19. package/docs/09_Develop.md +30 -11
  20. package/docs/90_Releases.md +2 -2
  21. package/docs/images/class_diagram.drawio +28 -28
  22. package/docs/images/class_diagram.jpg +0 -0
  23. package/docs/index.md +112 -0
  24. package/docs/reference/components/core/Basic.md +153 -0
  25. package/docs/reference/components/core/CoverageMap.md +160 -0
  26. package/docs/reference/components/core/Editor.md +172 -0
  27. package/docs/reference/components/core/Viewer.md +288 -0
  28. package/docs/reference/components/layout/CorneredGrid.md +29 -0
  29. package/docs/reference/components/layout/Mini.md +45 -0
  30. package/docs/reference/components/menus/MapBackground.md +32 -0
  31. package/docs/reference/components/menus/MapFilters.md +15 -0
  32. package/docs/reference/components/menus/MapLayers.md +15 -0
  33. package/docs/reference/components/menus/MapLegend.md +15 -0
  34. package/docs/reference/components/menus/PictureLegend.md +15 -0
  35. package/docs/reference/components/menus/PictureMetadata.md +15 -0
  36. package/docs/reference/components/menus/PlayerOptions.md +15 -0
  37. package/docs/reference/components/menus/QualityScoreDoc.md +15 -0
  38. package/docs/reference/components/menus/ReportForm.md +15 -0
  39. package/docs/reference/components/menus/ShareMenu.md +15 -0
  40. package/docs/reference/components/ui/Button.md +39 -0
  41. package/docs/reference/components/ui/ButtonGroup.md +36 -0
  42. package/docs/reference/components/ui/CopyButton.md +35 -0
  43. package/docs/reference/components/ui/Grade.md +32 -0
  44. package/docs/reference/components/ui/LinkButton.md +44 -0
  45. package/docs/reference/components/ui/Loader.md +54 -0
  46. package/docs/reference/components/ui/Map.md +214 -0
  47. package/docs/reference/components/ui/MapMore.md +233 -0
  48. package/docs/reference/components/ui/Photo.md +369 -0
  49. package/docs/reference/components/ui/Popup.md +56 -0
  50. package/docs/reference/components/ui/QualityScore.md +45 -0
  51. package/docs/reference/components/ui/SearchBar.md +63 -0
  52. package/docs/reference/components/ui/TogglableGroup.md +39 -0
  53. package/docs/reference/components/ui/widgets/GeoSearch.md +32 -0
  54. package/docs/reference/components/ui/widgets/Legend.md +32 -0
  55. package/docs/reference/components/ui/widgets/MapFiltersButton.md +33 -0
  56. package/docs/reference/components/ui/widgets/MapLayersButton.md +15 -0
  57. package/docs/reference/components/ui/widgets/Player.md +32 -0
  58. package/docs/reference/components/ui/widgets/Share.md +15 -0
  59. package/docs/reference/components/ui/widgets/Zoom.md +15 -0
  60. package/docs/reference/utils/API.md +311 -0
  61. package/docs/reference/utils/InitParameters.md +67 -0
  62. package/docs/reference/utils/URLHandler.md +102 -0
  63. package/docs/reference.md +73 -0
  64. package/docs/shortcuts.md +11 -0
  65. package/docs/tutorials/aerial_imagery.md +19 -0
  66. package/docs/tutorials/authentication.md +10 -0
  67. package/docs/tutorials/custom_widgets.md +64 -0
  68. package/docs/tutorials/map_style.md +27 -0
  69. package/docs/tutorials/migrate_v4.md +122 -0
  70. package/docs/tutorials/synced_coverage.md +42 -0
  71. package/mkdocs.yml +60 -5
  72. package/package.json +10 -7
  73. package/public/editor.html +21 -29
  74. package/public/index.html +3 -3
  75. package/public/map.html +19 -18
  76. package/public/viewer.html +18 -24
  77. package/public/widgets.html +265 -0
  78. package/scripts/doc.js +77 -0
  79. package/src/components/core/Basic.css +44 -0
  80. package/src/components/core/Basic.js +258 -0
  81. package/src/components/core/CoverageMap.css +9 -0
  82. package/src/components/core/CoverageMap.js +105 -0
  83. package/src/components/core/Editor.css +23 -0
  84. package/src/components/core/Editor.js +354 -0
  85. package/src/components/core/Viewer.css +109 -0
  86. package/src/components/core/Viewer.js +707 -0
  87. package/src/components/core/index.js +11 -0
  88. package/src/components/index.js +13 -0
  89. package/src/components/layout/CorneredGrid.js +109 -0
  90. package/src/components/layout/Mini.js +117 -0
  91. package/src/components/layout/index.js +7 -0
  92. package/src/components/menus/MapBackground.js +106 -0
  93. package/src/components/menus/MapFilters.js +386 -0
  94. package/src/components/menus/MapLayers.js +143 -0
  95. package/src/components/menus/MapLegend.js +54 -0
  96. package/src/components/menus/PictureLegend.js +103 -0
  97. package/src/components/menus/PictureMetadata.js +188 -0
  98. package/src/components/menus/PlayerOptions.js +96 -0
  99. package/src/components/menus/QualityScoreDoc.js +36 -0
  100. package/src/components/menus/ReportForm.js +133 -0
  101. package/src/components/menus/Share.js +228 -0
  102. package/src/components/menus/index.js +15 -0
  103. package/src/components/styles.js +365 -0
  104. package/src/components/ui/Button.js +75 -0
  105. package/src/components/ui/ButtonGroup.css +49 -0
  106. package/src/components/ui/ButtonGroup.js +68 -0
  107. package/src/components/ui/CopyButton.js +71 -0
  108. package/src/components/ui/Grade.js +54 -0
  109. package/src/components/ui/LinkButton.js +68 -0
  110. package/src/components/ui/Loader.js +188 -0
  111. package/src/components/{Map.css → ui/Map.css} +5 -17
  112. package/src/components/{Map.js → ui/Map.js} +114 -138
  113. package/src/components/ui/MapMore.js +324 -0
  114. package/src/components/{Photo.css → ui/Photo.css} +6 -6
  115. package/src/components/{Photo.js → ui/Photo.js} +279 -90
  116. package/src/components/ui/Popup.js +145 -0
  117. package/src/components/ui/QualityScore.js +152 -0
  118. package/src/components/ui/SearchBar.js +363 -0
  119. package/src/components/ui/TogglableGroup.js +162 -0
  120. package/src/components/ui/index.js +20 -0
  121. package/src/components/ui/widgets/GeoSearch.css +21 -0
  122. package/src/components/ui/widgets/GeoSearch.js +139 -0
  123. package/src/components/ui/widgets/Legend.js +51 -0
  124. package/src/components/ui/widgets/MapFiltersButton.js +104 -0
  125. package/src/components/ui/widgets/MapLayersButton.js +79 -0
  126. package/src/components/ui/widgets/Player.css +7 -0
  127. package/src/components/ui/widgets/Player.js +148 -0
  128. package/src/components/ui/widgets/Share.js +30 -0
  129. package/src/components/ui/widgets/Zoom.js +82 -0
  130. package/src/components/ui/widgets/index.js +12 -0
  131. package/src/img/panoramax.svg +13 -0
  132. package/src/img/switch_big.svg +20 -10
  133. package/src/index.js +6 -9
  134. package/src/translations/da.json +1 -1
  135. package/src/translations/de.json +1 -1
  136. package/src/translations/en.json +5 -3
  137. package/src/translations/eo.json +1 -1
  138. package/src/translations/es.json +1 -1
  139. package/src/translations/fr.json +5 -3
  140. package/src/translations/hu.json +1 -1
  141. package/src/translations/it.json +1 -1
  142. package/src/translations/ja.json +1 -1
  143. package/src/translations/nl.json +1 -1
  144. package/src/translations/pl.json +1 -1
  145. package/src/translations/sv.json +1 -1
  146. package/src/translations/zh_Hant.json +1 -1
  147. package/src/utils/API.js +74 -42
  148. package/src/utils/InitParameters.js +354 -0
  149. package/src/utils/URLHandler.js +364 -0
  150. package/src/utils/geocoder.js +116 -0
  151. package/src/utils/{I18n.js → i18n.js} +3 -1
  152. package/src/utils/index.js +11 -0
  153. package/src/utils/{Map.js → map.js} +216 -80
  154. package/src/utils/picture.js +433 -0
  155. package/src/utils/utils.js +315 -0
  156. package/src/utils/widgets.js +93 -0
  157. package/tests/components/ui/CopyButton.test.js +52 -0
  158. package/tests/components/ui/Loader.test.js +54 -0
  159. package/tests/components/{Map.test.js → ui/Map.test.js} +19 -61
  160. package/tests/components/{Photo.test.js → ui/Photo.test.js} +89 -57
  161. package/tests/components/ui/Popup.test.js +24 -0
  162. package/tests/components/ui/QualityScore.test.js +17 -0
  163. package/tests/components/ui/SearchBar.test.js +107 -0
  164. package/tests/components/ui/__snapshots__/CopyButton.test.js.snap +34 -0
  165. package/tests/components/ui/__snapshots__/Loader.test.js.snap +56 -0
  166. package/tests/components/{__snapshots__ → ui/__snapshots__}/Map.test.js.snap +11 -38
  167. package/tests/components/{__snapshots__ → ui/__snapshots__}/Photo.test.js.snap +57 -4
  168. package/tests/components/ui/__snapshots__/Popup.test.js.snap +29 -0
  169. package/tests/components/ui/__snapshots__/QualityScore.test.js.snap +11 -0
  170. package/tests/components/ui/__snapshots__/SearchBar.test.js.snap +65 -0
  171. package/tests/utils/API.test.js +1 -14
  172. package/tests/utils/InitParameters.test.js +485 -0
  173. package/tests/utils/URLHandler.test.js +350 -0
  174. package/tests/utils/__snapshots__/URLHandler.test.js.snap +21 -0
  175. package/tests/utils/__snapshots__/picture.test.js.snap +315 -0
  176. package/tests/utils/__snapshots__/widgets.test.js.snap +19 -0
  177. package/tests/utils/geocoder.test.js +37 -0
  178. package/tests/utils/{I18n.test.js → i18n.test.js} +1 -1
  179. package/tests/utils/map.test.js +67 -0
  180. package/tests/utils/picture.test.js +745 -0
  181. package/tests/utils/utils.test.js +288 -0
  182. package/tests/utils/widgets.test.js +90 -0
  183. package/docs/01_Start.md +0 -149
  184. package/docs/02_Usage.md +0 -831
  185. package/docs/04_Advanced_examples.md +0 -216
  186. package/src/Editor.css +0 -37
  187. package/src/Editor.js +0 -361
  188. package/src/StandaloneMap.js +0 -114
  189. package/src/Viewer.css +0 -203
  190. package/src/Viewer.js +0 -1246
  191. package/src/components/CoreView.css +0 -70
  192. package/src/components/CoreView.js +0 -175
  193. package/src/components/Loader.css +0 -74
  194. package/src/components/Loader.js +0 -120
  195. package/src/utils/Exif.js +0 -193
  196. package/src/utils/Utils.js +0 -631
  197. package/src/utils/Widgets.js +0 -562
  198. package/src/viewer/URLHash.js +0 -469
  199. package/src/viewer/Widgets.css +0 -880
  200. package/src/viewer/Widgets.js +0 -1470
  201. package/tests/Editor.test.js +0 -126
  202. package/tests/StandaloneMap.test.js +0 -45
  203. package/tests/Viewer.test.js +0 -366
  204. package/tests/__snapshots__/Editor.test.js.snap +0 -298
  205. package/tests/__snapshots__/StandaloneMap.test.js.snap +0 -30
  206. package/tests/__snapshots__/Viewer.test.js.snap +0 -195
  207. package/tests/components/CoreView.test.js +0 -92
  208. package/tests/components/Loader.test.js +0 -38
  209. package/tests/components/__snapshots__/Loader.test.js.snap +0 -15
  210. package/tests/utils/Exif.test.js +0 -124
  211. package/tests/utils/Map.test.js +0 -113
  212. package/tests/utils/Utils.test.js +0 -300
  213. package/tests/utils/Widgets.test.js +0 -107
  214. package/tests/utils/__snapshots__/Exif.test.js.snap +0 -43
  215. package/tests/utils/__snapshots__/Utils.test.js.snap +0 -41
  216. package/tests/utils/__snapshots__/Widgets.test.js.snap +0 -44
  217. package/tests/viewer/URLHash.test.js +0 -559
  218. package/tests/viewer/Widgets.test.js +0 -127
  219. package/tests/viewer/__snapshots__/URLHash.test.js.snap +0 -108
  220. package/tests/viewer/__snapshots__/Widgets.test.js.snap +0 -403
  221. /package/tests/utils/__snapshots__/{Map.test.js.snap → geocoder.test.js.snap} +0 -0
@@ -1,41 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`getNodeCaption works with date + 2 producers 1`] = `
4
- Object {
5
- "date": Object {
6
- "toLocaleDateString": [Function],
7
- },
8
- "producer": "GeoVisio Corp., PanierAvide",
9
- }
10
- `;
11
-
12
- exports[`getNodeCaption works with date + producer 1`] = `
13
- Object {
14
- "date": Object {
15
- "toLocaleDateString": [Function],
16
- },
17
- "producer": "PanierAvide",
18
- }
19
- `;
20
-
21
- exports[`getNodeCaption works with date 1`] = `
22
- Object {
23
- "date": Object {
24
- "toLocaleDateString": [Function],
25
- },
26
- }
27
- `;
28
-
29
- exports[`getNodeCaption works with date+tz 1`] = `
30
- Object {
31
- "date": Object {
32
- "toLocaleDateString": [Function],
33
- },
34
- }
35
- `;
36
-
37
- exports[`getNodeCaption works with producer 1`] = `
38
- Object {
39
- "producer": "PanierAvide",
40
- }
41
- `;
@@ -1,44 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`createExpandableButton works with large container 1`] = `"<svg aria-hidden=\\"true\\" focusable=\\"false\\" data-prefix=\\"fas\\" data-icon=\\"chevron-down\\" class=\\"svg-inline--fa fa-chevron-down\\" role=\\"img\\" xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 512 512\\"><path fill=\\"currentColor\\" d=\\"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z\\"></path></svg>blabla<svg aria-hidden=\\"true\\" focusable=\\"false\\" data-prefix=\\"fas\\" data-icon=\\"chevron-down\\" class=\\"svg-inline--fa fa-chevron-down\\" role=\\"img\\" xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 512 512\\"><path fill=\\"currentColor\\" d=\\"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z\\"></path></svg>"`;
4
-
5
- exports[`createExpandableButton works with small container 1`] = `"<svg aria-hidden=\\"true\\" focusable=\\"false\\" data-prefix=\\"fas\\" data-icon=\\"chevron-down\\" class=\\"svg-inline--fa fa-chevron-down\\" role=\\"img\\" xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 512 512\\"><path fill=\\"currentColor\\" d=\\"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z\\"></path></svg>"`;
6
-
7
- exports[`createGroup works 1`] = `"<span></span>"`;
8
-
9
- exports[`createPanel works 1`] = `"<span></span>"`;
10
-
11
- exports[`createPanel works 2`] = `
12
- Array [
13
- Array [
14
- "click",
15
- [Function],
16
- ],
17
- Array [
18
- "hover",
19
- [Function],
20
- ],
21
- ]
22
- `;
23
-
24
- exports[`createSearchBar works 1`] = `"<input type=\\"text\\" placeholder=\\"no res\\" id=\\"mysrch-input\\" autocomplete=\\"off\\"><span class=\\"gvs-search-bar-icon\\"><svg aria-hidden=\\"true\\" focusable=\\"false\\" data-prefix=\\"fas\\" data-icon=\\"magnifying-glass\\" class=\\"svg-inline--fa fa-magnifying-glass\\" role=\\"img\\" xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 512 512\\"><path fill=\\"currentColor\\" d=\\"M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z\\"></path></svg></span><div id=\\"mysrch-panel\\" class=\\"gvs-panel gvs-widget-bg gvs-hidden gvs-search-bar-results\\"></div>"`;
25
-
26
- exports[`fa works 1`] = `
27
- <svg
28
- aria-hidden="true"
29
- class="svg-inline--fa fa-chevron-down"
30
- data-icon="chevron-down"
31
- data-prefix="fas"
32
- focusable="false"
33
- role="img"
34
- viewBox="0 0 512 512"
35
- xmlns="http://www.w3.org/2000/svg"
36
- >
37
- <path
38
- d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"
39
- fill="currentColor"
40
- />
41
- </svg>
42
- `;
43
-
44
- exports[`fat works 1`] = `"<svg aria-hidden=\\"true\\" focusable=\\"false\\" data-prefix=\\"fas\\" data-icon=\\"chevron-down\\" class=\\"svg-inline--fa fa-chevron-down\\" role=\\"img\\" xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 512 512\\"><path fill=\\"currentColor\\" d=\\"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z\\"></path></svg>"`;
@@ -1,559 +0,0 @@
1
- import URLHash from "../../src/viewer/URLHash";
2
-
3
- describe("constructor", () => {
4
- it("works", () => {
5
- const receivedEvents = [];
6
- const vl = (t, h) => {
7
- receivedEvents.push([t, h]);
8
- if(t == "ready") { h(); }
9
- };
10
- const v = { addEventListener: vl };
11
- const uh = new URLHash(v);
12
- expect(uh).toBeDefined();
13
- expect(uh._viewer).toBe(v);
14
- expect(receivedEvents).toMatchSnapshot();
15
- });
16
- });
17
-
18
- describe("destroy", () => {
19
- it("works", () => {
20
- const v = {
21
- addEventListener: jest.fn(),
22
- removeEventListener: jest.fn(),
23
- };
24
- const uh = new URLHash(v);
25
- uh.destroy();
26
- expect(uh._viewer).toBeUndefined();
27
- expect(v.removeEventListener.mock.calls).toMatchSnapshot();
28
- });
29
- });
30
-
31
- describe("bindMapEvents", () => {
32
- it("works", () => {
33
- const v = { addEventListener: jest.fn(), map: { on: jest.fn() } };
34
- const uh = new URLHash(v);
35
- uh.bindMapEvents();
36
- expect(v.map.on.mock.calls).toMatchSnapshot();
37
- });
38
- });
39
-
40
- describe("getHashString", () => {
41
- it("works without any specific values set", () => {
42
- const v = {
43
- addEventListener: jest.fn(),
44
- getPicturesNavigation: () => null,
45
- psv: {
46
- getTransitionDuration: () => null,
47
- getPictureMetadata: () => null,
48
- },
49
- };
50
- const uh = new URLHash(v);
51
- expect(uh.getHashString()).toBe("#map=none");
52
- });
53
-
54
- it("works with picture metadata", () => {
55
- const v = {
56
- addEventListener: jest.fn(),
57
- getPicturesNavigation: () => null,
58
- psv: {
59
- getTransitionDuration: () => null,
60
- getPictureMetadata: () => ({ "id": "cbfc3add-8173-4464-98c8-de2a43c6a50f" })
61
- },
62
- };
63
- const uh = new URLHash(v);
64
- uh._getXyzHashString = () => "0/1/2";
65
- expect(uh.getHashString()).toBe("#map=none&pic=cbfc3add-8173-4464-98c8-de2a43c6a50f&xyz=0/1/2");
66
- });
67
-
68
- it("works with map started + wide", () => {
69
- const v = {
70
- addEventListener: jest.fn(),
71
- getPicturesNavigation: () => null,
72
- psv: {
73
- getTransitionDuration: () => null,
74
- getPictureMetadata: () => null,
75
- },
76
- map: {
77
- getVisibleUsers: () => ["geovisio"],
78
- hasTwoBackgrounds: () => false,
79
- },
80
- isMapWide: () => true,
81
- popupContainer: { classList: { contains: () => true } },
82
- };
83
- const uh = new URLHash(v);
84
- uh._getMapHashString = () => "18/0.5/-12";
85
- expect(uh.getHashString()).toBe("#focus=map&map=18/0.5/-12");
86
- });
87
-
88
- it("works with map + picture wide", () => {
89
- const v = {
90
- addEventListener: jest.fn(),
91
- getPicturesNavigation: () => null,
92
- psv: {
93
- getTransitionDuration: () => null,
94
- getPictureMetadata: () => ({ "id": "cbfc3add-8173-4464-98c8-de2a43c6a50f" }),
95
- },
96
- map: {
97
- getVisibleUsers: () => ["geovisio"],
98
- hasTwoBackgrounds: () => false,
99
- },
100
- isMapWide: () => false,
101
- popupContainer: { classList: { contains: () => true } },
102
- };
103
- const uh = new URLHash(v);
104
- uh._getXyzHashString = () => "0/1/2";
105
- uh._getMapHashString = () => "18/0.5/-12";
106
- expect(uh.getHashString()).toBe("#focus=pic&map=18/0.5/-12&pic=cbfc3add-8173-4464-98c8-de2a43c6a50f&xyz=0/1/2");
107
- });
108
-
109
- it("works with map filters", () => {
110
- const v = {
111
- addEventListener: jest.fn(),
112
- getPicturesNavigation: () => null,
113
- psv: {
114
- getTransitionDuration: () => null,
115
- getPictureMetadata: () => null,
116
- },
117
- map: {
118
- getVisibleUsers: () => ["geovisio"],
119
- hasTwoBackgrounds: () => false,
120
- },
121
- isMapWide: () => false,
122
- popupContainer: { classList: { contains: () => true } },
123
- _mapFilters: {
124
- "minDate": "2023-01-01",
125
- "maxDate": "2023-08-08",
126
- "camera": "sony",
127
- "type": "flat",
128
- "theme": "age",
129
- },
130
- };
131
- const uh = new URLHash(v);
132
- uh._getMapHashString = () => "18/0.5/-12";
133
- expect(uh.getHashString()).toBe("#camera=sony&date_from=2023-01-01&date_to=2023-08-08&focus=pic&map=18/0.5/-12&pic_type=flat&theme=age");
134
- });
135
-
136
- it("works with speed", () => {
137
- const v = {
138
- addEventListener: jest.fn(),
139
- getPicturesNavigation: () => null,
140
- psv: {
141
- getTransitionDuration: () => 250,
142
- getPictureMetadata: () => null,
143
- },
144
- };
145
- const uh = new URLHash(v);
146
- expect(uh.getHashString()).toBe("#map=none&speed=250");
147
- });
148
-
149
- it("works with popup", () => {
150
- const v = {
151
- addEventListener: jest.fn(),
152
- getPicturesNavigation: () => null,
153
- psv: {
154
- getTransitionDuration: () => null,
155
- getPictureMetadata: () => null,
156
- },
157
- map: {
158
- getVisibleUsers: () => ["geovisio"],
159
- hasTwoBackgrounds: () => false,
160
- },
161
- isMapWide: () => false,
162
- popupContainer: { classList: { contains: () => false } },
163
- };
164
- const uh = new URLHash(v);
165
- uh._getMapHashString = () => "18/0.5/-12";
166
- expect(uh.getHashString()).toBe("#focus=meta&map=18/0.5/-12");
167
- });
168
-
169
- it("works with nav", () => {
170
- const v = {
171
- addEventListener: jest.fn(),
172
- getPicturesNavigation: () => "pic",
173
- psv: {
174
- getTransitionDuration: () => null,
175
- getPictureMetadata: () => null,
176
- },
177
- };
178
- const uh = new URLHash(v);
179
- expect(uh.getHashString()).toBe("#map=none&nav=pic");
180
- });
181
- });
182
-
183
- describe("_getCurrentHash", () => {
184
- it("works if empty", () => {
185
- delete window.location;
186
- window.location = { hash: "" };
187
- const v = { addEventListener: jest.fn() };
188
- const uh = new URLHash(v);
189
- expect(uh._getCurrentHash()).toStrictEqual({});
190
- });
191
-
192
- it("works with single param", () => {
193
- delete window.location;
194
- window.location = { hash: "#a=b" };
195
- const v = { addEventListener: jest.fn() };
196
- const uh = new URLHash(v);
197
- expect(uh._getCurrentHash()).toStrictEqual({"a": "b"});
198
- });
199
-
200
- it("works with multiple params", () => {
201
- delete window.location;
202
- window.location = { hash: "#a=b&c=d" };
203
- const v = { addEventListener: jest.fn() };
204
- const uh = new URLHash(v);
205
- expect(uh._getCurrentHash()).toStrictEqual({"a": "b", "c": "d"});
206
- });
207
- });
208
-
209
- describe("_getMapHashString", () => {
210
- it("works with zoom+center", () => {
211
- const v = {
212
- addEventListener: jest.fn(),
213
- map: {
214
- getZoom: () => 18,
215
- getCenter: () => ({ lng: -12.5, lat: 48.75 }),
216
- getBearing: () => null,
217
- getPitch: () => null,
218
- }
219
- };
220
- const uh = new URLHash(v);
221
- expect(uh._getMapHashString()).toBe("18/48.75/-12.5");
222
- });
223
-
224
- it("works with zoom+center+bearing", () => {
225
- const v = {
226
- addEventListener: jest.fn(),
227
- map: {
228
- getZoom: () => 18,
229
- getCenter: () => ({ lng: -12.5, lat: 48.75 }),
230
- getBearing: () => 12,
231
- getPitch: () => null,
232
- }
233
- };
234
- const uh = new URLHash(v);
235
- expect(uh._getMapHashString()).toBe("18/48.75/-12.5/12");
236
- });
237
-
238
- it("works with zoom+center+pitch", () => {
239
- const v = {
240
- addEventListener: jest.fn(),
241
- map: {
242
- getZoom: () => 18,
243
- getCenter: () => ({ lng: -12.5, lat: 48.75 }),
244
- getBearing: () => null,
245
- getPitch: () => 65,
246
- },
247
- };
248
- const uh = new URLHash(v);
249
- expect(uh._getMapHashString()).toBe("18/48.75/-12.5/0/65");
250
- });
251
-
252
- it("works with zoom+center+bearing+pitch", () => {
253
- const v = {
254
- addEventListener: jest.fn(),
255
- map: {
256
- getZoom: () => 18,
257
- getCenter: () => ({ lng: -12.5, lat: 48.75 }),
258
- getBearing: () => 42,
259
- getPitch: () => 65,
260
- },
261
- };
262
- const uh = new URLHash(v);
263
- expect(uh._getMapHashString()).toBe("18/48.75/-12.5/42/65");
264
- });
265
- });
266
-
267
- describe("_getXyzHashString", () => {
268
- it("works", () => {
269
- const v = {
270
- addEventListener: jest.fn(),
271
- psv: {
272
- getXYZ: () => ({ x: 12, y: 50, z: 75 }),
273
- },
274
- };
275
- const uh = new URLHash(v);
276
- expect(uh._getXyzHashString()).toBe("12.00/50.00/75");
277
- });
278
-
279
- it("rounds to 2 decimals", () => {
280
- const v = {
281
- addEventListener: jest.fn(),
282
- psv: {
283
- getXYZ: () => ({ x: 12.123456, y: 50.789456, z: 75 }),
284
- },
285
- };
286
- const uh = new URLHash(v);
287
- expect(uh._getXyzHashString()).toBe("12.12/50.79/75");
288
- });
289
-
290
- it("works without z", () => {
291
- const v = {
292
- addEventListener: jest.fn(),
293
- psv: {
294
- getXYZ: () => ({ x: 12, y: 50 }),
295
- },
296
- };
297
- const uh = new URLHash(v);
298
- expect(uh._getXyzHashString()).toBe("12.00/50.00/0");
299
- });
300
- });
301
-
302
- describe("_onHashChange", () => {
303
- global.console = { warn: jest.fn() };
304
-
305
- it("works", () => {
306
- const v = {
307
- addEventListener: jest.fn(),
308
- map: {
309
- dragRotate: { isEnabled: () => false },
310
- getBearing: jest.fn(),
311
- jumpTo: jest.fn(),
312
- setVisibleUsers: jest.fn(),
313
- setBackground: jest.fn(),
314
- },
315
- psv: {
316
- setTransitionDuration: jest.fn(),
317
- setXYZ: jest.fn(),
318
- },
319
- select: jest.fn(),
320
- setFocus: jest.fn(),
321
- setFilters: jest.fn(),
322
- setPopup: jest.fn(),
323
- };
324
- const uh = new URLHash(v);
325
- uh._getCurrentHash = () => ({
326
- pic: "cbfc3add-8173-4464-98c8-de2a43c6a50f",
327
- focus: "map",
328
- xyz: "1/2/3",
329
- map: "15/48.7/-12.5",
330
- speed: "300",
331
- });
332
- uh._onHashChange();
333
-
334
- expect(v.select.mock.calls).toEqual([[null, "cbfc3add-8173-4464-98c8-de2a43c6a50f"]]);
335
- expect(v.setFocus.mock.calls).toEqual([["map"]]);
336
- expect(v.map.jumpTo.mock.calls).toEqual([[{ center: [-12.5, 48.7], zoom: 15, pitch: 0 }]]);
337
- expect(v.psv.setXYZ.mock.calls).toEqual([[1, 2, 3]]);
338
- expect(v.psv.setTransitionDuration.mock.calls).toEqual([["300"]]);
339
- });
340
-
341
- it("doesnt call map if no map params", () => {
342
- const v = {
343
- addEventListener: jest.fn(),
344
- map: {
345
- jumpTo: jest.fn(),
346
- setBackground: jest.fn(),
347
- },
348
- psv: {
349
- setTransitionDuration: jest.fn(),
350
- setXYZ: jest.fn(),
351
- },
352
- select: jest.fn(),
353
- setFocus: jest.fn(),
354
- setFilters: jest.fn(),
355
- };
356
- const uh = new URLHash(v);
357
- uh._getCurrentHash = () => ({
358
- pic: "cbfc3add-8173-4464-98c8-de2a43c6a50f",
359
- xyz: "1/2/3",
360
- });
361
- uh._onHashChange();
362
-
363
- expect(v.select.mock.calls).toEqual([[null, "cbfc3add-8173-4464-98c8-de2a43c6a50f"]]);
364
- expect(v.setFocus.mock.calls.length).toBe(0);
365
- expect(v.map.jumpTo.mock.calls.length).toBe(0);
366
- expect(v.map.setBackground.mock.calls.length).toBe(0);
367
- expect(v.psv.setXYZ.mock.calls).toEqual([[1, 2, 3]]);
368
- });
369
-
370
- it("doesnt call psv if no related params", () => {
371
- const v = {
372
- addEventListener: jest.fn(),
373
- map: {
374
- dragRotate: { isEnabled: () => false },
375
- getBearing: jest.fn(),
376
- jumpTo: jest.fn(),
377
- setVisibleUsers: jest.fn(),
378
- setBackground: jest.fn(),
379
- },
380
- psv: {
381
- setTransitionDuration: jest.fn(),
382
- setXYZ: jest.fn(),
383
- },
384
- select: jest.fn(),
385
- setFocus: jest.fn(),
386
- setFilters: jest.fn(),
387
- setPopup: jest.fn(),
388
- };
389
- const uh = new URLHash(v);
390
- uh._getCurrentHash = () => ({
391
- focus: "map",
392
- map: "15/48.7/-12.5"
393
- });
394
- uh._onHashChange();
395
-
396
- expect(v.select.mock.calls).toEqual([[]]);
397
- expect(v.setFocus.mock.calls).toEqual([["map"]]);
398
- expect(v.map.jumpTo.mock.calls).toEqual([[{ center: [-12.5, 48.7], zoom: 15, pitch: 0 }]]);
399
- expect(v.psv.setXYZ.mock.calls.length).toEqual(0);
400
- });
401
-
402
- it("handles multiple picture IDs", () => {
403
- const v = {
404
- addEventListener: jest.fn(),
405
- map: {
406
- dragRotate: { isEnabled: () => false },
407
- getBearing: jest.fn(),
408
- jumpTo: jest.fn(),
409
- setVisibleUsers: jest.fn(),
410
- setBackground: jest.fn(),
411
- },
412
- psv: {
413
- setTransitionDuration: jest.fn(),
414
- setXYZ: jest.fn(),
415
- },
416
- select: jest.fn(),
417
- setFocus: jest.fn(),
418
- setFilters: jest.fn(),
419
- setPopup: jest.fn(),
420
- };
421
- const uh = new URLHash(v);
422
- uh._getCurrentHash = () => ({
423
- pic: "cbfc3add-8173-4464-98c8-de2a43c6a50f;blablabla-8173-4464-98c8-de2a43c6a50f",
424
- focus: "map",
425
- xyz: "1/2/3",
426
- map: "15/48.7/-12.5",
427
- speed: "300",
428
- });
429
- uh._onHashChange();
430
-
431
- expect(v.select.mock.calls).toEqual([[null, "cbfc3add-8173-4464-98c8-de2a43c6a50f"]]);
432
- expect(v.setFocus.mock.calls).toEqual([["map"]]);
433
- expect(v.map.jumpTo.mock.calls).toEqual([[{ center: [-12.5, 48.7], zoom: 15, pitch: 0 }]]);
434
- expect(v.psv.setXYZ.mock.calls).toEqual([[1, 2, 3]]);
435
- expect(v.psv.setTransitionDuration.mock.calls).toEqual([["300"]]);
436
- });
437
- });
438
-
439
- describe("getMapFiltersFromHashVals", () => {
440
- it("works", () => {
441
- const v = { addEventListener: jest.fn() };
442
- const uh = new URLHash(v);
443
- const vals = {
444
- "date_from": "2023-01-01",
445
- "date_to": "2023-05-05",
446
- "pic_type": "equirectangular",
447
- "camera": "sony",
448
- "whatever": "whenever",
449
- "theme": "type",
450
- };
451
- expect(uh.getMapFiltersFromHashVals(vals)).toEqual({
452
- "minDate": "2023-01-01",
453
- "maxDate": "2023-05-05",
454
- "type": "equirectangular",
455
- "camera": "sony",
456
- "theme": "type",
457
- });
458
- });
459
- });
460
-
461
- describe("getMapOptionsFromHashString", () => {
462
- it("works without map", () => {
463
- const v = { addEventListener: jest.fn() };
464
- const uh = new URLHash(v);
465
- expect(uh.getMapOptionsFromHashString("18/-12.5/48.7")).toEqual({ center: [48.7, -12.5], zoom: 18, pitch: 0 });
466
- });
467
-
468
- it("works with map", () => {
469
- const v = {
470
- addEventListener: jest.fn(),
471
- map: {
472
- dragRotate: { isEnabled: () => true },
473
- touchZoomRotate: { isEnabled: () => true },
474
- },
475
- };
476
- const uh = new URLHash(v);
477
- expect(uh.getMapOptionsFromHashString("18/-12.5/48.7/15/12")).toEqual({ center: [48.7, -12.5], zoom: 18, pitch: 12, bearing: 15 });
478
- });
479
-
480
- it("nulls if string is invalid", () => {
481
- const v = { addEventListener: jest.fn() };
482
- const uh = new URLHash(v);
483
- expect(uh.getMapOptionsFromHashString("bla/bla/bla")).toBeNull();
484
- });
485
- });
486
-
487
- describe("getXyzOptionsFromHashString", () => {
488
- it("works", () => {
489
- const v = { addEventListener: jest.fn() };
490
- const uh = new URLHash(v);
491
- expect(uh.getXyzOptionsFromHashString("18/-12.5/48.7")).toEqual({ x: 18, y: -12.5, z: 48.7 });
492
- });
493
-
494
- it("nulls if string is invalid", () => {
495
- const v = { addEventListener: jest.fn() };
496
- const uh = new URLHash(v);
497
- expect(uh.getXyzOptionsFromHashString("bla/bla/bla")).toBeNull();
498
- });
499
- });
500
-
501
- describe("_updateHash", () => {
502
- it("works", async () => {
503
- delete window.history;
504
- delete window.location;
505
-
506
- window.history = { replaceState: jest.fn(), state: {} };
507
- window.location = { href: "http://localhost:5000/#a=b&b=c", hash: "#a=b&b=c" };
508
-
509
- const v = { addEventListener: jest.fn() };
510
- const uh = new URLHash(v);
511
- uh.getHashString = () => "#c=d";
512
- uh.dispatchEvent = jest.fn();
513
-
514
- uh._updateHash();
515
- await new Promise((r) => setTimeout(r, 1000));
516
-
517
- expect(window.history.replaceState.mock.calls.pop()).toEqual([{}, null, "http://localhost:5000/#c=d"]);
518
- expect(uh.dispatchEvent.mock.calls).toMatchSnapshot();
519
- });
520
-
521
- it("works with pic change", async () => {
522
- delete window.history;
523
- delete window.location;
524
-
525
- window.history = { pushState: jest.fn(), state: {} };
526
- window.location = { href: "http://localhost:5000/#a=b&b=c", hash: "#a=b&pic=bla" };
527
-
528
- const v = { addEventListener: jest.fn() };
529
- const uh = new URLHash(v);
530
- uh.getHashString = () => "#c=d";
531
- uh.dispatchEvent = jest.fn();
532
-
533
- uh._updateHash();
534
- await new Promise((r) => setTimeout(r, 1000));
535
-
536
- expect(window.history.pushState.mock.calls.pop()).toEqual([{}, null, "http://localhost:5000/#c=d"]);
537
- expect(uh.dispatchEvent.mock.calls).toMatchSnapshot();
538
- });
539
-
540
- it("deduplicates calls", async () => {
541
- delete window.history;
542
- delete window.location;
543
-
544
- window.history = { replaceState: jest.fn(), state: {} };
545
- window.location = { href: "http://localhost:5000/#a=b&b=c", hash: "#a=b&b=c" };
546
-
547
- const v = { addEventListener: jest.fn() };
548
- const uh = new URLHash(v);
549
- uh.getHashString = () => "#c=d";
550
-
551
- for(let i=0; i <= 10; i++) {
552
- uh._updateHash();
553
- }
554
-
555
- await new Promise((r) => setTimeout(r, 1000));
556
-
557
- expect(window.history.replaceState.mock.calls).toEqual([[{}, null, "http://localhost:5000/#c=d"]]);
558
- });
559
- });