Skip to content

Commit

Permalink
Fix detail view navigation if no thumbnail is selected. Add fast forw…
Browse files Browse the repository at this point in the history
…ard and backward buttons to skip many media.
  • Loading branch information
thomaslow committed Nov 7, 2024
1 parent 0b03285 commit 3fe8132
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ public MediaPartialsPanel getMediaPartialsPanel() {
}

/**
* Return true if the currently selected media (that is shown in the detail view) is the verify
* Return true if the currently selected media (that is shown in the detail view) is the
* first media of all available media.
* @return boolean true if selected media is first media
*/
Expand Down Expand Up @@ -1078,7 +1078,7 @@ public boolean isSelectedMediaFirst() {
}

/**
* Return true if the currently selected media (that is shown in the detail view) is the verify
* Return true if the currently selected media (that is shown in the detail view) is the
* last media of all available media.
* @return boolean true if selected media is last media
*/
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css
Original file line number Diff line number Diff line change
Expand Up @@ -3436,7 +3436,7 @@ Column content
}

#imagePreviewForm .mediaDetailNavigationPanel button {
margin: var(--default-full-size);
margin: var(--default-full-size) var(--default-half-size);
pointer-events: all;
opacity: 0.0;
transition: opacity 0.1s linear;
Expand Down
30 changes: 30 additions & 0 deletions Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,36 @@ metadataEditor.pagination = {
}
};

metadataEditor.detailView = {

/**
* Select the previous or following media when clicking on the navigation buttons of the detail view.
* @param {int} delta position delta with respect to currently selected media
*/
navigate(delta) {
// find media currently shown in detail view
let currentTreeNodeId = $("#imagePreviewForm\\:mediaDetail").data("logicaltreenodeid");
if (!currentTreeNodeId) {
return;
}
// find current media in list of thumbnails
let thumbnails = $("#imagePreviewForm .thumbnail-container");
let currentThumbnail = $("#imagePreviewForm .thumbnail-container[data-logicaltreenodeid='" + currentTreeNodeId + "']");
let index = thumbnails.index(currentThumbnail);
if (index < 0) {
return;
}
// add delta to find previous or next thumbnail
index = Math.min(thumbnails.length - 1, Math.max(0, index + delta));
let nextThumbnail = thumbnails.eq(index);
let nextTreeNodeId = nextThumbnail.data("logicaltreenodeid");
// update selection and trigger reload of detail view
metadataEditor.gallery.pages.handleSingleSelect(null, nextThumbnail, nextTreeNodeId);
metadataEditor.gallery.pages.handleSelectionUpdates(nextTreeNodeId);
scrollToPreviewThumbnail(nextThumbnail, $("#thumbnailStripeScrollableContent"));
}
};

metadataEditor.contextMenu = {
listen() {
document.oncontextmenu = function(event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough">

<h:panelGroup id="mediaDetail" layout="block">
<ui:param name="selectedGalleryMediaContent"
value="#{DataEditorForm.galleryPanel.getGalleryMediaContent(DataEditorForm.galleryPanel.lastSelection.key)}"/>
<ui:param name="selectedGalleryMediaContent"
value="#{DataEditorForm.galleryPanel.getGalleryMediaContent(DataEditorForm.galleryPanel.lastSelection.key)}"/>

<h:panelGroup id="mediaDetail"
layout="block"
a:data-logicaltreenodeid="#{selectedGalleryMediaContent.getLogicalTreeNodeId()}">

<ui:fragment
rendered="#{mediaProvider.hasMediaViewVariant(selectedGalleryMediaContent) and (fn:startsWith(selectedGalleryMediaContent.mediaViewMimeType, 'video') or fn:startsWith(selectedGalleryMediaContent.mediaViewMimeType, 'audio'))}">
Expand Down Expand Up @@ -92,16 +95,22 @@
</ui:fragment>

<p:outputPanel styleClass="mediaDetailNavigationPanel">
<p:commandButton id="mediaDetailNavigationPreviousButton"
title="#{msgs['dataEditor.navigateToPreviousElement']}"
<p:commandButton title="#{msgs['dataEditor.navigateToPreviousElement']}"
disabled="#{DataEditorForm.galleryPanel.isSelectedMediaFirst()}"
icon="fa fa-arrow-left fa-lg"
onclick="metadataEditor.shortcuts.navigateByShortcut(-1, false);" />
<p:commandButton id="mediaDetailNavigationNextButton"
title="#{msgs['dataEditor.navigateToNextElement']}"
icon="fa fa-angle-double-left fa-lg"
onclick="metadataEditor.detailView.navigate(-20);" />
<p:commandButton title="#{msgs['dataEditor.navigateToPreviousElement']}"
disabled="#{DataEditorForm.galleryPanel.isSelectedMediaFirst()}"
icon="fa fa-angle-left fa-lg"
onclick="metadataEditor.detailView.navigate(-1);" />
<p:commandButton title="#{msgs['dataEditor.navigateToNextElement']}"
disabled="#{DataEditorForm.galleryPanel.isSelectedMediaLast()}"
icon="fa fa-angle-right fa-lg"
onclick="metadataEditor.detailView.navigate(+1);" />
<p:commandButton title="#{msgs['dataEditor.navigateToNextElement']}"
disabled="#{DataEditorForm.galleryPanel.isSelectedMediaLast()}"
icon="fa fa-arrow-right fa-lg"
onclick="metadataEditor.shortcuts.navigateByShortcut(1, false);" />
icon="fa fa-angle-double-right fa-lg"
onclick="metadataEditor.detailView.navigate(+20);" />
</p:outputPanel>

</h:panelGroup>
Expand Down

0 comments on commit 3fe8132

Please sign in to comment.