1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

next and prev chapter respect linear=no per #110

This commit is contained in:
Fred Chasen 2014-04-01 16:18:06 -07:00
parent 4ed8272d41
commit ae7c84aa8a
9 changed files with 102 additions and 34 deletions

View file

@ -2561,22 +2561,39 @@ EPUBJS.Book.prototype.prevPage = function() {
};
EPUBJS.Book.prototype.nextChapter = function() {
if(this.spinePos < this.spine.length - 1){
this.spinePos += 1;
if (this.spinePos < this.spine.length - 1) {
var next = this.spinePos + 1;
while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') {
next++;
}
if (next < this.spine.length - 1) {
this.spinePos = next;
return this.displayChapter(this.spinePos);
} else {
this.trigger("book:atEnd");
}
} else {
this.trigger("book:atEnd");
}
};
EPUBJS.Book.prototype.prevChapter = function() {
if(this.spinePos > 0){
this.spinePos -= 1;
if (this.spinePos > 0) {
var prev = this.spinePos - 1;
while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') {
prev--;
}
if (prev >= 0) {
this.spinePos = prev;
return this.displayChapter(this.spinePos, true);
} else {
this.trigger("book:atStart");
}
} else {
this.trigger("book:atStart");
}
};
EPUBJS.Book.prototype.getCurrentLocationCfi = function() {

File diff suppressed because one or more lines are too long

4
build/epub.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2560,22 +2560,39 @@ EPUBJS.Book.prototype.prevPage = function() {
};
EPUBJS.Book.prototype.nextChapter = function() {
if(this.spinePos < this.spine.length - 1){
this.spinePos += 1;
if (this.spinePos < this.spine.length - 1) {
var next = this.spinePos + 1;
while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') {
next++;
}
if (next < this.spine.length - 1) {
this.spinePos = next;
return this.displayChapter(this.spinePos);
} else {
this.trigger("book:atEnd");
}
} else {
this.trigger("book:atEnd");
}
};
EPUBJS.Book.prototype.prevChapter = function() {
if(this.spinePos > 0){
this.spinePos -= 1;
if (this.spinePos > 0) {
var prev = this.spinePos - 1;
while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') {
prev--;
}
if (prev >= 0) {
this.spinePos = prev;
return this.displayChapter(this.spinePos, true);
} else {
this.trigger("book:atStart");
}
} else {
this.trigger("book:atStart");
}
};
EPUBJS.Book.prototype.getCurrentLocationCfi = function() {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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

@ -2561,22 +2561,39 @@ EPUBJS.Book.prototype.prevPage = function() {
};
EPUBJS.Book.prototype.nextChapter = function() {
if(this.spinePos < this.spine.length - 1){
this.spinePos += 1;
if (this.spinePos < this.spine.length - 1) {
var next = this.spinePos + 1;
while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') {
next++;
}
if (next < this.spine.length - 1) {
this.spinePos = next;
return this.displayChapter(this.spinePos);
} else {
this.trigger("book:atEnd");
}
} else {
this.trigger("book:atEnd");
}
};
EPUBJS.Book.prototype.prevChapter = function() {
if(this.spinePos > 0){
this.spinePos -= 1;
if (this.spinePos > 0) {
var prev = this.spinePos - 1;
while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') {
prev--;
}
if (prev >= 0) {
this.spinePos = prev;
return this.displayChapter(this.spinePos, true);
} else {
this.trigger("book:atStart");
}
} else {
this.trigger("book:atStart");
}
};
EPUBJS.Book.prototype.getCurrentLocationCfi = function() {

View file

@ -785,22 +785,39 @@ EPUBJS.Book.prototype.prevPage = function() {
};
EPUBJS.Book.prototype.nextChapter = function() {
if(this.spinePos < this.spine.length - 1){
this.spinePos += 1;
if (this.spinePos < this.spine.length - 1) {
var next = this.spinePos + 1;
while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') {
next++;
}
if (next < this.spine.length - 1) {
this.spinePos = next;
return this.displayChapter(this.spinePos);
} else {
this.trigger("book:atEnd");
}
} else {
this.trigger("book:atEnd");
}
};
EPUBJS.Book.prototype.prevChapter = function() {
if(this.spinePos > 0){
this.spinePos -= 1;
if (this.spinePos > 0) {
var prev = this.spinePos - 1;
while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') {
prev--;
}
if (prev >= 0) {
this.spinePos = prev;
return this.displayChapter(this.spinePos, true);
} else {
this.trigger("book:atStart");
}
} else {
this.trigger("book:atStart");
}
};
EPUBJS.Book.prototype.getCurrentLocationCfi = function() {