//______________________________________________________________________________
GnuBook.prototype.updatePageNumBox2UP = function() {
if (null != this.getPageNum(this.twoPage.currentIndexL)) {
- $("#GBpagenum").val(this.getPageNum(this.twoPage.currentIndexL));
+ $("#GBpagenum").val(this.getPageNum(this.currentIndex()));
} else {
$("#GBpagenum").val('');
}
// Returns the currently active index.
GnuBook.prototype.currentIndex = function() {
// $$$ we should be cleaner with our idea of which index is active in 1up/2up
- if (this.mode == this.constMode1up || this.mode == this.constMode2up) {
- return this.firstIndex;
+ if (this.mode == this.constMode1up) {
+ return this.firstIndex; // $$$ TODO page in center of view would be better
+ } else if (this.mode == this.constMode2up) {
+ // Only allow indices that are actually present in book
+ return GnuBook.util.clamp(this.firstIndex, 0, this.numLeafs - 1);
} else {
throw 'currentIndex called for unimplemented mode ' + this.mode;
}
var params = {};
- var index = GnuBook.util.clamp(this.currentIndex(), 0, this.numLeafs - 1);
-
+ var index = this.currentIndex();
var pageNum = this.getPageNum(index);
if ((pageNum === 0) || pageNum) {
params.page = pageNum;