Skip to content

Commit

Permalink
Merge pull request #460 from d-i-t-a/develop
Browse files Browse the repository at this point in the history
2.3.4
  • Loading branch information
aferditamuriqi authored Apr 21, 2023
2 parents 05db925 + 9815681 commit 88c6a4e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
28 changes: 11 additions & 17 deletions src/modules/history/HistoryModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,20 @@ export class HistoryModule implements ReaderModule {
let lastReadingPosition = (await this.annotator.getLastReadingPosition()) as
| ReadingPosition
| undefined;
if (
lastReadingPosition &&
lastReadingPosition?.locations.progression &&
lastReadingPosition?.locations.progression > 0
) {
if (lastReadingPosition) {
const linkHref = this.publication.getAbsoluteHref(
lastReadingPosition.href
);
lastReadingPosition.href = linkHref;

if (this.historyCurrentIndex < this.history.length - 1) {
this.history = this.history.slice(0, this.historyCurrentIndex);
}
lastInHistory = this.history[this.history.length - 1];
if (
(lastInHistory && lastInHistory.href !== lastReadingPosition.href) ||
lastInHistory === undefined
this.history.push(lastReadingPosition);
this.historyCurrentIndex = this.history.length - 1;
} else if (
lastReadingPosition?.locations.progression &&
lastReadingPosition?.locations.progression > 0
) {
const linkHref = this.publication.getAbsoluteHref(
lastReadingPosition.href
);
log.log(lastReadingPosition.href);
log.log(linkHref);
lastReadingPosition.href = linkHref;

this.history.push(lastReadingPosition);
this.historyCurrentIndex = this.history.length - 1;
}
Expand Down
40 changes: 31 additions & 9 deletions src/modules/search/Popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,31 @@ export class Popup {
event.preventDefault();
event.stopPropagation();

await fetch(absolute, this.navigator.requestConfig)
.then((r) => r.text())
.then(async (data) => {
if (this.navigator.api?.getContent) {
await this.navigator.api?.getContent(href).then((content) => {
const parser = new DOMParser();
const doc = parser.parseFromString(data, "text/html");
const doc = parser.parseFromString(content, "text/html");
const element = doc.querySelector("#" + id);
if (element) {
event.preventDefault();
event.stopPropagation();
this.showPopup(element, event);
}
});
} else {
await fetch(absolute, this.navigator.requestConfig)
.then((r) => r.text())
.then(async (data) => {
const parser = new DOMParser();
const doc = parser.parseFromString(data, "text/html");
const element = doc.querySelector("#" + id);
if (element) {
event.preventDefault();
event.stopPropagation();
this.showPopup(element, event);
}
});
}
}
}
}
Expand Down Expand Up @@ -113,16 +126,25 @@ export class Popup {
const d2content = document.createElement("div");
d2content.className = "d2-popover-content";
d2wrapper.appendChild(d2content);

await fetch(absolute, this.navigator.requestConfig)
.then((r) => r.text())
.then(async (data) => {
d2content.innerHTML = data;
if (this.navigator.api?.getContent) {
await this.navigator.api?.getContent(href).then((content) => {
d2content.innerHTML = content;
let doc = this.navigator.iframes[0].contentDocument;
if (doc) {
doc.body.appendChild(d2popover);
}
});
} else {
await fetch(absolute, this.navigator.requestConfig)
.then((r) => r.text())
.then(async (data) => {
d2content.innerHTML = data;
let doc = this.navigator.iframes[0].contentDocument;
if (doc) {
doc.body.appendChild(d2popover);
}
});
}

let win = this.navigator.iframes[0].contentWindow;
if (!win) {
Expand Down

0 comments on commit 88c6a4e

Please sign in to comment.