Skip to content

Commit

Permalink
Merge pull request #380 from d-i-t-a/bugfix/remove-unused-config
Browse files Browse the repository at this point in the history
removed uplink as it isn't used since v1
  • Loading branch information
aferditamuriqi authored Aug 10, 2022
2 parents 4341e21 + c07d321 commit d34368b
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 81 deletions.
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "@d-i-t-a/reader",
"version": "2.1.0-beta.4",
"version": "2.1.0-beta.5",
"description": "A viewer application for EPUB files.",
"repository": "https://github.com/d-i-t-a/R2D2BC",
"license": "Apache-2.0",
Expand Down
48 changes: 1 addition & 47 deletions src/navigator/IFrameNavigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ import EventHandler, {
} from "../utils/EventHandler";
import * as BrowserUtilities from "../utils/BrowserUtilities";
import * as HTMLUtilities from "../utils/HTMLUtilities";
import {
readerError,
readerLoading,
simpleUpLinkTemplate,
} from "../utils/HTMLTemplates";
import { readerError, readerLoading } from "../utils/HTMLTemplates";
import {
Annotation,
Locations,
Expand Down Expand Up @@ -118,11 +114,6 @@ export interface NavigatorAPI {
onError?: (e: Error) => void;
}

export interface UpLinkConfig {
url?: URL;
label?: string;
ariaLabel?: string;
}
export interface IFrameAttributes {
margin: number;
navHeight?: number;
Expand All @@ -137,7 +128,6 @@ export interface IFrameNavigatorConfig {
publication: Publication;
settings: UserSettings;
annotator?: Annotator;
upLink?: UpLinkConfig;
initialLastReadingPosition?: ReadingPosition;
rights: Partial<ReaderRights>;
api?: Partial<NavigatorAPI>;
Expand Down Expand Up @@ -196,7 +186,6 @@ export interface ReaderConfig {
userSettings?: any;
initialAnnotations?: any;
lastReadingPosition?: any;
upLinkUrl?: any;
rights?: Partial<ReaderRights>;
api?: Partial<NavigatorAPI>;
tts?: Partial<TTSModuleConfig>;
Expand Down Expand Up @@ -258,8 +247,6 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
private readonly touchEventHandler: TouchEventHandler;
private readonly keyboardEventHandler: KeyboardEventHandler;
private readonly sampleReadEventHandler: SampleReadEventHandler;
private readonly upLinkConfig: UpLinkConfig | undefined;
private upLink: HTMLAnchorElement | undefined = undefined;

private nextChapterBottomAnchorElement: HTMLAnchorElement;
private previousChapterTopAnchorElement: HTMLAnchorElement;
Expand Down Expand Up @@ -326,7 +313,6 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
const navigator = new this(
config.settings,
config.annotator || undefined,
config.upLink || undefined,
config.initialLastReadingPosition || undefined,
config.publication,
config.api,
Expand All @@ -349,7 +335,6 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
protected constructor(
settings: UserSettings,
annotator: Annotator | undefined = undefined,
upLinkConfig: UpLinkConfig | undefined = undefined,
initialLastReadingPosition: ReadingPosition | undefined = undefined,
publication: Publication,
api?: Partial<NavigatorAPI>,
Expand All @@ -370,7 +355,6 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
this.eventHandler = new EventHandler(this);
this.touchEventHandler = new TouchEventHandler(this);
this.keyboardEventHandler = new KeyboardEventHandler(this);
this.upLinkConfig = upLinkConfig;
this.initialLastReadingPosition = initialLastReadingPosition;
this.publication = publication;
this.api = api;
Expand Down Expand Up @@ -1241,36 +1225,6 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
}
}

if (
(this.links || this.linksTopLeft) &&
this.upLinkConfig &&
this.upLinkConfig.url
) {
const upUrl = this.upLinkConfig.url;
const upLabel = this.upLinkConfig.label || "";
const upAriaLabel = this.upLinkConfig.ariaLabel || upLabel;
var upHTML = simpleUpLinkTemplate(upUrl.href, upLabel, upAriaLabel);
const upParent: HTMLLIElement = document.createElement("li");
upParent.classList.add("uplink-wrapper");
upParent.innerHTML = upHTML;
if (this.links) {
this.links.insertBefore(upParent, this.links.firstChild);
this.upLink = HTMLUtilities.findRequiredElement(
this.links,
"a[rel=up]"
);
} else {
this.linksTopLeft.insertBefore(
upParent,
this.linksTopLeft.firstChild
);
this.upLink = HTMLUtilities.findRequiredElement(
this.linksTopLeft,
"a[rel=up]"
);
}
}

let lastReadingPosition: ReadingPosition | undefined = undefined;
if (this.annotator) {
lastReadingPosition = (await this.annotator.getLastReadingPosition()) as
Expand Down
4 changes: 0 additions & 4 deletions src/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
IFrameNavigator,
IFrameAttributes,
ReaderConfig,
UpLinkConfig,
ReaderRights,
} from "./navigator/IFrameNavigator";
import LocalAnnotator from "./store/LocalAnnotator";
Expand Down Expand Up @@ -158,8 +157,6 @@ export default class D2Reader {

const annotator = new LocalAnnotator({ store: store });

const upLink: UpLinkConfig = initialConfig.upLinkUrl ?? undefined;

publication.sample = initialConfig.sample;

// update our config based on what we know from the publication
Expand Down Expand Up @@ -212,7 +209,6 @@ export default class D2Reader {
publication: publication,
settings,
annotator: annotator,
upLink: upLink,
initialLastReadingPosition: initialConfig.lastReadingPosition,
api: initialConfig.api,
rights: rights,
Expand Down
22 changes: 0 additions & 22 deletions src/utils/HTMLTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,6 @@

import * as IconLib from "./IconLib";

export const simpleUpLinkTemplate = (
href: string,
_label: string,
ariaLabel: string
) => `
<a rel="up" href='${href}' aria-label="${ariaLabel}" style="padding: 0px"><i class="material-icons show-on-large">arrow_back_ios</i></a>
`;

export const defaultUpLinkTemplate = (
href: string,
label: string,
ariaLabel: string
) => `
<a rel="up" href='${href}' aria-label="${ariaLabel}">
<svg xmlns="http://www.w3.org/2000/svg" width="${IconLib.WIDTH_ATTR}" height="${IconLib.HEIGHT_ATTR}" viewBox="${IconLib.VIEWBOX_ATTR}" aria-labelledby="up-label" preserveAspectRatio="xMidYMid meet" role="img" class="icon">
<title id="up-label">${label}</title>
${IconLib.icons.home}
</svg>
<span class="setting-text up">${label}</span>
</a>
`;

export const readerLoading = `${IconLib.icons.loading}`;
export const readerError = `
<span>
Expand Down
1 change: 0 additions & 1 deletion viewer/index_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@
]

let urlParams = getURLQueryParams();
let upLink = { url: new URL("/", window.location.href), label: "Back", ariaLabel: "Go back" };

let d2reader = undefined;
D2Reader.load({
Expand Down
2 changes: 0 additions & 2 deletions viewer/index_dita.html
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,6 @@
return params;
};
let urlParams = getURLQueryParams();
let upLink = { url: new URL("/", window.location.href), label: "Back", ariaLabel: "Go back" };
let injectables = [
{ type: 'style', url: '/viewer/readium-css/ReadiumCSS-before.css', r2before: true },
{ type: 'style', url: '/viewer/readium-css/ReadiumCSS-default.css', r2default: true },
Expand Down Expand Up @@ -967,7 +966,6 @@

let d2reader;
D2Reader.load({
upLinkUrl: upLink,
url: new URL(urlParams['url']),
requestConfig: {
method: "GET",
Expand Down
2 changes: 0 additions & 2 deletions viewer/index_sampleread.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@
return params;
};
let urlParams = getURLQueryParams();
let upLink = { url: new URL("/", window.location.href), label: "Back", ariaLabel: "Go back" };
let injectables = [
{ type: 'style', url: '/viewer/readium-css/ReadiumCSS-before.css', r2before: true },
{ type: 'style', url: '/viewer/readium-css/ReadiumCSS-default.css', r2default: true },
Expand Down Expand Up @@ -269,7 +268,6 @@

let d2reader;
D2Reader.load({
upLinkUrl: upLink,
url: new URL(urlParams['url']),
attributes: {
margin: 120,
Expand Down

0 comments on commit d34368b

Please sign in to comment.