mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Update annotation remove and always add default theme
This commit is contained in:
parent
837775b2cf
commit
6401485f48
6 changed files with 41 additions and 8 deletions
|
@ -131,6 +131,7 @@
|
|||
var text;
|
||||
var li = document.createElement('li');
|
||||
var a = document.createElement('a');
|
||||
var remove = document.createElement('a');
|
||||
var textNode;
|
||||
|
||||
if (range) {
|
||||
|
@ -143,8 +144,16 @@
|
|||
rendition.display(cfiRange);
|
||||
};
|
||||
|
||||
remove.textContent = "remove";
|
||||
remove.href = "#" + cfiRange;
|
||||
remove.onclick = function () {
|
||||
rendition.annotations.remove(cfiRange);
|
||||
return false;
|
||||
};
|
||||
|
||||
li.appendChild(a);
|
||||
li.appendChild(textNode);
|
||||
li.appendChild(remove);
|
||||
highlights.appendChild(li);
|
||||
}
|
||||
|
||||
|
|
|
@ -218,8 +218,11 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
var params = URLSearchParams && new URLSearchParams(document.location.search.substring(1));
|
||||
var url = params && params.get("url") && decodeURIComponent(params.get("url"));
|
||||
|
||||
// Load the opf
|
||||
var book = ePub(window.location.protocol + "//s3.amazonaws.com/epubjs/books/alice/OPS/package.opf");
|
||||
var book = ePub(url || window.location.protocol + "//s3.amazonaws.com/epubjs/books/alice/OPS/package.opf");
|
||||
var rendition = book.renderTo("viewer", {
|
||||
ignoreClass: "annotator-hl",
|
||||
width: "100%",
|
||||
|
@ -274,6 +277,23 @@
|
|||
// window.location.hash = "#/"+section.href
|
||||
});
|
||||
|
||||
var keyListener = function(e){
|
||||
|
||||
// Left Key
|
||||
if ((e.keyCode || e.which) == 37) {
|
||||
rendition.prev();
|
||||
}
|
||||
|
||||
// Right Key
|
||||
if ((e.keyCode || e.which) == 39) {
|
||||
rendition.next();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
rendition.on("keyup", keyListener);
|
||||
document.addEventListener("keyup", keyListener, false);
|
||||
|
||||
book.loaded.navigation.then(function(toc){
|
||||
var $nav = document.getElementById("toc"),
|
||||
docfrag = document.createDocumentFragment();
|
||||
|
|
|
@ -188,7 +188,11 @@
|
|||
|
||||
<script>
|
||||
// Load the opf
|
||||
var book = ePub(window.location.protocol + "//s3.amazonaws.com/epubjs/books/alice/OPS/package.opf");
|
||||
var params = URLSearchParams && new URLSearchParams(document.location.search.substring(1));
|
||||
var url = params && params.get("url") && decodeURIComponent(params.get("url"));
|
||||
|
||||
// Load the opf
|
||||
var book = ePub(url || window.location.protocol + "//s3.amazonaws.com/epubjs/books/alice/OPS/package.opf");
|
||||
var rendition = book.renderTo("viewer", {
|
||||
flow: "scrolled-doc",
|
||||
ignoreClass: "annotator-hl"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "epubjs",
|
||||
"version": "0.3.42",
|
||||
"version": "0.3.43",
|
||||
"description": "Parse and Render Epubs",
|
||||
"main": "lib/index.js",
|
||||
"module": "src/index.js",
|
||||
|
|
|
@ -69,9 +69,9 @@ class Annotations {
|
|||
return annotation;
|
||||
}
|
||||
|
||||
remove (cfiRange) {
|
||||
let hash = decodeURI(cfiRange);
|
||||
let result;
|
||||
remove (cfiRange, type) {
|
||||
let hash = encodeURI(cfiRange);
|
||||
|
||||
if (hash in this._annotations) {
|
||||
let annotation = this._annotations[hash];
|
||||
|
||||
|
@ -84,7 +84,6 @@ class Annotations {
|
|||
|
||||
delete this._annotations[hash];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
highlight (cfiRange, data, cb) {
|
||||
|
@ -177,6 +176,7 @@ class Annotation {
|
|||
|
||||
detach (contents) {
|
||||
let {cfiRange, type} = this;
|
||||
let result;
|
||||
|
||||
if (contents) {
|
||||
if (type === "highlight") {
|
||||
|
|
|
@ -103,7 +103,7 @@ class Themes {
|
|||
var theme;
|
||||
|
||||
for (var name in themes) {
|
||||
if (themes.hasOwnProperty(name) && name === this._current) {
|
||||
if (themes.hasOwnProperty(name) && (name === this._current || name === "default")) {
|
||||
theme = themes[name];
|
||||
if(theme.rules || (theme.url && links.indexOf(theme.url) === -1)) {
|
||||
this.add(name, contents);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue