From 492b974ffe860a111f373192f3347749880059b9 Mon Sep 17 00:00:00 2001 From: "rkumar@home.us.archive.org" Date: Mon, 27 Oct 2008 06:06:20 +0000 Subject: [PATCH] Add autoPlay feature, simple.js, and more icons. --- GnuBook/GnuBook.js | 114 +++++++++++++++++++++----- GnuBook/GnuBookJSSimple.js | 37 +++++++++ GnuBook/images/control_pause_blue.png | Bin 0 -> 721 bytes GnuBook/images/control_play_blue.png | Bin 0 -> 717 bytes GnuBook/images/page_code.png | Bin 0 -> 818 bytes 5 files changed, 130 insertions(+), 21 deletions(-) create mode 100644 GnuBook/GnuBookJSSimple.js create mode 100644 GnuBook/images/control_pause_blue.png create mode 100644 GnuBook/images/control_play_blue.png create mode 100644 GnuBook/images/page_code.png diff --git a/GnuBook/GnuBook.js b/GnuBook/GnuBook.js index b0b4a1c..ccc205c 100644 --- a/GnuBook/GnuBook.js +++ b/GnuBook/GnuBook.js @@ -15,6 +15,8 @@ This file is part of GnuBook. You should have received a copy of the GNU Affero General Public License along with GnuBook. If not, see . + +archive.org cvs $Revision: 1.57 $ $Date: 2008-10-27 05:47:40 $ */ // GnuBook() @@ -39,7 +41,9 @@ function GnuBook() { this.timer = null; this.animating = false; this.auto = false; - + this.autoTimer = null; + this.flipSpeed = 'fast'; + this.twoPagePopUp = null; this.leafEdgeTmp = null; @@ -58,8 +62,8 @@ GnuBook.prototype.init = function() { if (this.bookTitle.length>50) title += '...'; $("#GnuBook").empty(); - $("#GnuBook").append("
zoom: 25%    "+title+"
"); - $("#GBtoolbar").append("
page:
"); + $("#GnuBook").append("
zoom: 25%    "+title+"
"); + $("#GBtoolbar").append("
page:
"); $("#GnuBook").append("
"); $("#GBcontainer").append("
"); @@ -390,13 +394,13 @@ GnuBook.prototype.centerPageView = function() { // jumpToPage() //______________________________________________________________________________ GnuBook.prototype.jumpToPage = function(pageNum) { - if (2 == this.mode) return; + //if (2 == this.mode) return; var i; var foundPage = false; var foundLeaf = null; for (i=0; i= 1) { @@ -795,7 +802,7 @@ GnuBook.prototype.flipBackToIndex = function(index) { borderStyle: 'solid none solid solid', borderColor: 'rgb(51, 51, 34)', borderWidth: '1px 0px 1px 1px', - background: 'transparent url(http://www-rkumar.us.archive.org/GnuBook/images/left-edges.png) repeat scroll 0% 0%', + background: 'transparent url(http://www.us.archive.org/GnuBook/images/left-edges.png) repeat scroll 0% 0%', width: leafEdgeTmpW + 'px', height: this.twoPageH-1 + 'px', left: gutter-scaledWL+10+newLeafEdgeWidthL+'px', @@ -811,7 +818,7 @@ GnuBook.prototype.flipBackToIndex = function(index) { }); var left = $(this.prefetchedImgs[leftLeaf]).offset().left; - var right = $('#GBcontainer').width()-left-$(this.prefetchedImgs[leftLeaf]).width()+9+'px'; + var right = $('#GBcontainer').width()-left-$(this.prefetchedImgs[leftLeaf]).width()+$('#GBcontainer').offset().left-2+'px'; $(this.prefetchedImgs[leftLeaf]).css({ right: right, left: null @@ -820,7 +827,7 @@ GnuBook.prototype.flipBackToIndex = function(index) { left = $(this.prefetchedImgs[leftLeaf]).offset().left - $('#book_div_1').offset().left; right = left+$(this.prefetchedImgs[leftLeaf]).width()+'px'; - $(this.leafEdgeTmp).animate({left: gutter}, 'fast', 'easeInSine'); + $(this.leafEdgeTmp).animate({left: gutter}, this.flipSpeed, 'easeInSine'); //$(this.prefetchedImgs[leftLeaf]).animate({width: '0px'}, 'slow', 'easeInSine'); var scaledWR = this.getPageWidth2UP(prevR); @@ -829,9 +836,9 @@ GnuBook.prototype.flipBackToIndex = function(index) { this.removeSearchHilites(); - $(this.prefetchedImgs[leftLeaf]).animate({width: '0px'}, 'fast', 'easeInSine', function() { - $(self.leafEdgeTmp).animate({left: gutter+scaledWR+'px'}, 'fast', 'easeOutSine'); - $(self.prefetchedImgs[prevR]).animate({width: scaledWR+'px'}, 'fast', 'easeOutSine', function() { + $(this.prefetchedImgs[leftLeaf]).animate({width: '0px'}, self.flipSpeed, 'easeInSine', function() { + $(self.leafEdgeTmp).animate({left: gutter+scaledWR+'px'}, self.flipSpeed, 'easeOutSine'); + $(self.prefetchedImgs[prevR]).animate({width: scaledWR+'px'}, self.flipSpeed, 'easeOutSine', function() { $(self.prefetchedImgs[prevL]).css('zIndex', 2); $(self.leafEdgeR).css({ @@ -916,7 +923,7 @@ GnuBook.prototype.flipFwdToIndex = function(index) { borderStyle: 'solid none solid solid', borderColor: 'rgb(51, 51, 34)', borderWidth: '1px 0px 1px 1px', - background: 'transparent url(http://www-rkumar.us.archive.org/GnuBook/images/left-edges.png) repeat scroll 0% 0%', + background: 'transparent url(http://www.us.archive.org/GnuBook/images/left-edges.png) repeat scroll 0% 0%', width: leafEdgeTmpW + 'px', height: this.twoPageH-1 + 'px', left: currGutter+scaledW+'px', @@ -932,7 +939,7 @@ GnuBook.prototype.flipFwdToIndex = function(index) { var self = this; - var speed = 'fast'; + var speed = this.flipSpeed; this.removeSearchHilites(); @@ -977,10 +984,12 @@ GnuBook.prototype.setClickHandlers = function() { var self = this; $(this.prefetchedImgs[this.currentLeafL]).click(function() { //self.prevPage(); + self.autoStop(); self.flipBackToIndex(null); }); $(this.prefetchedImgs[this.currentLeafR]).click(function() { - //self.nextPage(); + //self.nextPage();' + self.autoStop(); self.flipFwdToIndex(null); }); } @@ -1325,3 +1334,66 @@ GnuBook.prototype.removeSearchHilites = function() { } } } + +// showEmbedCode() +//______________________________________________________________________________ +GnuBook.prototype.showEmbedCode = function() { + this.autoStop(); + var overlay = document.createElement("div"); + $(overlay).css({ + position: 'absolute', + top: '20px', + left: ($('#GBcontainer').width()-400)/2 + 'px', + width: '400px', + padding: "20px", + border: "3px double #999999", + zIndex: 3, + backgroundColor: "#fff", + }).appendTo('#GnuBook'); + + htmlStr = '

