// - getPageURI()
// You must also add a numLeafs property before calling init().
-//XXX
-if (typeof(console) == 'undefined') {
- console = { log: function(msg) { } };
-}
-
function GnuBook() {
this.reduce = 4;
this.padding = 10;
// drawLeafsTwoPage()
//______________________________________________________________________________
GnuBook.prototype.drawLeafsTwoPage = function() {
- console.log('drawing two leafs!'); // XXX
-
var scrollTop = $('#GBtwopageview').attr('scrollTop');
var scrollBottom = scrollTop + $('#GBtwopageview').height();
- console.log('drawLeafsTwoPage: this.currrentLeafL ' + this.twoPage.currentIndexL); // XXX
-
- // XXX we should use calculated values in this.twoPage (recalc if necessary)
+ // $$$ we should use calculated values in this.twoPage (recalc if necessary)
var indexL = this.twoPage.currentIndexL;
var heightL = this.getPageHeight(indexL);
//______________________________________________________________________________
GnuBook.prototype.zoom2up = function(direction) {
- // Stop autoplay
- this.autoStop();
- this.stopFlipAnimations(); // hard stop animations
+ // Hard stop autoplay
+ this.stopFlipAnimations();
// Get new zoom state
var newZoom = this.twoPageNextReduce(this.reduce, direction);
// This function sets this.twoPage.height, twoPage.width
GnuBook.prototype.calculateSpreadSize = function() {
- console.log('calculateSpreadSize ' + this.twoPage.currentIndexL); // XXX
// $$$ TODO Calculate the spread size based on the reduction factor. If we are using
// fit mode we recalculate the reduction factor based on the current page sizes
ideal.height = parseInt(ideal.width*ratio);
}
- // XXX check this logic with large spreads
+ // $$$ check this logic with large spreads
ideal.reduce = ((first.height + second.height) / 2) / ideal.height;
return ideal;
var spreadSize = {};
// $$$ Scale this based on reduce?
var totalLeafEdgeWidth = parseInt(this.numLeafs * 0.1);
- var maxLeafEdgeWidth = parseInt($('#GBcontainer').attr('clientWidth') * 0.1); // XXX update
+ var maxLeafEdgeWidth = parseInt($('#GBcontainer').attr('clientWidth') * 0.1); // $$$ Assumes leaf edge width constant at all zoom levels
spreadSize.totalLeafEdgeWidth = Math.min(totalLeafEdgeWidth, maxLeafEdgeWidth);
// $$$ Possibly incorrect -- we should make height "dominant"
// It is offset from the middle to create the illusion of thickness to the pages
var gutter = middle + this.gutterOffsetForIndex(prevL);
- // XXX
- console.log(' gutter for ' + prevL + ' is ' + gutter);
+ //console.log(' gutter for ' + prevL + ' is ' + gutter);
//console.log(' prevL.left: ' + (gutter - scaledW) + 'px');
//console.log(' changing prevL ' + prevL + ' to left: ' + (gutter-scaledW) + ' width: ' + scaledW);
}
-// XXXmang we're adding an extra pixel in the middle
+// $$$ mang we're adding an extra pixel in the middle. See https://bugs.edge.launchpad.net/gnubook/+bug/411667
// prepareFlipRightToLeft()
//______________________________________________________________________________
GnuBook.prototype.prepareFlipRightToLeft = function(nextL, nextR) {
var scaledW = this.twoPage.height*width/height;
var gutter = middle + this.gutterOffsetForIndex(nextL);
-
- console.log('right to left to %d gutter is %d', nextL, gutter); // XXX
-
+
//console.log(' prepareRTL changing nextR ' + nextR + ' to left: ' + gutter);
$(this.prefetchedImgs[nextR]).css({
position: 'absolute',
}
}
-// XXX move, clean up, use everywhere
+// twoPageGutter()
+//______________________________________________________________________________
+// Returns the position of the gutter (line between the page images)
GnuBook.prototype.twoPageGutter = function() {
return this.twoPage.middle + this.gutterOffsetForIndex(this.twoPage.currentIndexL);
}
-// XXX move, clean up, use everywhere
+// twoPageTop()
+//______________________________________________________________________________
+// Returns the offset for the top of the page images
GnuBook.prototype.twoPageTop = function() {
return this.twoPage.coverExternalPadding + this.twoPage.coverInternalPadding; // $$$ + border?
}
-
+
+// twoPageCoverWidth()
+//______________________________________________________________________________
+// Returns the width of the cover div given the total page width
GnuBook.prototype.twoPageCoverWidth = function(totalPageWidth) {
return totalPageWidth + this.twoPage.edgeWidth + 2*this.twoPage.coverInternalPadding;
}
+// twoPageGetViewCenter()
+//______________________________________________________________________________
+// Returns the percentage offset into twopageview div at the center of container div
+// { percentageX: float, percentageY: float }
GnuBook.prototype.twoPageGetViewCenter = function() {
var center = {};
// autoStop()
//______________________________________________________________________________
+// Stop autoplay mode, allowing animations to finish
GnuBook.prototype.autoStop = function() {
if (null != this.autoTimer) {
clearInterval(this.autoTimer);
}
}
-// $$$ document
+// stopFlipAnimations
+//______________________________________________________________________________
+// Immediately stop flip animations. Callbacks are triggered.
GnuBook.prototype.stopFlipAnimations = function() {
+ this.autoStop(); // Clear timers
+
// Stop animation, clear queue, trigger callbacks
if (this.leafEdgeTmp) {
$(this.leafEdgeTmp).stop(false, true);
}
- console.log(this.leafEdgeTmp);
jQuery.each(this.prefetchedImgs, function() {
$(this).stop(false, true);
});
if (this.leafEdgeTmp) {
$(this.leafEdgeTmp).stop(false, true);
}
- console.log(this.leafEdgeTmp);
jQuery.each(this.prefetchedImgs, function() {
$(this).stop(false, true);
});