-
-
Notifications
You must be signed in to change notification settings - Fork 201
Add menu for canvas choice #1748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jamesmisson
wants to merge
24
commits into
UniversalViewer:v4.4.0
Choose a base branch
from
jamesmisson:choice-v2
base: v4.4.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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 5fd26ad
refactor choice menu as Dialogue
jamesmisson 5dea0db
style dialogue
jamesmisson dc33019
add layers icon
jamesmisson e218abb
add cookbook manifest to examples
jamesmisson 095f6a4
support choice on 2-up view
jamesmisson 4f6c0cf
add missing width and height to AnnotationOverlayRect interface
jamesmisson c7246b8
update manifold, fix commit cherry pick bug
jamesmisson 1b5596f
clean up
jamesmisson 3cef59e
remove accidental empty file, unused variable
jamesmisson 8d1f98d
remove old updateChoiceSwitch function
jamesmisson 62235b3
redo 2-up choice menu
jamesmisson c335bb0
add paged choice combinations manifest to examples
jamesmisson c1d3578
update example manifest
jamesmisson 1f926ba
hide button when navigating to no choice canvas
jamesmisson 03a0522
remove duplicated constructor and methods from dialogue
jamesmisson 321bb85
separate concerns between abstract dialog class and osd dialog class
jamesmisson f554bcd
add internationalisation
jamesmisson 959631d
move event subscription to osd extension
jamesmisson 292783f
refactor repeated code to indicesIncludeChoices
jamesmisson 0c82cd4
remove console log
jamesmisson b8e8518
whitespace
jamesmisson 90bd1f2
keep controls visible when choice dialogue open
jamesmisson bc567aa
enable scroll zoom while menu open
jamesmisson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/content-handlers/iiif/extensions/uv-openseadragon-extension/ChoiceSwitchDialogue.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
|
|
||
| create(): void { | ||
| this.setConfig("choiceSwitchDialogue"); | ||
| super.create(); | ||
| } | ||
|
|
||
| resize(): void { | ||
| super.resize(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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; | ||
|
|
@@ -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; | ||
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
| ); | ||
|
|
@@ -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 { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/content-handlers/iiif/modules/uv-dialogues-module/ChoiceSwitchDialogue.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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>( | ||
|
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"); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.