Skip to content
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

Extending the thumbnail label to reveal more text #758 #950

Open
wants to merge 35 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3cb5067
gallery view checkbox
Saira-A Jan 5, 2024
283d676
checkbox in left panel
Saira-A Jan 5, 2024
d1c6d5b
4.1.0
Saira-A Jan 5, 2024
e856014
working checkbox test
Saira-A Jan 14, 2024
a48863c
checkbox test
Saira-A Jan 14, 2024
070e37f
left panel
Saira-A Jan 18, 2024
5547def
width 98px
Saira-A Jan 18, 2024
89afa9d
labels extended by default
Saira-A Jan 18, 2024
b166ff3
translations
Saira-A Jan 18, 2024
d438487
testing
Saira-A Jan 18, 2024
7451743
comments
Saira-A Jan 19, 2024
f509070
review
Saira-A Jan 23, 2024
217f718
changes
Saira-A Jan 24, 2024
6aede73
remove whitespace
Saira-A Jan 24, 2024
bfcae9e
galleryView label height
Saira-A Jan 26, 2024
6215786
Revert "4.1.0"
Saira-A Feb 2, 2024
a71c7f1
Revert "4.1.0"
Saira-A Feb 2, 2024
55221dc
tests updated
Saira-A Feb 2, 2024
b4aa8d3
Revert "Revert "4.1.0""
Saira-A Feb 5, 2024
be33e3b
default to true
Saira-A Feb 13, 2024
4ec467f
update test
Saira-A Feb 13, 2024
be384a4
config
Saira-A Feb 13, 2024
db421f8
Truncate by default
Saira-A Feb 26, 2024
60e53fe
update test
Saira-A Feb 26, 2024
00a7917
Remove unnecessary newline.
demiankatz Feb 26, 2024
6ba0b98
Restore lost indentation.
demiankatz Feb 26, 2024
7c104e1
Fix indentation.
demiankatz Feb 26, 2024
76acb6e
Remove extra blank line.
demiankatz Feb 26, 2024
43d30dd
Fix indentation.
demiankatz Feb 26, 2024
5e4c880
Remove unwanted newline.
demiankatz Feb 26, 2024
1020ac2
Remove newline.
demiankatz Feb 26, 2024
751df42
Whitespace cleanup.
demiankatz Feb 26, 2024
7552f7d
resolve conflicts
Saira-A Jul 18, 2024
8b751fb
remove tests
Saira-A Jul 18, 2024
0a8f88b
Merge branch 'dev' into 758
Saira-A Jul 18, 2024
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
58 changes: 56 additions & 2 deletions __tests__/test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,67 @@
test.skip('Configuration options', () => {});

const puppeteer = require('puppeteer');

describe('Universal Viewer', () => {
let browser;
let page;

beforeAll(async () => {
await page.goto('http://localhost:4444/');
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:8080/#?xywh=-1741%2C125%2C8017%2C6807&iiifManifestId=http%3A%2F%2Fiiif.bodleian.ox.ac.uk%2Fexamples%2Fmushaf4.json');
});

afterAll(async () => {
await browser.close();
});

it('has the correct page title', async () => {
const title = await page.title();
expect(title).toBe('Universal Viewer Examples');
});

it('can toggle thumbnail label truncation', async () => {
await page.waitForSelector('#truncateThumbnailLabels');

const isCheckedBeforeToggle = await page.$eval('#truncateThumbnailLabels', checkbox => checkbox.checked);
expect(isCheckedBeforeToggle).toBe(true);

const labelOverflowBeforeToggle = await page.evaluate(() => {
const label = document.querySelector('.thumbs .thumb .info .label');
return getComputedStyle(label).overflowX;
});
expect(labelOverflowBeforeToggle).toBe('visible');

await page.evaluate(() => {
document.querySelector('#truncateThumbnailLabels').click();
});

const isCheckedAfterToggle = await page.$eval('#truncateThumbnailLabels', checkbox => checkbox.checked);
expect(isCheckedAfterToggle).toBe(false);

const labelOverflowAfterToggle = await page.evaluate(() => {
const label = document.querySelector('.thumbs .thumb .info .label');
return getComputedStyle(label).overflowX;
});
expect(labelOverflowAfterToggle).toBe('hidden');
});

it('settings button is visible', async () => {

await page.waitForSelector('.btn.imageBtn.settings');


const isSettingsButtonVisible = await page.evaluate(() => {
const settingsButton = document.querySelector('.btn.imageBtn.settings');
const style = window.getComputedStyle(settingsButton);
return style.getPropertyValue('visibility') !== 'hidden' && style.getPropertyValue('display') !== 'none';
});

expect(isSettingsButtonVisible).toBe(true);
});
});

