Skip to content
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bdf47ee
add basic choice menu
jamesmisson Apr 7, 2026
5fd26ad
refactor choice menu as Dialogue
jamesmisson Apr 7, 2026
5dea0db
style dialogue
jamesmisson Apr 7, 2026
dc33019
add layers icon
jamesmisson Apr 7, 2026
e218abb
add cookbook manifest to examples
jamesmisson Apr 8, 2026
095f6a4
support choice on 2-up view
jamesmisson Apr 27, 2026
4f6c0cf
add missing width and height to AnnotationOverlayRect interface
jamesmisson Apr 27, 2026
c7246b8
update manifold, fix commit cherry pick bug
jamesmisson Apr 27, 2026
1b5596f
clean up
jamesmisson Apr 27, 2026
3cef59e
remove accidental empty file, unused variable
jamesmisson Apr 27, 2026
8d1f98d
remove old updateChoiceSwitch function
jamesmisson Apr 27, 2026
62235b3
redo 2-up choice menu
jamesmisson Apr 29, 2026
c335bb0
add paged choice combinations manifest to examples
jamesmisson Apr 29, 2026
c1d3578
update example manifest
jamesmisson Apr 29, 2026
1f926ba
hide button when navigating to no choice canvas
jamesmisson Apr 29, 2026
03a0522
remove duplicated constructor and methods from dialogue
jamesmisson Apr 29, 2026
321bb85
separate concerns between abstract dialog class and osd dialog class
jamesmisson Apr 29, 2026
f554bcd
add internationalisation
jamesmisson Apr 29, 2026
959631d
move event subscription to osd extension
jamesmisson Apr 29, 2026
292783f
refactor repeated code to indicesIncludeChoices
jamesmisson Apr 29, 2026
0c82cd4
remove console log
jamesmisson Apr 29, 2026
b8e8518
whitespace
jamesmisson Apr 29, 2026
90bd1f2
keep controls visible when choice dialogue open
jamesmisson May 7, 2026
bc567aa
enable scroll zoom while menu open
jamesmisson May 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"@google/model-viewer": "^4.0.0",
"@iiif/base-component": "2.0.1",
"@iiif/iiif-av-component": "1.2.4",
"@iiif/manifold": "^2.2.0",
"@iiif/manifold": "^2.3.0",
"@iiif/presentation-3": "^1.0.5",
"@iiif/vocabulary": "^1.0.31",
"@openseadragon-imaging/openseadragon-viewerinputhook": "^2.2.1",
Expand Down
10 changes: 10 additions & 0 deletions src/content-handlers/iiif/BaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@ export type AdjustImageDialogue = ModuleConfig & {
content: AdjustImageDialogueContent;
};

type ChoiceSwitchDialogueOptions = DialogueOptions & {};

type ChoiceSwitchDialogueContent = DialogueContent & {};

export type ChoiceSwitchDialogue = ModuleConfig & {
options: ChoiceSwitchDialogueOptions;
content: ChoiceSwitchDialogueContent;
};

export type DownloadDialogueOptions = DialogueOptions & {};

