- if ((0 != firstIndexToDraw) && (1 < this.reduce)) {
- firstIndexToDraw--;
- indicesToDisplay.unshift(firstIndexToDraw);
- }
-
- var lastIndexToDraw = indicesToDisplay[indicesToDisplay.length-1];
- if ( ((this.numLeafs-1) != lastIndexToDraw) && (1 < this.reduce) ) {
- indicesToDisplay.push(lastIndexToDraw+1);
- }
-
- leafTop = 0;
- var i;
- for (i=0; i<firstIndexToDraw; i++) {
- leafTop += parseInt(this.getPageHeight(i)/this.thumbScale) +10;
- }
-
- //var viewWidth = $('#GBpageview').width(); //includes scroll bar width
- var viewWidth = $('#GBcontainer').attr('scrollWidth');
-
-
- for (i=0; i<indicesToDisplay.length; i++) {
- var index = indicesToDisplay[i];
- var height = parseInt(this.getPageHeight(index)/this.thumbScale);
-
- if(-1 == jQuery.inArray(indicesToDisplay[i], this.displayedIndices)) {
- var width = parseInt(this.getPageWidth(index)/this.thumbScale);
- //console.log("displaying leaf " + indicesToDisplay[i] + ' leafTop=' +leafTop);
- var div = document.createElement("div");
- div.className = 'GBpagediv1up';
- div.id = 'pagediv'+index;
- div.style.position = "absolute";
- $(div).css('top', leafTop + 'px');
- var left = (viewWidth-width)>>1;
- if (left<0) left = 0;
- $(div).css('left', left+'px');
- $(div).css('width', width+'px');
- $(div).css('height', height+'px');
- //$(div).text('loading...');
-
- // thumbnails are hyperlinked, do not need drag handler
- //this.setDragHandler(div);
-
- // link to page in single page mode
- var link = document.createElement("a");
- link.href = '#page/' + (this.getPageNum(index)) +'/mode/1up' ;
- $(div).append(link);
-
- $('#GBpageview').append(div);
-
- var img = document.createElement("img");
- img.src = this.getPageURI(index);
- $(img).css('width', width+'px');
- $(img).css('height', height+'px');
- img.style.border = "0";
- $(link).append(img);
-
-
- } else {
- //console.log("not displaying " + indicesToDisplay[i] + ' score=' + jQuery.inArray(indicesToDisplay[i], this.displayedIndices));
- }
-
- leafTop += height +10;
-
- }
-
- for (i=0; i<this.displayedIndices.length; i++) {
- if (-1 == jQuery.inArray(this.displayedIndices[i], indicesToDisplay)) {
- var index = this.displayedIndices[i];
- //console.log('Removing leaf ' + index);
- //console.log('id='+'#pagediv'+index+ ' top = ' +$('#pagediv'+index).css('top'));
- $('#pagediv'+index).remove();
- } else {
- //console.log('NOT Removing leaf ' + this.displayedIndices[i]);
- }
- }
-
- this.displayedIndices = indicesToDisplay.slice();
- this.updateSearchHilites();
-
- if (null != this.getPageNum(firstIndexToDraw)) {
+ var j;
+ var row;
+ var left;
+ var index;
+ var div;
+ var link;
+ var img;
+ for (i=0; i<rowsToDisplay.length; 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]);
+ }
+ }
+
+ this.displayedRows = rowsToDisplay.slice();
+
+ if (null !== this.getPageNum(this.currentIndex())) {