- var i;
- var leafWidth;
- var leafHeight;
- var rightPos = 0;
- var bottomPos = 0;
- var maxRight = 0;
- var currentRow = 0;
- var leafIndex = 0;
- var leafMap = [];
-
- for (i=0; i<this.numLeafs; i++) {
- leafWidth = parseInt(this.getPageWidth(i)/this.reduce, 10);
- if (rightPos + (leafWidth + this.padding) > viewWidth){
- currentRow++;
- rightPos = 0;
- leafIndex = 0;
- }
-
- if (leafMap[currentRow]===undefined) { leafMap[currentRow] = {}; }
- if (leafMap[currentRow].leafs===undefined) {
- leafMap[currentRow].leafs = [];
- leafMap[currentRow].height = 0;
- leafMap[currentRow].top = 0;
- }
- leafMap[currentRow].leafs[leafIndex] = {};
- leafMap[currentRow].leafs[leafIndex].num = i;
- leafMap[currentRow].leafs[leafIndex].left = rightPos;
-
- leafHeight = parseInt(this.getPageHeight(leafMap[currentRow].leafs[leafIndex].num)/this.reduce, 10);
- if (leafHeight > leafMap[currentRow].height) { leafMap[currentRow].height = leafHeight; }
- if (leafIndex===0) { bottomPos += this.padding + leafMap[currentRow].height; }
- rightPos += leafWidth + this.padding;
- if (rightPos > maxRight) { maxRight = rightPos; }
- leafIndex++;
- }
-
- // reset the bottom position based on thumbnails
- $('#GBpageview').height(bottomPos);
-
- var pageViewBuffer = Math.floor(($('#GBcontainer').attr('scrollWidth') - maxRight) / 2) - 14;
- var scrollTop = $('#GBcontainer').attr('scrollTop');
+ var i;
+ var leafWidth;
+ var leafHeight;
+ var rightPos = 0;
+ var bottomPos = 0;
+ var maxRight = 0;
+ var currentRow = 0;
+ var leafIndex = 0;
+ var leafMap = [];
+
+ for (i=0; i<this.numLeafs; i++) {
+ leafWidth = parseInt(this.getPageWidth(i)/this.reduce, 10);
+ if (rightPos + (leafWidth + this.padding) > viewWidth){
+ currentRow++;
+ rightPos = 0;
+ leafIndex = 0;
+ }
+
+ if (leafMap[currentRow]===undefined) { leafMap[currentRow] = {}; }
+ if (leafMap[currentRow].leafs===undefined) {
+ leafMap[currentRow].leafs = [];
+ leafMap[currentRow].height = 0;
+ leafMap[currentRow].top = 0;
+ }
+ leafMap[currentRow].leafs[leafIndex] = {};
+ leafMap[currentRow].leafs[leafIndex].num = i;
+ leafMap[currentRow].leafs[leafIndex].left = rightPos;
+
+ leafHeight = parseInt(this.getPageHeight(leafMap[currentRow].leafs[leafIndex].num)/this.reduce, 10);
+ if (leafHeight > leafMap[currentRow].height) { leafMap[currentRow].height = leafHeight; }
+ if (leafIndex===0) { bottomPos += this.padding + leafMap[currentRow].height; }
+ rightPos += leafWidth + this.padding;
+ if (rightPos > maxRight) { maxRight = rightPos; }
+ leafIndex++;
+ }
+
+ // reset the bottom position based on thumbnails
+ $('#GBpageview').height(bottomPos);
+
+ var pageViewBuffer = Math.floor(($('#GBcontainer').attr('scrollWidth') - maxRight) / 2) - 14;
+ var scrollTop = $('#GBcontainer').attr('scrollTop');
- if (-1 == jQuery.inArray(rowsToDisplay[i], this.displayedRows)) {
- row = rowsToDisplay[i];
-
-
- for (j=0; j<leafMap[row].leafs.length; j++) {
- index = leafMap[row].leafs[j].num;
-
- leafWidth = parseInt(this.getPageWidth(index)/this.reduce, 10);
- leafHeight = parseInt(this.getPageHeight(index)/this.reduce, 10);
- leafTop = leafMap[row].top;
- left = leafMap[row].leafs[j].left + pageViewBuffer;
-
- div = document.createElement("div");
- div.id = 'pagediv'+index;
- div.style.position = "absolute";
- div.className = "GBpagedivthumb";
-
- left += this.padding;
- $(div).css('top', leafTop + 'px');
- $(div).css('left', left+'px');
- $(div).css('width', leafWidth+'px');
- $(div).css('height', leafHeight+'px');
- //$(div).text('loading...');
-
- // link to page in single page mode
- link = document.createElement("a");
- link.href = '#page/' + (this.getPageNum(index)) +'/mode/1up' ;
- $(div).append(link);
-
- $('#GBpageview').append(div);
-
- img = document.createElement("img");
- img.src = this.getPageURI(index);
- $(img).css('width', leafWidth+'px');
- $(img).css('height', leafHeight+'px');
- img.style.border = "0";
- $(link).append(img);
- //console.log('displaying thumbnail: ' + leafMap[j]);
- }
- }
- }
-
-
- // remove previous highlights
- if ($('.GBpagedivthumb_highlight').length>0) {
- div = $('.GBpagedivthumb_highlight')
- div.attr({className: 'GBpagedivthumb' });
- }
- // highlight current page
- $('#pagediv'+this.currentIndex()).attr({className: 'GBpagedivthumb_highlight' });
-
- var k;
- for (i=0; i<this.displayedRows.length; i++) {
- if (-1 == jQuery.inArray(this.displayedRows[i], rowsToDisplay)) {
- row = this.displayedRows[i];
- for (k=0; k<leafMap[row].leafs.length; k++) {
- index = leafMap[row].leafs[k].num;
- //console.log('Removing leaf ' + index);
- $('#pagediv'+index).remove();
- }
- } else {
-
- //console.log('NOT Removing leaf ' + this.displayedIndices[i]);
- }
- }
+ if (-1 == jQuery.inArray(rowsToDisplay[i], this.displayedRows)) {
+ row = rowsToDisplay[i];
+
+ for (j=0; j<leafMap[row].leafs.length; j++) {
+ index = leafMap[row].leafs[j].num;
+
+ leafWidth = parseInt(this.getPageWidth(index)/this.reduce, 10);
+ leafHeight = parseInt(this.getPageHeight(index)/this.reduce, 10);
+ leafTop = leafMap[row].top;
+ left = leafMap[row].leafs[j].left + pageViewBuffer;
+
+ div = document.createElement("div");
+ div.id = 'pagediv'+index;
+ div.style.position = "absolute";
+ div.className = "GBpagedivthumb";
+
+ left += this.padding;
+ $(div).css('top', leafTop + 'px');
+ $(div).css('left', left+'px');
+ $(div).css('width', leafWidth+'px');
+ $(div).css('height', leafHeight+'px');
+ //$(div).text('loading...');
+
+ // link to page in single page mode
+ link = document.createElement("a");
+ link.href = '#page/' + (this.getPageNum(index)) +'/mode/1up' ;
+ $(div).append(link);
+
+ $('#GBpageview').append(div);
+
+ img = document.createElement("img");
+ img.src = this.getPageURI(index);
+ $(img).css('width', leafWidth+'px');
+ $(img).css('height', leafHeight+'px');
+ img.style.border = "0";
+ $(link).append(img);
+ //console.log('displaying thumbnail: ' + leafMap[j]);
+ }
+ }
+ }
+
+ // remove previous highlights
+ if ($('.GBpagedivthumb_highlight').length>0) {
+ div = $('.GBpagedivthumb_highlight')
+ div.attr({className: 'GBpagedivthumb' });
+ }
+ // highlight current page
+ $('#pagediv'+this.currentIndex()).attr({className: 'GBpagedivthumb_highlight' });
+
+ var k;
+ for (i=0; i<this.displayedRows.length; i++) {
+ if (-1 == jQuery.inArray(this.displayedRows[i], rowsToDisplay)) {
+ row = this.displayedRows[i];
+ for (k=0; k<leafMap[row].leafs.length; k++) {
+ index = leafMap[row].leafs[k].num;
+ //console.log('Removing leaf ' + index);
+ $('#pagediv'+index).remove();
+ }
+ } else {
+
+ //console.log('NOT Removing leaf ' + this.displayedIndices[i]);
+ }
+ }
- var viewWidth = $('#GBcontainer').attr('scrollWidth') - 20; // width minus buffer
- var i;
- var leafWidth = 0;
- var leafHeight = 0;
- var rightPos = 0;
- var bottomPos = 0;
- var rowHeight = 0;
- var leafTop = 0;
- var leafIndex = 0;
-
- for (i=0; i<(index+1); i++) {
- leafWidth = parseInt(this.getPageWidth(i)/this.reduce, 10);
- if (rightPos + (leafWidth + this.padding) > viewWidth){
- rightPos = 0;
- rowHeight = 0;
- leafIndex = 0;
- }
- leafHeight = parseInt(this.getPageHeight(i)/this.reduce, 10);
- if(leafHeight > rowHeight) { rowHeight = leafHeight; }
- if (leafIndex==0) { leafTop = bottomPos; }
- if (leafIndex==0) { bottomPos += this.padding + rowHeight; }
- rightPos += leafWidth + this.padding;
- leafIndex++;
- }
- this.firstIndex=index;
- if ($('#GBcontainer').attr('scrollTop') == leafTop) {
- this.loadLeafs();
- } else {
- $('#GBcontainer').animate({scrollTop: leafTop },'fast');
- }
- } else {
+ var viewWidth = $('#GBcontainer').attr('scrollWidth') - 20; // width minus buffer
+ var i;
+ var leafWidth = 0;
+ var leafHeight = 0;
+ var rightPos = 0;
+ var bottomPos = 0;
+ var rowHeight = 0;
+ var leafTop = 0;
+ var leafIndex = 0;
+
+ for (i=0; i<(index+1); i++) {
+ leafWidth = parseInt(this.getPageWidth(i)/this.reduce, 10);
+ if (rightPos + (leafWidth + this.padding) > viewWidth){
+ rightPos = 0;
+ rowHeight = 0;
+ leafIndex = 0;
+ }
+ leafHeight = parseInt(this.getPageHeight(i)/this.reduce, 10);
+ if(leafHeight > rowHeight) { rowHeight = leafHeight; }
+ if (leafIndex==0) { leafTop = bottomPos; }
+ if (leafIndex==0) { bottomPos += this.padding + rowHeight; }
+ rightPos += leafWidth + this.padding;
+ leafIndex++;
+ }
+ this.firstIndex=index;
+ if ($('#GBcontainer').attr('scrollTop') == leafTop) {
+ this.loadLeafs();
+ } else {
+ $('#GBcontainer').animate({scrollTop: leafTop },'fast');
+ }
+ } else {