export type DownloadDialogueContent = DialogueContent & {
Expand Down Expand Up @@ -473,6 +482,7 @@ export type BaseConfig = {
settingsDialogue: SettingsDialogue;
shareDialogue: ShareDialogue;
adjustImageDialogue: AdjustImageDialogue;
choiceSwitchDialogue: ChoiceSwitchDialogue;
};
localisation: Localisation;
content: Content;
Expand Down
2 changes: 2 additions & 0 deletions src/content-handlers/iiif/IIIFEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class IIIFEvents {
static BOOKMARK: string = "bookmark";
static CANVAS_INDEX_CHANGE_FAILED: string = "canvasIndexChangeFailed";
static CANVAS_INDEX_CHANGE: string = "canvasIndexChange";
static CHOICE_CHANGE: string = "choiceChange";
static CLEAR_ANNOTATIONS: string = "clearAnnotations";
static CLICKTHROUGH: string = "clickthrough";
static CLOSE_ACTIVE_DIALOGUE: string = "closeActiveDialogue";
Expand Down Expand Up @@ -90,6 +91,7 @@ export class IIIFEvents {
static SETTINGS_CHANGE: string = "settingsChange";
static SHOW_AUTH_DIALOGUE: string = "showAuthDialogue";
static SHOW_CLICKTHROUGH_DIALOGUE: string = "showClickThroughDialogue";
static SHOW_CHOICE_SWITCH_DIALOGUE: string = "showChoiceSwitchDialogue";
static SHOW_DOWNLOAD_DIALOGUE: string = "showDownloadDialogue";
static SHOW_EMBED_DIALOGUE: string = "showEmbedDialogue";
static SHOW_EXTERNALCONTENT_DIALOGUE: string = "showExternalContentDialogue";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@
"remember": "$remember"
}
},
"choiceSwitchDialogue": {
"options": {
"topCloseButtonEnabled": false
},
"content": {
"close": "$close"
}
},
"clickThroughDialogue": {
"options": {
"topCloseButtonEnabled": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,14 @@
"remember": "$remember"
}
},
"choiceSwitchDialogue": {
"options": {
"topCloseButtonEnabled": false
},
"content": {
"close": "$close"
}
},
"clickThroughDialogue": {
"options": {
"topCloseButtonEnabled": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@
"remember": "$remember"
}
},
"choiceSwitchDialogue": {
"options": {
"topCloseButtonEnabled": false
},
"content": {
"close": "$close"
}
},
"clickThroughDialogue": {
"options": {
"topCloseButtonEnabled": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@
"remember": "$remember"
}
},
"choiceSwitchDialogue": {
"options": {
"topCloseButtonEnabled": false
},
"content": {
"close": "$close"
}
},
"clickThroughDialogue": {
"options": {
"topCloseButtonEnabled": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@
"remember": "$remember"
}
},
"choiceSwitchDialogue": {
"options": {
"topCloseButtonEnabled": false
},
"content": {
"close": "$close"
}
},
"clickThroughDialogue": {
"options": {
"topCloseButtonEnabled": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@
"reset": "$reset",
"remember": "$remember"
}
},
"choiceSwitchDialogue": {
"options": {
"topCloseButtonEnabled": false
},
"content": {
"close": "$close"
}
}
},
"localisation": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ChoiceSwitchDialogue as BaseChoiceSwitchDialogue } from "../../modules/uv-dialogues-module/ChoiceSwitchDialogue";
import { Shell } from "../../modules/uv-shared-module/Shell";

