From d1a390585b05feac33230e977133a09ce51dfa68 Mon Sep 17 00:00:00 2001 From: jamesmisson Date: Wed, 27 May 2026 12:27:25 +0100 Subject: [PATCH 1/3] remove redundant conditional rendering --- .../ChoiceSwitchDialogue.ts | 1 + .../uv-openseadragon-extension/Extension.ts | 18 ++++++++---------- .../OpenSeadragonCenterPanel.ts | 11 +++-------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/ChoiceSwitchDialogue.ts b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/ChoiceSwitchDialogue.ts index a01119788..329d8823a 100644 --- a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/ChoiceSwitchDialogue.ts +++ b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/ChoiceSwitchDialogue.ts @@ -86,6 +86,7 @@ export class ChoiceSwitchDialogue extends BaseChoiceSwitchDialogue { }); const mobileFooterButton = extension.mobileFooterPanel?.$choiceSwitchButton; + this.$anchor = mobileFooterButton?.is(":visible") && mobileFooterButton?.length ? mobileFooterButton diff --git a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts index bed219f7e..a0baa31ee 100644 --- a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts @@ -620,16 +620,14 @@ export default class OpenSeadragonExtension extends BaseExtension { this.footerPanel.init(); } - if (this.helper.hasChoices()) { - this.$choiceSwitchDialogue = $( - '' - ); - this.shell.$overlays.append(this.$choiceSwitchDialogue); - this.choiceSwitchDialogue = new ChoiceSwitchDialogue( - this.$choiceSwitchDialogue, - this.shell - ); - } + this.$choiceSwitchDialogue = $( + '' + ); + this.shell.$overlays.append(this.$choiceSwitchDialogue); + this.choiceSwitchDialogue = new ChoiceSwitchDialogue( + this.$choiceSwitchDialogue, + this.shell + ); } render(): void { diff --git a/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts b/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts index 9c69191e4..65cdb28ce 100644 --- a/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts +++ b/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts @@ -636,6 +636,8 @@ export class OpenSeadragonCenterPanel extends CenterPanel< this.hidePrevButton(); this.hideNextButton(); + this.createChoiceSwitch(); + this.isCreated = true; //this.resize(); @@ -659,8 +661,6 @@ export class OpenSeadragonCenterPanel extends CenterPanel< { capture: true } ); - this.createChoiceSwitch(); - this.extensionHost.subscribe(IIIFEvents.CLOSE_ACTIVE_DIALOGUE, () => { this.$viewer.removeClass("dialogue-open"); }); @@ -773,12 +773,6 @@ export class OpenSeadragonCenterPanel extends CenterPanel< } createChoiceSwitch(): void { - // check for a choice on either of the displayed canvases if in 2-up view - const indices = this.extension.getPagedIndices(); - const hasChoices = this.indicesIncludeChoices(indices); - - if (!hasChoices) return; - this.$choiceSwitchButton = this.$rotateButton.clone(); this.$choiceSwitchButton.attr("title", this.content.layers); this.$choiceSwitchButton.attr("aria-label", this.content.layers); @@ -791,6 +785,7 @@ export class OpenSeadragonCenterPanel extends CenterPanel< this.$choiceSwitchButton.insertAfter(this.$rotateButton); } this.onAccessibleClick(this.$choiceSwitchButton, () => { + console.log("choice clicked"); this.extensionHost.publish(IIIFEvents.SHOW_CHOICE_SWITCH_DIALOGUE); }); } From b58d01361475a39b6170929203db3dfe5df13c2b Mon Sep 17 00:00:00 2001 From: jamesmisson Date: Wed, 27 May 2026 12:34:37 +0100 Subject: [PATCH 2/3] remove console log --- .../OpenSeadragonCenterPanel.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts b/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts index 65cdb28ce..1cffbb57e 100644 --- a/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts +++ b/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts @@ -785,7 +785,6 @@ export class OpenSeadragonCenterPanel extends CenterPanel< this.$choiceSwitchButton.insertAfter(this.$rotateButton); } this.onAccessibleClick(this.$choiceSwitchButton, () => { - console.log("choice clicked"); this.extensionHost.publish(IIIFEvents.SHOW_CHOICE_SWITCH_DIALOGUE); }); } From 46c319cd411ffe748bef70f58f37c1e9857b910f Mon Sep 17 00:00:00 2001 From: jamesmisson Date: Wed, 27 May 2026 13:41:00 +0100 Subject: [PATCH 3/3] new pr --- .../OpenSeadragonCenterPanel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts b/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts index 1cffbb57e..bcf0ae0ba 100644 --- a/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts +++ b/src/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.ts @@ -774,8 +774,8 @@ export class OpenSeadragonCenterPanel extends CenterPanel< createChoiceSwitch(): void { this.$choiceSwitchButton = this.$rotateButton.clone(); - this.$choiceSwitchButton.attr("title", this.content.layers); this.$choiceSwitchButton.attr("aria-label", this.content.layers); + this.$choiceSwitchButton.attr("title", this.content.layers); this.$choiceSwitchButton.switchClass("rotate", "choiceSwitch"); this.$choiceSwitchButton.attr("tabindex", 0);