$(this.leafEdgeR).bind('mousemove', this, function(e) {
var jumpIndex = e.data.jumpIndexForRightEdgePageX(e.pageX);
- $(e.data.twoPagePopUp).text('View Page '+ e.data.getPageNum(jumpIndex));
+ $(e.data.twoPagePopUp).text('View ' + e.data.getPageName(jumpIndex));
$(e.data.twoPagePopUp).css({
left: e.pageX +5+ 'px',
$(this.leafEdgeL).bind('mousemove', this, function(e) {
var jumpIndex = e.data.jumpIndexForLeftEdgePageX(e.pageX);
- $(e.data.twoPagePopUp).text('View Page '+ e.data.getPageNum(jumpIndex));
+ $(e.data.twoPagePopUp).text('View '+ e.data.getPageName(jumpIndex));
$(e.data.twoPagePopUp).css({
left: e.pageX - $(e.data.twoPagePopUp).width() - 30 + 'px',
script.setAttribute("type", "text/javascript");
script.setAttribute("src", 'http://'+this.server+'/GnuBook/flipbook_search_gb.php?url='+escape(this.bookPath+'/'+this.bookId+'_djvu.xml')+'&term='+term+'&format=XML&callback=gb.GBSearchCallback');
document.getElementsByTagName('head')[0].appendChild(script);
+ $('#GnuBookSearchResults').html('Searching...');
}
// GBSearchCallback()
}
}
}
+ var pageName = this.getPageName(index);
//TODO: remove hardcoded instance name
- $('#GnuBookSearchResults').append('<li><b><a href="javascript:gb.jumpToIndex('+index+');">Leaf ' + index + '</a></b> - ' + context+'</li>');
+ $('#GnuBookSearchResults').append('<li><b><a href="javascript:gb.jumpToIndex('+index+');">' + pageName + '</a></b> - ' + context + '</li>');
}
}
$('#GnuBookSearchResults').append('</ul>');
if ('rl' != this.pageProgression) {
// LTR - flipping backward
var jumpIndex = this.currentIndexL - ($(this.leafEdgeL).offset().left + $(this.leafEdgeL).width() - pageX) * 10;
- // browser may have resized the div due to font size change -- see https://bugs.launchpad.net/gnubook/+bug/333570
- jumpIndex = Math.min(jumpIndex, this.currentIndexL - 2);
- jumpIndex = Math.max(jumpIndex, this.firstDisplayableIndex());
+
+ // browser may have resized the div due to font size change -- see https://bugs.launchpad.net/gnubook/+bug/333570
+ jumpIndex = GnuBook.util.clamp(Math.round(jumpIndex), this.firstDisplayableIndex(), this.currentIndexL - 2);
return jumpIndex;
+
} else {
var jumpIndex = this.currentIndexL + ($(this.leafEdgeL).offset().left + $(this.leafEdgeL).width() - pageX) * 10;
- jumpIndex = Math.max(jumpIndex, this.currentIndexL + 2);
- jumpIndex = Math.min(jumpIndex, this.lastDisplayableIndex());
+ jumpIndex = GnuBook.util.clamp(Math.round(jumpIndex), this.currentIndexL + 2, this.lastDisplayableIndex());
return jumpIndex;
}
}
if ('rl' != this.pageProgression) {
// LTR
var jumpIndex = this.currentIndexR + (pageX - $(this.leafEdgeR).offset().left) * 10;
- jumpIndex = Math.max(jumpIndex, this.currentIndexR + 2);
- jumpIndex = Math.min(jumpIndex, this.lastDisplayableIndex());
+ jumpIndex = GnuBook.util.clamp(Math.round(jumpIndex), this.currentIndexR + 2, this.lastDisplayableIndex());
return jumpIndex;
} else {
var jumpIndex = this.currentIndexR - (pageX - $(this.leafEdgeR).offset().left) * 10;
- jumpIndex = Math.min(jumpIndex, this.currentIndexR - 2);
- jumpIndex = Math.max(jumpIndex, this.firstDisplayableIndex());
+ jumpIndex = GnuBook.util.clamp(Math.round(jumpIndex), this.firstDisplayableIndex(), this.currentIndexR - 2);
return jumpIndex;
}
}
+ "<a class='GBicon logo rollover' href='" + this.logoURL + "'> </a>"
+ " <button class='GBicon rollover zoom_out' onclick='gb.zoom1up(-1); return false;'/>"
+ "<button class='GBicon rollover zoom_in' onclick='gb.zoom1up(1); return false;'/>"
- + " <span class='label'>Zoom: <span id='GBzoom'>25</span>%</span>"
+ + " <span class='label'>Zoom: <span id='GBzoom'>"+100/this.reduce+"</span>%</span>"
+ " <button class='GBicon rollover one_page_mode' onclick='gb.switchMode(1); return false;'/>"
+ " <button class='GBicon rollover two_page_mode' onclick='gb.switchMode(2); return false;'/>"
+ " <a class='GBblack title' href='"+this.bookUrl+"' target='_blank'>"+this.shortTitle(50)+"</a>"
if (pageNum.slice(0,1) == 'n') {
try {
var pageIntStr = pageNum.slice(1, pageNum.length);
- pageIndex = parseInt(pageIntStr);
+ var pageIndex = parseInt(pageIntStr);
indices.append(pageIndex);
return indices;
} catch(err) {
return indices;
}
+// getPageName(index)
+//________
+// Returns the name of the page as it should be displayed in the user interface
+GnuBook.prototype.getPageName = function(index) {
+ return 'Page ' + this.getPageNum(index);
+}
+
// updateLocationHash
//________
// Update the location hash from the current parameters. Call this instead of manually
// Returns the embed code HTML fragment suitable for copy and paste
GnuBook.prototype.getEmbedCode = function() {
return "<iframe src='" + this.getEmbedURL() + "' width='480px' height='430px'></iframe>";
+}
+
+
+// Library functions
+GnuBook.util = {
+ clamp: function(value, min, max) {
+ return Math.min(Math.max(value, min), max);
+ }
}
\ No newline at end of file