1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-05 15:32:55 +02:00

fix navigation to final chapter

This commit is contained in:
Fred Chasen 2014-10-07 21:58:41 -04:00
parent 8a3f72853d
commit f6c2b04836
15 changed files with 47 additions and 49 deletions

File diff suppressed because one or more lines are too long

21
reader/js/epub.min.js vendored
View file

@ -2185,7 +2185,7 @@ global.RSVP = requireModule('rsvp');
'use strict';
var EPUBJS = EPUBJS || {};
EPUBJS.VERSION = "0.2.1";
EPUBJS.VERSION = "0.2.2";
EPUBJS.plugins = EPUBJS.plugins || {};
@ -3082,10 +3082,11 @@ EPUBJS.Book.prototype.nextChapter = function() {
var next;
if (this.spinePos < this.spine.length - 1) {
next = this.spinePos + 1;
// Skip non linear chapters
while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') {
next++;
}
if (next < this.spine.length - 1) {
if (next < this.spine.length) {
return this.displayChapter(next);
} else {
this.trigger("book:atEnd");
@ -5566,15 +5567,14 @@ EPUBJS.Parser.prototype.toc = function(tocXml, spineIndexByURL, bookSpine){
function getTOC(parent){
var list = [],
nodes = parent.querySelectorAll("navPoint"),
items = Array.prototype.slice.call(nodes).reverse(),
length = items.length,
iter = length,
node;
snapshot = tocXml.evaluate("*[local-name()='navPoint']", parent, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null),
length = snapshot.snapshotLength;
if(length === 0) return [];
items.forEach(function(item){
for ( var i=length-1 ; i >= 0; i-- ) {
var item = snapshot.snapshotItem(i);
var id = item.getAttribute('id') || false,
content = item.querySelector("content"),
src = content.getAttribute('src'),
@ -5596,8 +5596,7 @@ EPUBJS.Parser.prototype.toc = function(tocXml, spineIndexByURL, bookSpine){
id = 'epubjs-autogen-toc-id-' + (idCounter++);
}
}
list.unshift({
"id": id,
"href": src,
@ -5608,7 +5607,7 @@ EPUBJS.Parser.prototype.toc = function(tocXml, spineIndexByURL, bookSpine){
"cfi" : cfi
});
});
}
return list;
}

File diff suppressed because one or more lines are too long