From 5ac865bd08d789aed634feba9b461933a4f2a680 Mon Sep 17 00:00:00 2001
From: t11r <1674104+t11r@users.noreply.github.com>
Date: Tue, 7 Jan 2025 19:50:32 +0100
Subject: [PATCH 1/6] Change scan view option
No longer treat view option "scan" and null the same; "scan" is no longer a valid value. Handle URL param for backwards compatibility.
---
README.md | 5 +++--
src/components/AppHeader.vue | 10 +++++-----
src/components/PageSelect.vue | 2 +-
src/components/TocList.vue | 2 +-
src/components/ViewThumbnails.vue | 2 +-
src/main.js | 2 +-
src/plugins/store.js | 8 ++++----
tests/e2e/scan.spec.js | 3 +--
8 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
index 8aad3e33..31021596 100644
--- a/README.md
+++ b/README.md
@@ -128,7 +128,8 @@ TIFY takes an options object as its only parameter. While optional, you usually
- **`view`**: string, default `''`
- The initially displayed view (panel); `scan`, `fulltext`, `thumbnails`, `toc`, `info`, `help`, or empty (same as `scan`). On large screens, the scan is always shown next to the selected view.
+ The initially displayed view (panel); `fulltext`, `thumbnails`, `toc`, `info`, `help`, or `null` to display (only) the scan. On large screens, the scan is always shown next to the selected view.
+
- **`viewer`**: object
@@ -233,7 +234,7 @@ tify.ready.then(() => {
- `name`: string (required)
- The view’s name; `'export'`, `'fulltext'`, `'help'`, `'info'`, `'scan'`, `'thumbnails'`, `'toc'`, or an empty string (same as `'scan'`).
+ The view’s name; `'export'`, `'fulltext'`, `'help'`, `'info'`, `'thumbnails'`, `'toc'`, or `null` to display (only) the scan.
- **`toggleDoublePage`**
diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue
index cdd45f8a..657a5719 100644
--- a/src/components/AppHeader.vue
+++ b/src/components/AppHeader.vue
@@ -85,7 +85,7 @@ export default {
case 'Backspace':
// switchViewSmall is visible, i.e. screen is small
if (this.$refs.switchViewSmall.offsetParent) {
- this.toggleView('scan');
+ this.toggleView(null);
}
break;
case '1':
@@ -222,7 +222,7 @@ export default {
this.closeControlsPopup();
const view = name === this.$store.options.view && this.$store.manifest && !this.$store.isMobile()
- ? ''
+ ? null
: name;
this.$store.updateOptions({ view });
return view;
@@ -298,10 +298,10 @@ export default {
v-if="$store.manifest"
type="button"
class="tify-header-button -scan"
- :class="{ '-active': $store.options.view === 'scan' }"
+ :class="{ '-active': !$store.options.view }"
:aria-controls="$store.getId('scan')"
- :aria-expanded="$store.options.view === 'scan' ? 'true' : 'false'"
- @click="toggleView('scan')"
+ :aria-expanded="!$store.options.view"
+ @click="toggleView(null)"
>
{{ $translate('Scan') }}
diff --git a/src/components/PageSelect.vue b/src/components/PageSelect.vue
index 4b5d40c9..e6a744f2 100644
--- a/src/components/PageSelect.vue
+++ b/src/components/PageSelect.vue
@@ -79,7 +79,7 @@ export default {
this.closeDropdown();
this.$store.setPage(page);
if (this.$store.isMobile()) {
- this.$store.updateOptions({ view: 'scan' });
+ this.$store.updateOptions({ view: null });
}
},
toggleDropdown() {
diff --git a/src/components/TocList.vue b/src/components/TocList.vue
index 469b1a9e..9167e5b8 100644
--- a/src/components/TocList.vue
+++ b/src/components/TocList.vue
@@ -67,7 +67,7 @@ export default {
setPage(page) {
this.$store.setPage(page);
if (this.$store.isMobile()) {
- this.$store.updateOptions({ view: 'scan' });
+ this.$store.updateOptions({ view: null });
}
},
toggleAllChildren(expanded = null) {
diff --git a/src/components/ViewThumbnails.vue b/src/components/ViewThumbnails.vue
index bf9d3da5..f0a6ed45 100644
--- a/src/components/ViewThumbnails.vue
+++ b/src/components/ViewThumbnails.vue
@@ -157,7 +157,7 @@ export default {
this.$store.setPage(page);
if (this.$store.isMobile()) {
- this.$store.updateOptions({ view: 'scan' });
+ this.$store.updateOptions({ view: null });
}
},
touchStartTogglePage(page) {
diff --git a/src/main.js b/src/main.js
index e849c56c..7825a2f7 100644
--- a/src/main.js
+++ b/src/main.js
@@ -39,7 +39,7 @@ window.Tify = function Tify(userOptions = {}) {
'view',
'zoom',
],
- view: '',
+ view: null,
viewer: {},
zoom: null,
};
diff --git a/src/plugins/store.js b/src/plugins/store.js
index 77eba3c2..29c3ac6b 100644
--- a/src/plugins/store.js
+++ b/src/plugins/store.js
@@ -324,9 +324,9 @@ function Store(args) {
}
}
- // NOTE: params.view can be an empty string (showing only the scan on large screens)
- if (params.view === '' && store.isMobile()) {
- params.view = 'scan';
+ // For backwards compatibility
+ if (params.view === 'scan') {
+ params.view = null;
}
if (params.pages && !isValidPagesArray(params.pages, store.pageCount)) {
@@ -382,7 +382,7 @@ function Store(args) {
pages: [store.getStartPage()],
pan: {},
rotation: null,
- view: store.isMobile() ? 'scan' : 'collection',
+ view: store.isMobile() ? null : 'collection',
zoom: null,
});
}
diff --git a/tests/e2e/scan.spec.js b/tests/e2e/scan.spec.js
index b90c9af0..40a7354f 100644
--- a/tests/e2e/scan.spec.js
+++ b/tests/e2e/scan.spec.js
@@ -34,8 +34,7 @@ describe('Scan', () => {
cy.get('.tify').type('{shift}0');
cy.url().should(
'include',
- `/?manifest=${encodeURIComponent(`${Cypress.env('iiifApiUrl')}/manifest/gdz-HANS_DE_7_w042081`)}`
- + `&tify=${encodeURIComponent('{"view":""}')}`,
+ `/?manifest=${encodeURIComponent(`${Cypress.env('iiifApiUrl')}/manifest/gdz-HANS_DE_7_w042081`)}`,
);
});
From 3bf445fd1f5373af72300666dfbfa3e4e8b54f69 Mon Sep 17 00:00:00 2001
From: t11r <1674104+t11r@users.noreply.github.com>
Date: Tue, 7 Jan 2025 19:52:04 +0100
Subject: [PATCH 2/6] Improve coding style: Simplify boolean attributes
---
src/components/AppHeader.vue | 16 ++++++++--------
src/components/CollectionNode.vue | 2 +-
src/components/PageSelect.vue | 2 +-
src/components/TocList.vue | 2 +-
src/components/ViewExport.vue | 2 +-
src/components/ViewScan.vue | 2 +-
6 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue
index 657a5719..d3ced69d 100644
--- a/src/components/AppHeader.vue
+++ b/src/components/AppHeader.vue
@@ -277,7 +277,7 @@ export default {