Skip to content

Commit

Permalink
added last navigated href
Browse files Browse the repository at this point in the history
  • Loading branch information
aferditamuriqi committed Apr 2, 2020
1 parent 0824299 commit d057c58
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 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": "1.0.7",
"version": "1.0.8",
"description": "A viewer application for EPUB files.",
"repository": "https://github.com/d-i-t-a/R2D2BC",
"main": "src/index.js",
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export function currentResource() {
if (IS_DEV) { console.log("currentResource") }
return R2Navigator.currentResource()
}
export function currentTocHref() {
if (IS_DEV) { console.log("currentTocHref") }
return R2Navigator.currentTocHref()
}
export function totalResources() {
if (IS_DEV) { console.log("totalResources") }
return R2Navigator.totalResources()
Expand Down Expand Up @@ -262,6 +266,9 @@ exports.annotations = function () {
exports.currentResource = function() {
return currentResource()
}
exports.currentTocHref = function() {
return currentTocHref()
}
exports.totalResources = function() {
return totalResources()
}
3 changes: 3 additions & 0 deletions src/modules/TTSModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export default class TTSModule implements ReaderModule {
initialize() {
this.annotationModule.highlighter.ttsDelegate = this
}
cancel() {
this.synth.cancel()
}

speak(selectionInfo: ISelectionInfo | undefined ): any {
console.log(selectionInfo.cleanText)
Expand Down
3 changes: 3 additions & 0 deletions src/modules/highlight/TextHighlighter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ export default class TextHighlighter {
toolbox.style.display = "none";
var backdrop = document.getElementById("toolbox-backdrop");
backdrop.style.display = "none";
self.ttsDelegate.cancel()
},

/**
Expand Down Expand Up @@ -1321,6 +1322,8 @@ export default class TextHighlighter {
backdropButton.removeEventListener("click", backdropEvent);
backdropButton.removeEventListener("mousedown", backdropEvent);
backdropButton.removeEventListener("mouseup", backdropEvent);


}

backdropButton.addEventListener("click", backdropEvent);
Expand Down
5 changes: 5 additions & 0 deletions src/navigator/IFrameNavigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class IFrameNavigator implements Navigator {
mSidenav: any;

currentChapterLink: Link = {};
currentTOCRawLink: string;
private nextChapterLink: Link;
private previousChapterLink: Link;
private settings: UserSettings;
Expand Down Expand Up @@ -999,6 +1000,9 @@ export default class IFrameNavigator implements Navigator {
totalResources(): number {
return this.publication.readingOrder.length
}
currentTocHref(): string {
return this.currentTOCRawLink
}
currentResource(): number {
let currentLocation = this.currentChapterLink.href
return this.publication.getSpineIndex(currentLocation)
Expand Down Expand Up @@ -1320,6 +1324,7 @@ export default class IFrameNavigator implements Navigator {
}
}
this.newPosition = locator;
this.currentTOCRawLink = locator.href

if (locator.href.indexOf("#") !== -1) {
const newResource = locator.href.slice(0, locator.href.indexOf("#"))
Expand Down
1 change: 1 addition & 0 deletions viewer/index_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

<button onclick="javascript:alert(D2Reader.totalResources())">totalResources</button><br>
<button onclick="javascript:alert(D2Reader.currentResource())">currentResource</button><br>
<button onclick="javascript:alert(D2Reader.currentTocHref())">currentTocHref</button><br>

<button onclick="javascript:D2Reader.resetUserSettings()">reset user setting</button><br>
<button onclick="javascript:D2Reader.publisher(true)">publisher default</button><br>
Expand Down

0 comments on commit d057c58

Please sign in to comment.