export class ChoiceSwitchDialogue extends BaseChoiceSwitchDialogue {
constructor($element: JQuery, shell: Shell) {
super($element, shell);
}

Comment thread
jamesmisson marked this conversation as resolved.
Outdated
create(): void {
this.setConfig("choiceSwitchDialogue");
super.create();
}

resize(): void {
super.resize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export class OpenSeadragonExtensionEvents {

static CURRENT_VIEW_URI: string =
OpenSeadragonExtensionEvents.namespace + "currentViewUri";
static CHOICE_CHANGE: string =
OpenSeadragonExtensionEvents.namespace + "choiceChange";
static DOUBLECLICK: string =
OpenSeadragonExtensionEvents.namespace + "doubleClick";
static IMAGE_SEARCH: string =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { merge } from "../../../../Utils";
import defaultConfig from "./config/config.json";
import { Config } from "./config/Config";
import { AdjustImageDialogue } from "../../modules/uv-dialogues-module/AdjustImageDialogue";
import { ChoiceSwitchDialogue } from "../../modules/uv-dialogues-module/ChoiceSwitchDialogue";

export default class OpenSeadragonExtension extends BaseExtension<Config> {
$downloadDialogue: JQuery;
Expand All @@ -64,6 +65,7 @@ export default class OpenSeadragonExtension extends BaseExtension<Config> {
$settingsDialogue: JQuery;
$shareDialogue: JQuery;
$adjustImageDialogue: JQuery;
$choiceSwitchDialogue: JQuery;
centerPanel: OpenSeadragonCenterPanel;
currentAnnotationRect: AnnotationRect | null;
currentRotation: number = 0;
Expand All @@ -73,6 +75,7 @@ export default class OpenSeadragonExtension extends BaseExtension<Config> {
headerPanel: PagingHeaderPanel;
helpDialogue: HelpDialogue;
adjustImageDialogue: AdjustImageDialogue;
choiceSwitchDialogue: ChoiceSwitchDialogue;
isAnnotating: boolean = false;
leftPanel: ContentLeftPanel;
mobileFooterPanel: MobileFooterPanel;
Expand Down Expand Up @@ -110,6 +113,8 @@ export default class OpenSeadragonExtension extends BaseExtension<Config> {
(canvasIndex: number) => {
this.previousAnnotationRect = null;
this.currentAnnotationRect = null;

// JM todo: make config option for preserving choice over canvas changes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to do this TODO before merging? Should we open an issue rather than leaving this comment in the code?

this.changeCanvas(canvasIndex);
}
);
Expand Down Expand Up @@ -600,6 +605,17 @@ export default class OpenSeadragonExtension extends BaseExtension<Config> {
if (this.isFooterPanelEnabled()) {
this.footerPanel.init();
}

if (this.helper.hasChoices()) {
this.$choiceSwitchDialogue = $(
'<div class="overlay choiceSwitch" aria-hidden="true"></div>'
);
this.shell.$overlays.append(this.$choiceSwitchDialogue);
this.choiceSwitchDialogue = new ChoiceSwitchDialogue(
this.$choiceSwitchDialogue,
this.shell
);
}
}

render(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AdjustImageDialogue,
ChoiceSwitchDialogue,
BaseConfig,
CenterPanelContent,
CenterPanelOptions,
Expand Down Expand Up @@ -289,6 +290,7 @@ type Modules = {
shareDialogue: OSDShareDialogue;
settingsDialogue: OSDSettingsDialogue;
adjustImageDialogue: AdjustImageDialogue;
choiceSwitchDialogue: ChoiceSwitchDialogue;
};

export type Config = BaseConfig & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@
"remember": "$remember"
}
},
"choiceSwitchDialogue": {
"options": {
"topCloseButtonEnabled": false
},
"content": {
"close": "$close"
}
},
"clickThroughDialogue": {
"options": {
"topCloseButtonEnabled": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@
"remember": "$remember"
}
},
"choiceSwitchDialogue": {
"options": {
"topCloseButtonEnabled": false
},
"content": {
"close": "$close"
}
},
"moreInfoRightPanel": {
"options": {
"canvasDisplayOrder": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { BaseConfig } from "../../BaseConfig";
import { IIIFEvents } from "../../IIIFEvents";
import { Dialogue } from "../uv-shared-module/Dialogue";
import OpenSeadragonExtension from "../../extensions/uv-openseadragon-extension/Extension";
import { Shell } from "../uv-shared-module/Shell";

export class ChoiceSwitchDialogue extends Dialogue<
BaseConfig["modules"]["choiceSwitchDialogue"]
> {
$choiceList: JQuery;
shell: Shell;

constructor($element: JQuery, shell: Shell) {
super($element);
this.shell = shell;
}

create(): void {
this.setConfig("choiceSwitchDialogue");

super.create();

this.extensionHost.subscribe(IIIFEvents.SHOW_CHOICE_SWITCH_DIALOGUE, () => {
this.open();
});

this.$choiceList = $(
'<div class="choiceList" role="radiogroup" aria-label="Image choices"></div>'
);
this.$content.append(this.$choiceList);

this.$closeButton.hide();

this.$element.hide();
}

open(): void {
this.$choiceList.empty();

const choices = (<OpenSeadragonExtension>(
Comment thread
jamesmisson marked this conversation as resolved.
Outdated
this.extension
)).helper.getChoices();

choices.forEach((choice, index) => {
const label = choice.getLabel().getValue() ?? `Choice ${index + 1}`;
const isActive =
index === (<OpenSeadragonExtension>this.extension).helper.choiceIndex;

const $item = $(`
<label class="choiceItem">
<input type="radio" name="choice" value="${index}" ${isActive ? "checked" : ""} />
${label}
</label>
`);

$item.find("input").on("change", () => {
this.extensionHost.publish(IIIFEvents.CHOICE_CHANGE, index);
});

this.$choiceList.append($item);
});

const $button = (<OpenSeadragonExtension>this.extension).centerPanel
.$choiceSwitchButton;
super.open($button[0]);
this.shell.$overlays.css("background", "none");
}

close(): void {
this.shell.$overlays.css("background", "");
super.close();
}

resize(): void {
super.resize();
this.setDockedPosition("below");
}
}
Loading