Embed Bookreader in your blog!

'; + htmlStr += '

Note: The bookreader is still in beta testing. URLs may change in the future, breaking embedded books. This feature is just for testing!

'; + htmlStr += '

The bookreader uses iframes for embedding. It will not work on web hosts that block iframes. The embed feature has been tested on blogspot.com blogs as well as self-hosted Wordpress blogs. This feature will NOT work on wordpress.com blogs.

'; + htmlStr += '

Embed Code:

'; + htmlStr += '

Close popup

'; + + overlay.innerHTML = htmlStr; +} + +// autoToggle() +//______________________________________________________________________________ +GnuBook.prototype.autoToggle = function() { + if (2 != this.mode) { + this.switchMode(2); + } + + var self = this; + if (null == this.autoTimer) { + this.flipSpeed = 2000; + this.flipFwdToIndex(); + + $('#autoImg').attr('src', 'http://www.us.archive.org/GnuBook/images/control_pause_blue.png'); + this.autoTimer=setInterval(function(){ + if (self.animating) {return;} + + if (self.currentLeafR >= self.numLeafs-5) { + self.flipBackToIndex(1); + } else { + self.flipFwdToIndex(); + } + },5000); + } else { + this.autoStop(); + } +} + +// autoStop() +//______________________________________________________________________________ +GnuBook.prototype.autoStop = function() { + if (null != this.autoTimer) { + clearInterval(this.autoTimer); + this.flipSpeed = 'fast'; + $('#autoImg').attr('src', 'http://www.us.archive.org/GnuBook/images/control_play_blue.png'); + this.autoTimer = null; + } +} diff --git a/GnuBook/GnuBookJSSimple.js b/GnuBook/GnuBookJSSimple.js new file mode 100644 index 0000000..41b78b3 --- /dev/null +++ b/GnuBook/GnuBookJSSimple.js @@ -0,0 +1,37 @@ +//Copyright(c)2008 Internet Archive. Software license AGPL version 3. + +gb = new GnuBook(); + +gb.getPageWidth = function(index) { + return 800; +} + +gb.getPageHeight = function(index) { + return 1200; +} + +gb.getPageURI = function(index) { + var leafStr = '000'; + var imgStr = (index+1).toString(); + var re = new RegExp("0{"+imgStr.length+"}$"); + var url = 'StandAloneImages/page'+leafStr.replace(re, imgStr) + '.jpg'; + return url; +} + +gb.getPageSide = function(index) { + if (0 == (index & 0x1)) { + return 'R'; + } else { + return 'L'; + } +} + +gb.getPageNum = function(index) { + return index+1; +} + +gb.numLeafs = 15; + +gb.bookTitle= 'Open Library Bookreader Presentation'; +gb.bookUrl = 'http://openlibrary.org'; +gb.init(); diff --git a/GnuBook/images/control_pause_blue.png b/GnuBook/images/control_pause_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..ec61099b0b82dcbb0277392c855aa5ed5b17a6d9 GIT binary patch literal 721 zcmV;?0xtcDP)%qypxm=P~KCwUk1<-E^%&v%&sfQfOPbAd^dMUz$2)JWFR zn(5E_apM_H=DRN?Tj1j{9obJa2Z=)=&L)N3y%h6eCr3~F>o%;x+TQ>p^I2c0Y>yvi zIld-=tn@%V9S}8IT_{!R5Z+_Ch0UxTYjubYFr%4GeU;lC74TEKeW=Sl5HvMAeX=Gi zUD%DrWY78$Ld*n!b75@ktedM+7b-uxz>7nb#SWC}9Rsqt73OZQ@HmbM0hR#sjmFrz z`Qn2R+;S%k^W^LfTz4f%8vIhZ??Cw@GT3qQ2$+f;Bm~?nEIi6bESWz7m0cmx39em$$Y&@l88-}q`@)p_|Tj# z*1_TN$urdYuZuK(mFK)s`?7zHi^MWe;3cvrICC;Dz(yzzbJPMi?R@k1RUUs#H=pHg zvrjkZN3JD?ns*D2owV@K;bCSR0s0c1`uAh{pXdA&89xkjaU%7W00000NkvXXu0mjf DW6MO* literal 0 HcmV?d00001 diff --git a/GnuBook/images/control_play_blue.png b/GnuBook/images/control_play_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..f8c8ec683edd6a974eacc253332f903d643dbe41 GIT binary patch literal 717 zcmV;;0y6!HP)*bxx-)TO!p6i!Q&%N5)kR|pVJuNho7M&@5o@ZpsgYXg z6pCpqAEgW*0v6~{n89ISU>M4A&V?DNy7MOQX68Ka`MBqf0l?U(ZY+X9l}VLZ)#Om- z;Wxvd@uT21RmKNz1dH$Bj0zp6>Db9B7mX*l{i7uPYA;7kd3g)QVC)rxA$;8vC|jea zS%$3%AWB_OF8f4{mJFo|55c22v$T`7VytGO85j|cC%=pBjskcjxd*)11x{77(<9$R zNrwG!M09PX(8Nd#urDkdGiz{FkfHKZhPUAguyq;A^$wKyj&8EE8)WXSvDl6Q4NN}z z2Zd#i!U*1a7=Vq#3W3jRZ6Z9$+&MVBAqrVEFbBV-XzUqFMNrFnb9RsDb%-T!q1pza zrNBj9g5~vhG_q(g8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