// it('loads the viewer images', async () => {
// await page.waitForSelector('#thumb0');
// const imageSrc = await page.$eval('#thumb0 img', e => e.src);
Expand All @@ -17,4 +71,4 @@ describe('Universal Viewer', () => {
// )
// );
// });
});

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
"enableTsDiagnostics": true
}
},
"testTimeout": 10000,
"preset": "jest-puppeteer",
"transform": {
"^.+\\.tsx?$": "ts-jest"
Expand Down
1 change: 1 addition & 0 deletions src/content-handlers/iiif/BaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export type SettingsDialogueContent = DialogueContent & {
clickToZoomEnabled: string;
pagingEnabled: string;
reducedMotion: string;
truncateThumbnailLabels: string;
preserveViewport: string;
title: string;
website: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
"clickToZoomEnabled": "Mouse Click To Zoom",
"pagingEnabled": "Two Page View",
"reducedMotion": "Reduce motion (disables animations)",
"truncateThumbnailLabels": "Display Full Thumbnail Labels",
"preserveViewport": "Preserve Zoom",
"title": "Settings",
"website": "<a href='https://github.com/universalviewer/universalviewer#contributors'>more info</a>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"truncateThumbnailLabels": "$truncateThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"truncateThumbnailLabels": "$truncateThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"truncateThumbnailLabels": "$truncateThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"truncateThumbnailLabels": "$truncateThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"truncateThumbnailLabels": "$truncateThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ interface ISettings {
preserveViewport?: boolean;
clickToZoomEnabled?: boolean;
reducedAnimation?: boolean;
truncateThumbnailLabels?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export class SettingsDialogue extends BaseSettingsDialogue {
$clickToZoomEnabled: JQuery;
$clickToZoomEnabledCheckbox: JQuery;
$clickToZoomEnabledLabel: JQuery;
$truncateThumbnailLabels: JQuery;
$truncateThumbnailLabelsLabel: JQuery;
$truncateThumbnailLabelsCheckbox: JQuery;
$navigatorEnabled: JQuery;
$navigatorEnabledCheckbox: JQuery;
$navigatorEnabledLabel: JQuery;
Expand All @@ -15,6 +18,7 @@ export class SettingsDialogue extends BaseSettingsDialogue {
$preserveViewportCheckbox: JQuery;
$preserveViewportLabel: JQuery;


constructor($element: JQuery) {
super($element);
}
Expand Down Expand Up @@ -53,6 +57,32 @@ export class SettingsDialogue extends BaseSettingsDialogue {
);
this.$pagingEnabled.append(this.$pagingEnabledLabel);

this.$truncateThumbnailLabels = $('<div class="setting truncateThumbnailLabels"></div>');
this.$scroll.append(this.$truncateThumbnailLabels);

this.$truncateThumbnailLabelsCheckbox = $(
'<input id="truncateThumbnailLabels" type="checkbox" tabindex="0" />'
);

this.$truncateThumbnailLabels.append(this.$truncateThumbnailLabelsCheckbox);

this.$truncateThumbnailLabelsLabel = $(
'<label for="truncateThumbnailLabels">' + this.content.truncateThumbnailLabels + "</label>"
);

this.$truncateThumbnailLabels.append(this.$truncateThumbnailLabelsLabel);

const settings: ISettings = {};
this.$truncateThumbnailLabelsCheckbox.prop('checked', settings.truncateThumbnailLabels || true);

this.$truncateThumbnailLabelsCheckbox.change(() => {
const settings: ISettings = {};

settings.truncateThumbnailLabels = this.$truncateThumbnailLabelsCheckbox.is(":checked");

this.updateSettings(settings);
});

this.$clickToZoomEnabled = $('<div class="setting clickToZoom"></div>');
this.$scroll.append(this.$clickToZoomEnabled);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"rightPanelEnabled": true,
"saveUserSettings": false,
"clickToZoomEnabled": true,
"truncateThumbnailLabels": true,
"searchWithinEnabled": true,
"seeAlsoEnabled": false,
"termsOfUseEnabled": true,
Expand Down Expand Up @@ -365,6 +366,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$goHome",
"reducedMotion": "$reducedMotion",
"truncateThumbnailLabels": "$truncateThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$goHome",
"reducedMotion": "$reducedMotion",
"truncateThumbnailLabels": "$truncateThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,27 +491,28 @@ export class ContentLeftPanel extends LeftPanel<ContentLeftPanelConfig> {
}

const paged: boolean =
!!this.extension.getSettings().pagingEnabled &&
this.extension.helper.isPaged();
!!this.extension.getSettings().pagingEnabled &&
Saira-A marked this conversation as resolved.
Show resolved Hide resolved
this.extension.helper.isPaged();

const selectedIndices: number[] = this.extension.getPagedIndices(
this.extension.helper.canvasIndex
);

// console.log("selectedIndeces", selectedIndices);
const settings = this.extension.getSettings();

this.thumbsRoot.render(
createElement(ThumbsView, {
thumbs,
paged,
viewingDirection: viewingDirection || ViewingDirection.LEFT_TO_RIGHT,
selected: selectedIndices,
truncateThumbnailLabels: settings.truncateThumbnailLabels !== undefined ? settings.truncateThumbnailLabels : true,
onClick: (thumb: Thumb) => {
this.extensionHost.publish(IIIFEvents.THUMB_SELECTED, thumb);
},
})
);
}
}

createGalleryView(): void {
this.galleryView = new GalleryView(this.$galleryView);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const $ = require("jquery");
import { IIIFEvents } from "../../IIIFEvents";
import { ContentLeftPanel } from "../../extensions/config/ContentLeftPanel";
import { BaseView } from "../uv-shared-module/BaseView";
import { GalleryComponent } from "@iiif/iiif-gallery-component";
import $ from "jquery";

export class GalleryView extends BaseView<ContentLeftPanel> {
isOpen: boolean = false;
Expand Down Expand Up @@ -31,7 +31,7 @@ export class GalleryView extends BaseView<ContentLeftPanel> {

this.galleryComponent.on(
"thumbSelected",
function(thumb: any) {
function (thumb: any) {
that.extensionHost.publish(IIIFEvents.GALLERY_THUMB_SELECTED, thumb);
that.extensionHost.publish(IIIFEvents.THUMB_SELECTED, thumb);
},
Expand All @@ -40,15 +40,15 @@ export class GalleryView extends BaseView<ContentLeftPanel> {

this.galleryComponent.on(
"decreaseSize",
function() {
function () {
that.extensionHost.publish(IIIFEvents.GALLERY_DECREASE_SIZE);
},
false
);

this.galleryComponent.on(
"increaseSize",
function() {
function () {
that.extensionHost.publish(IIIFEvents.GALLERY_INCREASE_SIZE);
},
false
Expand All @@ -68,6 +68,7 @@ export class GalleryView extends BaseView<ContentLeftPanel> {
// todo: would be better to have no imperative methods on components and use a reactive pattern
setTimeout(() => {
this.galleryComponent.selectIndex(this.extension.helper.canvasIndex);
this.applyExtendedLabelsStyles();
}, 10);
}

Expand All @@ -82,4 +83,10 @@ export class GalleryView extends BaseView<ContentLeftPanel> {
const $header: JQuery = this.$gallery.find(".header");
$main.height(this.$element.height() - $header.height());
}

public applyExtendedLabelsStyles(): void {

this.$gallery.addClass('label-extended');
}

}
Loading