Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Nov 7, 2023
2 parents c146cb4 + 72ae729 commit f58aa7e
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ export class ContentLeftPanel extends LeftPanel {
const range: Range = topRanges[i];
this.$treeSelect.append(
'<option value="' +
range.id +
'">' +
LanguageMap.getValue(range.getLabel()) +
"</option>"
range.id +
'">' +
LanguageMap.getValue(range.getLabel()) +
"</option>"
);
}
}
Expand Down Expand Up @@ -456,10 +456,8 @@ export class ContentLeftPanel extends LeftPanel {
// height = this.config.options.oneColThumbHeight;
// }

const thumbs: Thumb[] = <Thumb[]>(
this.extension.helper.getThumbs(90)
// this.extension.helper.getThumbs(width, height)
);
const thumbs: Thumb[] = <Thumb[]>this.extension.helper.getThumbs(90);
// this.extension.helper.getThumbs(width, height)

if (
viewingDirection &&
Expand Down Expand Up @@ -491,7 +489,9 @@ export class ContentLeftPanel extends LeftPanel {
}
}

const paged: boolean = (!!this.extension.getSettings().pagingEnabled && this.extension.helper.isPaged());
const paged: boolean =
!!this.extension.getSettings().pagingEnabled &&
this.extension.helper.isPaged();

const selectedIndices: number[] = this.extension.getPagedIndices(
this.extension.helper.canvasIndex
Expand Down Expand Up @@ -555,7 +555,7 @@ export class ContentLeftPanel extends LeftPanel {
return (
Bools.getBool(this.config.options.pageModeEnabled, true) &&
(<OpenSeadragonExtension>this.extension).getMode().toString() ===
Mode.page.toString()
Mode.page.toString()
);
}
return Bools.getBool(this.config.options.pageModeEnabled, true);
Expand Down Expand Up @@ -841,8 +841,8 @@ export class ContentLeftPanel extends LeftPanel {

this.$tabsContent.height(
this.$main.height() -
(isVisible(this.$tabs) ? this.$tabs.height() : 0) -
this.$tabsContent.verticalPadding()
(isVisible(this.$tabs) ? this.$tabs.height() : 0) -
this.$tabsContent.verticalPadding()
);
this.$views.height(
this.$tabsContent.height() - this.$options.outerHeight()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class TreeView extends BaseView {
"treeNodeSelected",
function(node: TreeNode) {
that.extensionHost.publish(IIIFEvents.TREE_NODE_SELECTED, node);
this.resize(); // renders the tree component and highlights the selected element
},
false
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
.treeView {
font-weight: normal;
overflow: auto;
padding: 0 @padding-medium-horizontal 0 0;

.iiif-tree-component ul li a.selected {
color: @brand-primary !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MediaElementExtensionEvents } from "../../extensions/uv-mediaelement-ex
import { CenterPanel } from "../uv-shared-module/CenterPanel";
import { IMediaElementExtension } from "../../extensions/uv-mediaelement-extension/IMediaElementExtension";
import { sanitize } from "../../../../Utils";
import { MediaType } from "@iiif/vocabulary/dist-commonjs/";
import { MediaType, RenderingFormat } from "@iiif/vocabulary/dist-commonjs/";
import {
AnnotationBody,
Canvas,
Expand Down Expand Up @@ -94,10 +94,19 @@ export class MediaElementCenterPanel extends CenterPanel {

if (renderings && renderings.length) {
canvas.getRenderings().forEach((rendering: Rendering) => {
sources.push({
type: rendering.getFormat().toString(),
src: rendering.id,
});
if (this.isTypeMedia(rendering)) {
sources.push({
type: rendering.getFormat().toString(),
src: rendering.id,
});
}

if (this.isTypeCaption(rendering)) {
subtitles.push({
label: rendering.getLabel().getValue() ?? rendering.getFormat().toString(),
id: rendering.id,
});
}
});
} else {
const formats: AnnotationBody[] | null = this.extension.getMediaFormats(
Expand All @@ -106,18 +115,23 @@ export class MediaElementCenterPanel extends CenterPanel {

if (formats && formats.length) {
formats.forEach((format: AnnotationBody) => {
const type: MediaType | null = format.getFormat();
const type = format.getFormat();

// Add any additional subtitle types if required.
if (type && type.toString() === "text/vtt") {
subtitles.push(format.__jsonld);
} else if (type) {
if (type === null) {
return;
}

if (this.isTypeMedia(format)) {
sources.push({
label: format.__jsonld.label ? format.__jsonld.label : "",
type: type.toString(),
src: format.id,
});
}

if (this.isTypeCaption(format)) {
subtitles.push(format.__jsonld);
}
});
}
}
Expand All @@ -128,6 +142,10 @@ export class MediaElementCenterPanel extends CenterPanel {
);

// Add VTT subtitles/captions.
if (subtitles.length > 0) {
// Show captions options popover for better interface feedback
subtitles.unshift({ id: "none" });
}
for (const subtitle of subtitles) {
this.$media.append(
$(`<track label="${subtitle.label}" kind="subtitles" srclang="${
Expand Down Expand Up @@ -276,6 +294,36 @@ export class MediaElementCenterPanel extends CenterPanel {
this.extensionHost.publish(Events.LOAD);
}

// audio/video
isTypeMedia(element: Rendering | AnnotationBody) {
const type: RenderingFormat | MediaType | null = element.getFormat();

if (type === null) {
return false;
}

const typeStr = type.toString();
const typeGroup = typeStr.split("/")[0];

return typeGroup === "audio" || typeGroup === "video";
}

// vtt, srt, csv
isTypeCaption(element: Rendering | AnnotationBody) {
const type: RenderingFormat | MediaType | null = element.getFormat();

if (type === null) {
return false;
}

const captionTypes = new Set<String>([
"text/vtt",
"text/srt",
]);

return captionTypes.has(type.toString());
}

isVideo(): boolean {
return (<IMediaElementExtension>this.extension).isVideo();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,8 +1309,10 @@ export class OpenSeadragonCenterPanel extends CenterPanel {
this.extension.helper.getViewingDirection() ||
ViewingDirection.LEFT_TO_RIGHT;

if (this.title) {
this.$title.text(sanitize(this.title));
if (this.extension.helper.isRightToLeft()) {
this.$title.addClass("rtl");
} else {
this.$title.removeClass("rtl");
}

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ export class PDFCenterPanel extends CenterPanel {

// use pdfjs cdn, it just isn't working with webpack
if (!this._pdfjsLib) {
await loadScripts(["//mozilla.github.io/pdf.js/build/pdf.js"]);
await loadScripts(["//cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"]);
this._pdfjsLib = window["pdfjs-dist/build/pdf"];
this._pdfjsLib.GlobalWorkerOptions.workerSrc =
"//mozilla.github.io/pdf.js/build/pdf.worker.js";
"//cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js";
} else {
this._$progress[0].setAttribute("value", "0");
this._$progress.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
IExternalResource,
IExternalResourceData,
IExternalResourceOptions,
// IExternalImageResourceData,
IExternalImageResourceData,
IManifestoOptions,
Manifest,
Range,
Expand Down Expand Up @@ -975,11 +975,11 @@ export class BaseExtension implements IExtension {
resource.data.hasServiceDescriptor = resource.hasServiceDescriptor();

// if the data isn't an info.json, give it the necessary viewing properties
// if (!resource.hasServiceDescriptor()) {
// resource.data.id = <string>resource.dataUri;
// (<IExternalImageResourceData>resource.data).width = resource.width;
// (<IExternalImageResourceData>resource.data).height = resource.height;
// }
if (!resource.hasServiceDescriptor()) {
resource.data.id = <string>resource.dataUri;
(<IExternalImageResourceData>resource.data).width = resource.width;
(<IExternalImageResourceData>resource.data).height = resource.height;
}

resource.data.index = resource.index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
text-overflow: ellipsis;
line-height: 30px;

&.rtl {
direction: rtl;
}

.xl-mediaquery({
padding: 0 20px 0 20px;
});
Expand Down

0 comments on commit f58aa7e

Please sign in to comment.