Browse Source

update epub.js and localforage

Andrew Dolgov 2 years ago
parent
commit
93cebbf740
2 changed files with 30 additions and 6 deletions
  1. 26 2
      lib/epub.js
  2. 4 4
      lib/localforage.min.js

+ 26 - 2
lib/epub.js

@@ -3445,6 +3445,7 @@ EPUBJS.Book.prototype.displayChapter = function(chap, end, deferred){
 		chapter.registerHook("beforeChapterRender", [
 			EPUBJS.replace.head,
 			EPUBJS.replace.resources,
+			EPUBJS.replace.posters,
 			EPUBJS.replace.svg
 		], true);
 
@@ -3760,6 +3761,7 @@ EPUBJS.Book.prototype.fromStorage = function(stored) {
 	var hooks = [
 		EPUBJS.replace.head,
 		EPUBJS.replace.resources,
+		EPUBJS.replace.posters,
 		EPUBJS.replace.svg
 	];
 
@@ -4022,7 +4024,7 @@ RSVP.on('error', function(event) {
 	console.error(event);
 });
 
-// RSVP.configure('instrument', true); //-- true | will logging out all RSVP rejections
+RSVP.configure('instrument', true); //-- true | will logging out all RSVP rejections
 // RSVP.on('created', listener);
 // RSVP.on('chained', listener);
 // RSVP.on('fulfilled', listener);
@@ -8410,6 +8412,11 @@ EPUBJS.replace.hrefs = function(callback, renderer){
 				uri,
 				url;
 
+		if(href.indexOf("mailto:") === 0){
+			done();
+			return;
+		}
+
 		if(isRelative != -1){
 
 			link.setAttribute("target", "_blank");
@@ -8421,6 +8428,10 @@ EPUBJS.replace.hrefs = function(callback, renderer){
 			uri = EPUBJS.core.uri(url);
 			directory = uri.directory;
 
+			if (href.indexOf("#") === 0) {
+				href = uri.filename + href;
+			}
+
 			if(directory) {
 				// We must ensure that the file:// protocol is preserved for
 				// local file links, as in certain contexts (such as under
@@ -8436,6 +8447,7 @@ EPUBJS.replace.hrefs = function(callback, renderer){
 			}
 
 			link.onclick = function(){
+                                book.trigger("book:linkClicked", href);
 				book.goto(relative);
 				return false;
 			};
@@ -8463,6 +8475,12 @@ EPUBJS.replace.resources = function(callback, renderer){
 
 };
 
+EPUBJS.replace.posters = function(callback, renderer){
+
+	renderer.replaceWithStored("[poster]", "poster", EPUBJS.replace.srcs, callback);
+
+};
+
 EPUBJS.replace.svg = function(callback, renderer) {
 
 	renderer.replaceWithStored("svg image", "xlink:href", function(_store, full, done){
@@ -8473,7 +8491,13 @@ EPUBJS.replace.svg = function(callback, renderer) {
 
 EPUBJS.replace.srcs = function(_store, full, done){
 
-	_store.getUrl(full).then(done);
+	var isRelative = (full.search("://") === -1);
+
+	if (isRelative) {
+		_store.getUrl(full).then(done);
+	} else {
+		done();
+	}
 
 };
 

File diff suppressed because it is too large
+ 4 - 4
lib/localforage.min.js