this.padding = 10;
this.mode = 1; //1, 2, 3
this.ui = 'full'; // UI mode
- this.thumbScale = 10; // thumbnail default
- this.thumbRowBuffer = 4; // number of rows to pre-cache out a view
- this.displayedIndices = [];
+ // thumbnail mode
+ this.thumbWidth = 100;
+ this.thumbRowBuffer = 3; // number of rows to pre-cache out a view
this.displayedRows=[];
+
+ this.displayedIndices = [];
//this.indicesToDisplay = [];
this.imgs = {};
this.prefetchedImgs = {}; //an object with numeric keys cooresponding to page index
var leafMap = [];
for (i=0; i<this.numLeafs; i++) {
- leafWidth = parseInt(this.getPageWidth(i)/this.reduce, 10);
+ leafWidth = this.thumbWidth;
if (rightPos + (leafWidth + this.padding) > viewWidth){
currentRow++;
rightPos = 0;
leafMap[currentRow].leafs[leafIndex].num = i;
leafMap[currentRow].leafs[leafIndex].left = rightPos;
- leafHeight = parseInt(this.getPageHeight(leafMap[currentRow].leafs[leafIndex].num)/this.reduce, 10);
+ leafHeight = parseInt((this.getPageHeight(leafMap[currentRow].leafs[leafIndex].num)*this.thumbWidth)/this.getPageWidth(leafMap[currentRow].leafs[leafIndex].num), 10);
if (leafHeight > leafMap[currentRow].height) { leafMap[currentRow].height = leafHeight; }
if (leafIndex===0) { bottomPos += this.padding + leafMap[currentRow].height; }
rightPos += leafWidth + this.padding;
leafTop = leafBottom;
}
+ // create a buffer of preloaded rows before and after the visible rows
var firstRow = rowsToDisplay[0];
var lastRow = rowsToDisplay[rowsToDisplay.length-1];
for (i=1; i<this.thumbRowBuffer+1; i++) {
- if (firstRow-i >= 0) { rowsToDisplay.unshift(firstRow-i); }
if (lastRow+i < leafMap.length) { rowsToDisplay.push(lastRow+i); }
-}
+ }
+ for (i=1; i<this.thumbRowBuffer+1; i++) {
+ if (firstRow-i >= 0) { rowsToDisplay.push(firstRow-i); }
+ }
// Update hash, but only if we're currently displaying a leaf
// Hack that fixes #365790
index = j;
leaf = leafMap[row].leafs[j].num;
- leafWidth = parseInt(this.getPageWidth(leaf)/this.reduce, 10);
- leafHeight = parseInt(this.getPageHeight(leaf)/this.reduce, 10);
+ leafWidth = this.thumbWidth;
+ leafHeight = parseInt((this.getPageHeight(leaf)*this.thumbWidth)/this.getPageWidth(leaf), 10);
leafTop = leafMap[row].top;
left = leafMap[row].leafs[index].left + pageViewBuffer;
if ('rl' == this.pageProgression){
var leafIndex = 0;
for (i=0; i<(index+1); i++) {
- leafWidth = parseInt(this.getPageWidth(i)/this.reduce, 10);
+ leafWidth = this.thumbWidth;
if (rightPos + (leafWidth + this.padding) > viewWidth){
rightPos = 0;
rowHeight = 0;
leafIndex = 0;
}
- leafHeight = parseInt(this.getPageHeight(i)/this.reduce, 10);
+ leafHeight = parseInt((this.getPageHeight(leaf)*this.thumbWidth)/this.getPageWidth(leaf), 10);
if(leafHeight > rowHeight) { rowHeight = leafHeight; }
if (leafIndex==0) { leafTop = bottomPos; }
if (leafIndex==0) { bottomPos += this.padding + rowHeight; }
// var startLeaf = this.displayedIndices[0];
var startLeaf = this.currentIndex();
- this.reduce = this.thumbScale;
-
+ this.reduce = this.getPageWidth(0)/this.thumbWidth;
+
$('#BRcontainer').empty();
$('#BRcontainer').css({
overflowY: 'scroll',
term = term.replace(/\//g, ' '); // strip slashes
this.searchTerm = term;
$('#BookReaderSearchScript').remove();
- var script = document.createElement("script");
- script.setAttribute('id', 'BookReaderSearchScript');
- script.setAttribute("type", "text/javascript");
- script.setAttribute("src", 'http://'+this.server+'/BookReader/flipbook_search_br.php?url='+escape(this.bookPath + '_djvu.xml')+'&term='+term+'&format=XML&callback=br.BRSearchCallback');
- document.getElementsByTagName('head')[0].appendChild(script);
- $('#BookReaderSearchBox').val(term);
- $('#BookReaderSearchResults').html('Searching...');
+ var script = document.createElement("script");
+ script.setAttribute('id', 'BookReaderSearchScript');
+ script.setAttribute("type", "text/javascript");
+ script.setAttribute("src", 'http://'+this.server+'/BookReader/flipbook_search_br.php?url='+escape(this.bookPath + '_djvu.xml')+'&term='+term+'&format=XML&callback=br.BRSearchCallback');
+ document.getElementsByTagName('head')[0].appendChild(script);
+ $('#BookReaderSearchBox').val(term);
+ $('#BookReaderSearchResults').html('Searching...');
}
// BRSearchCallback()
$('#BookReaderSearchResults').append('</ul>');
// $$$ update again for case of loading search URL in new browser window (search box may not have been ready yet)
- $('#BookReaderSearchBox').val(this.searchTerm);
+ $('#BookReaderSearchBox').val(this.searchTerm);
this.updateSearchHilites();
}
return this.imagesBaseURL + "/transparent.png";
}
+ if ('undefined' == typeof(reduce)) {
+ // reduce not passed in
+ var ratio = this.getPageHeight(index) / this.twoPage.height;
+ var scale;
+ // $$$ we make an assumption here that the scales are available pow2 (like kakadu)
+ if (ratio < 2) {
+ scale = 1;
+ } else if (ratio < 4) {
+ scale = 2;
+ } else if (ratio < 8) {
+ scale = 4;
+ } else if (ratio < 16) {
+ scale = 8;
+ } else if (ratio < 32) {
+ scale = 16;
+ } else {
+ scale = 32;
+ }
+ reduce = scale;
+ }
+
return this.getPageURI(index, reduce, rotate);
}