this.pageScale = this.reduce; // preserve current reduce
// Find start index and mode if set in location hash
- var params = this.paramsFromFragment(window.location.hash);
+ var params = {};
+ if (window.location.hash) {
+ // params explicitly set in URL
+ params = this.paramsFromFragment(window.location.hash);
+ } else {
+ // params not explicitly set, use defaults if we have them
+ if ('defaults' in this) {
+ params = this.paramsFromFragment(this.defaults);
+ }
+ }
// Sanitize/process parameters
// Attempts to jump to page. Returns true if page could be found, false otherwise.
BookReader.prototype.jumpToPage = function(pageNum) {
- var pageIndex = this.getPageIndex(pageNum);
+ var pageIndex;
+
+ // Check for special "leaf"
+ var re = new RegExp('^leaf(\\d+)');
+ leafMatch = re.exec(pageNum);
+ if (leafMatch) {
+ console.log(leafMatch[1]);
+ pageIndex = this.leafNumToIndex(parseInt(leafMatch[1],10));
+ if (pageIndex === null) {
+ pageIndex = undefined; // to match return type of getPageIndex
+ }
+
+ } else {
+ pageIndex = this.getPageIndex(pageNum);
+ }
if ('undefined' != typeof(pageIndex)) {
var leafTop = 0;
this.jumpToPage(params.page);
}
}
-
+
// $$$ process /region
// $$$ process /highlight
}