// this.twoPage.autofit = null; // Take zoom level from other mode
this.twoPageCalculateReductionFactors();
this.reduce = this.quantizeReduce(this.reduce, this.twoPage.reductionFactors);
+ $('button.thumb').show();
+ $('button.twopg').hide();
this.prepareTwoPageView();
this.twoPageCenterView(0.5, 0.5); // $$$ TODO preserve center
}
//______________________________________________________________________________
BookReader.prototype.search = function(term) {
//console.log('search called with term=' + term);
-
- $('#textSrch').blur(); //cause mobile safari to hide the keyboard
-
var url = 'http://'+this.server.replace(/:.+/, ''); //remove the port and userdir
url += '/~edward/inside_jsonp.php?item_id='+this.bookId;
url += '&doc='+this.subPrefix; //TODO: test with subitem
BookReader.prototype.initToolbar = function(mode, ui) {
// $$$mang should be contained within the BookReader div instead of body
-
- var readIcon = '';
+ var readIcon = ''
if (!navigator.userAgent.match(/mobile/i)) {
readIcon = "<button class='BRicon read modal'></button>";
}
-
+
$("body").append(
"<div id='BRtoolbar'>"
+ "<span id='BRtoolbarbuttons'>"
/* XXXmang integrate search */
- + "<form action='javascript:br.search($(\"#textSrch\").val());' id='booksearch'><input type='search' id='textSrch' name='textSrch' val='' placeholder='Search inside'/><button type='submit' id='btnSrch' name='btnSrch'>GO</button></form>"
+ + "<form action='javascript:' id='booksearch'><input type='search' id='textSrch' name='textSrch' val='' placeholder='Search inside'/><button type='submit' id='btnSrch' name='btnSrch'>GO</button></form>"
// XXXmang icons incorrect or handlers wrong
- + "<button class='BRicon play'></button>"
- + "<button class='BRicon pause'></button>"
+ "<button class='BRicon info'></button>"
+ "<button class='BRicon share'></button>"
+ readIcon
- //+ "<button class='BRicon full'></button>"
+ + "<button class='BRicon full'></button>"
+ "</span>"
+ "<span><a class='logo' href='" + this.logoURL + "'></a></span>"
+ "<span id='BRreturn'><span>Back to</span><a href='" + this.bookUrl + "'>" + this.bookTitle + "</a></span>"
+ + "<div id='BRnavCntlTop' class='BRnavCntl BRup'></div>"
+ "</div>"
/*
+ "<div id='BRzoomer'>"
*/
);
- $('#BRtoolbar .pause').hide();
-
this.updateToolbarZoom(this.reduce); // Pretty format
if (ui == "embed" || ui == "touch") {
'.embed': 'Embed BookReader',
'.link': 'Link to this book (and page)',
'.bookmark': 'Bookmark this page',
- '.read': 'Read this book aloud',
+ '.read': 'Allow BookReader to read this aloud',
'.full': 'Show fullscreen',
'.book_left': 'Flip left',
'.book_right': 'Flip right',
});
// XXX fix integration
- // XXX Mobile safari was not picking up this handler, so
- // I explictly set the form action in initToolbar()
- // $('#booksearch').bind('submit', function() {
- // self.search($('#textSrch').val());
- // });
+ $('#booksearch').bind('submit', function() {
+ self.search($('#textSrch').val());
+ });
this.initSwipeData();
$('#BookReader').die('mousemove.navigation').live('mousemove.navigation',
// showProgressPopup
//______________________________________________________________________________
BookReader.prototype.showProgressPopup = function(msg) {
+ if (soundManager.debugMode) console.log('showProgressPopup index='+this.ttsIndex+' pos='+this.ttsPosition);
if (this.popup) return;
this.popup = document.createElement("div");
$(this.popup).css({
top: ($('#BookReader').height()*0.5-100) + 'px',
- left: ($('#BookReader').width()-300)*0.5 + 'px',
- width: '300px',
- border: '2px solid black'
+ left: ($('#BookReader').width()-300)*0.5 + 'px'
}).attr('className', 'BRprogresspopup');
var bar = document.createElement("div");
},3000);
};
$().ready(function(){
- $('#BRtoolbar').animate({top:0},3000).animate({top:-40});
- $('#BRnav').animate({bottom:0},3000).animate({bottom:-53});
+ /*
+ $('#BRtoolbar').delay(3000).animate({top:-40});
+ $('#BRnav').delay(3000).animate({bottom:-53});
changeArrow();
- $('.BRnavCntl').animate({opacity:1},3000).animate({height:'43px'}).animate({opacity:1},1000).animate({opacity:.25},1000);
+ $('.BRnavCntl').delay(3000).animate({height:'43px'}).delay(1000).animate({opacity:.25},1000);
+ */
$('.BRnavCntl').click(
function(){
if ($('#BRnavCntlBtm').hasClass('BRdn')) {
$('#BRtoolbar').animate({top:-40});
- $('#BRnav').animate({bottom:-53});
+ $('#BRnav').animate({bottom:-55});
$('#BRnavCntlBtm').addClass('BRup').removeClass('BRdn');
- $('.BRnavCntl').animate({height:'43px'}).animate({opacity:1},1000).animate({opacity:.25},1000);
+ $('#BRnavCntlTop').addClass('BRdn').removeClass('BRup');
+ $('#BRnavCntlBtm.BRnavCntl').animate({height:'45px'});
+ $('.BRnavCntl').delay(1000).animate({opacity:.25},1000);
} else {
$('#BRtoolbar').animate({top:0});
$('#BRnav').animate({bottom:0});
$('#BRnavCntlBtm').addClass('BRdn').removeClass('BRup');
- $('.BRnavCntl').animate({opacity:1,height:'30px'});
+ $('#BRnavCntlTop').addClass('BRup').removeClass('BRdn');
+ $('#BRnavCntlBtm.BRnavCntl').animate({height:'30px'});
+ $('.BRvavCntl').animate({opacity:1})
};
}
);
$('.BRnavCntl').animate({opacity:.25},250);
};
});
+ $('#BRnavCntlTop').mouseover(function(){
+ if ($(this).hasClass('BRdn')) {
+ $('.BRnavCntl').animate({opacity:1},250);
+ };
+ });
+ $('#BRnavCntlTop').mouseleave(function(){
+ if ($(this).hasClass('BRdn')) {
+ $('.BRnavCntl').animate({opacity:.25},250);
+ };
+ });
});
-
*
* Project Home:
* http://code.google.com/p/jquery-ui-for-ipad-and-iphone/
-*/
-
-
-
-
-
-$(function() {
-
- //
-
- // Extend jQuery feature detection
-
- //
-
- $.extend($.support, {
-
- touch: typeof Touch == "object"
-
- });
-
-
-
- //
-
- // Hook up touch events
-
- //
-
- if ($.support.touch) {
-
- document.addEventListener("touchstart", iPadTouchHandler, false);
-
- document.addEventListener("touchmove", iPadTouchHandler, false);
-
- document.addEventListener("touchend", iPadTouchHandler, false);
-
- document.addEventListener("touchcancel", iPadTouchHandler, false);
-
- }
-
-});
-
-
-
-
-
-var lastTap = null; // Holds last tapped element (so we can compare for double tap)
-
-var tapValid = false; // Are we still in the .6 second window where a double tap can occur
-
-var tapTimeout = null; // The timeout reference
-
-
-
-function cancelTap() {
-
- tapValid = false;
-
-}
-
-
-
-
-
-var rightClickPending = false; // Is a right click still feasible
-
-var rightClickEvent = null; // the original event
-
-var holdTimeout = null; // timeout reference
-
-var cancelMouseUp = false; // prevents a click from occuring as we want the context menu
-
-
-
-
-
-function cancelHold() {
-
- if (rightClickPending) {
-
- window.clearTimeout(holdTimeout);
-
- rightClickPending = false;
-
- rightClickEvent = null;
-
- }
-
-}
-
-
-
-function startHold(event) {
-
- if (rightClickPending)
-
- return;
-
-
-
- rightClickPending = true; // We could be performing a right click
-
- rightClickEvent = (event.changedTouches)[0];
-
- holdTimeout = window.setTimeout("doRightClick();", 800);
-
-}
-
-
-
-
-
-function doRightClick() {
-
- rightClickPending = false;
-
-
-
- //
-
- // We need to mouse up (as we were down)
-
- //
-
- var first = rightClickEvent,
-
- simulatedEvent = document.createEvent("MouseEvent");
-
- simulatedEvent.initMouseEvent("mouseup", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
-
- false, false, false, false, 0, null);
-
- first.target.dispatchEvent(simulatedEvent);
-
-
-
- //
-
- // emulate a right click
-
- //
-
- simulatedEvent = document.createEvent("MouseEvent");
-
- simulatedEvent.initMouseEvent("mousedown", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
-
- false, false, false, false, 2, null);
-
- first.target.dispatchEvent(simulatedEvent);
-
-
-
- //
-
- // Show a context menu
-
- //
-
- simulatedEvent = document.createEvent("MouseEvent");
-
- simulatedEvent.initMouseEvent("contextmenu", true, true, window, 1, first.screenX + 50, first.screenY + 5, first.clientX + 50, first.clientY + 5,
-
- false, false, false, false, 2, null);
-
- first.target.dispatchEvent(simulatedEvent);
-
-
-
-
-
- //
-
- // Note:: I don't mouse up the right click here however feel free to add if required
-
- //
-
-
-
-
-
- //cancelMouseUp = true; // XXXmang this was preventing swipe from working! make sure rest of code is okay with setting this false
- cancelMouseUp = false;
-
- rightClickEvent = null; // Release memory
-
-}
-
-
-
-
-
-//
-
-// mouse over event then mouse down
-
-//
-
-function iPadTouchStart(event) {
-
- var touches = event.changedTouches,
-
- first = touches[0],
-
- type = "mouseover",
-
- simulatedEvent = document.createEvent("MouseEvent");
-
- //
-
- // Mouse over first - I have live events attached on mouse over
-
- //
-
- simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
-
- false, false, false, false, 0, null);
-
- first.target.dispatchEvent(simulatedEvent);
-
-
-
- type = "mousedown";
-
- simulatedEvent = document.createEvent("MouseEvent");
-
-
-
- simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
-
- false, false, false, false, 0, null);
-
- first.target.dispatchEvent(simulatedEvent);
-
-
-
-
-
- if (!tapValid) {
-
- lastTap = first.target;
-
- tapValid = true;
-
- tapTimeout = window.setTimeout("cancelTap();", 600);
-
- startHold(event);
-
- }
-
- else {
-
- window.clearTimeout(tapTimeout);
-
-
-
- //
-
- // If a double tap is still a possibility and the elements are the same
-
- // Then perform a double click
-
- //
-
- if (first.target == lastTap) {
-
- lastTap = null;
-
- tapValid = false;
-
-
-
- type = "click";
-
- simulatedEvent = document.createEvent("MouseEvent");
-
-
-
- simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
-
- false, false, false, false, 0/*left*/, null);
-
- first.target.dispatchEvent(simulatedEvent);
-
-
-
- type = "dblclick";
-
- simulatedEvent = document.createEvent("MouseEvent");
-
-
-
- simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
-
- false, false, false, false, 0/*left*/, null);
-
- first.target.dispatchEvent(simulatedEvent);
-
- }
-
- else {
-
- lastTap = first.target;
-
- tapValid = true;
-
- tapTimeout = window.setTimeout("cancelTap();", 600);
-
- startHold(event);
-
- }
-
- }
-
-}
-
-
-
-function iPadTouchHandler(event) {
-
- var type = "",
-
- button = 0; /*left*/
-
-
-
- if (event.touches.length > 1)
-
- return;
-
-
-
- switch (event.type) {
-
- case "touchstart":
-
- if ($(event.changedTouches[0].target).is("select")) {
-
- return;
-
- }
-
- iPadTouchStart(event); /*We need to trigger two events here to support one touch drag and drop*/
-
- event.preventDefault();
-
- return false;
-
- break;
-
-
-
- case "touchmove":
-
- cancelHold();
-
- type = "mousemove";
-
- event.preventDefault();
-
- break;
-
-
-
- case "touchend":
-
- if (cancelMouseUp) {
-
- cancelMouseUp = false;
-
- event.preventDefault();
-
- return false;
-
- }
-
- cancelHold();
-
- type = "mouseup";
-
- break;
-
-
-
- default:
-
- return;
-
- }
-
-
-
- var touches = event.changedTouches,
-
- first = touches[0],
-
- simulatedEvent = document.createEvent("MouseEvent");
-
-
-
- simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
-
- false, false, false, false, button, null);
-
-
-
- first.target.dispatchEvent(simulatedEvent);
-
-
-
- if (type == "mouseup" && tapValid && first.target == lastTap) { // This actually emulates the ipads default behaviour (which we prevented)
-
- simulatedEvent = document.createEvent("MouseEvent"); // This check avoids click being emulated on a double tap
-
-
-
- simulatedEvent.initMouseEvent("click", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
-
- false, false, false, false, button, null);
-
-
-
- first.target.dispatchEvent(simulatedEvent);
-
- }
-
-}
-
-
-
-
-
+*/\r
+\r
+\r
+$(function() {\r
+ //\r
+ // Extend jQuery feature detection\r
+ //\r
+ $.extend($.support, {\r
+ touch: typeof Touch == "object"\r
+ });\r
+ \r
+ //\r
+ // Hook up touch events\r
+ //\r
+ if ($.support.touch) {\r
+ document.addEventListener("touchstart", iPadTouchHandler, false);\r
+ document.addEventListener("touchmove", iPadTouchHandler, false);\r
+ document.addEventListener("touchend", iPadTouchHandler, false);\r
+ document.addEventListener("touchcancel", iPadTouchHandler, false);\r
+ }\r
+});\r
+\r
+\r
+var lastTap = null; // Holds last tapped element (so we can compare for double tap)\r
+var tapValid = false; // Are we still in the .6 second window where a double tap can occur\r
+var tapTimeout = null; // The timeout reference\r
+\r
+function cancelTap() {\r
+ tapValid = false;\r
+}\r
+\r
+\r
+var rightClickPending = false; // Is a right click still feasible\r
+var rightClickEvent = null; // the original event\r
+var holdTimeout = null; // timeout reference\r
+var cancelMouseUp = false; // prevents a click from occuring as we want the context menu\r
+\r
+\r
+function cancelHold() {\r
+ if (rightClickPending) {\r
+ window.clearTimeout(holdTimeout);\r
+ rightClickPending = false;\r
+ rightClickEvent = null;\r
+ }\r
+}\r
+\r
+function startHold(event) {\r
+ if (rightClickPending)\r
+ return;\r
+\r
+ rightClickPending = true; // We could be performing a right click\r
+ rightClickEvent = (event.changedTouches)[0];\r
+ holdTimeout = window.setTimeout("doRightClick();", 800);\r
+}\r
+\r
+\r
+function doRightClick() {\r
+ rightClickPending = false;\r
+\r
+ //\r
+ // We need to mouse up (as we were down)\r
+ //\r
+ var first = rightClickEvent,\r
+ simulatedEvent = document.createEvent("MouseEvent");\r
+ simulatedEvent.initMouseEvent("mouseup", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,\r
+ false, false, false, false, 0, null);\r
+ first.target.dispatchEvent(simulatedEvent);\r
+\r
+ //\r
+ // emulate a right click\r
+ //\r
+ simulatedEvent = document.createEvent("MouseEvent");\r
+ simulatedEvent.initMouseEvent("mousedown", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,\r
+ false, false, false, false, 2, null);\r
+ first.target.dispatchEvent(simulatedEvent);\r
+\r
+ //\r
+ // Show a context menu\r
+ //\r
+ simulatedEvent = document.createEvent("MouseEvent");\r
+ simulatedEvent.initMouseEvent("contextmenu", true, true, window, 1, first.screenX + 50, first.screenY + 5, first.clientX + 50, first.clientY + 5,\r
+ false, false, false, false, 2, null);\r
+ first.target.dispatchEvent(simulatedEvent);\r
+\r
+\r
+ //\r
+ // Note:: I don't mouse up the right click here however feel free to add if required\r
+ //\r
+\r
+\r
+ cancelMouseUp = true;\r
+ rightClickEvent = null; // Release memory\r
+}\r
+\r
+\r
+//\r
+// mouse over event then mouse down\r
+//\r
+function iPadTouchStart(event) {\r
+ var touches = event.changedTouches,\r
+ first = touches[0],\r
+ type = "mouseover",\r
+ simulatedEvent = document.createEvent("MouseEvent");\r
+ //\r
+ // Mouse over first - I have live events attached on mouse over\r
+ //\r
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,\r
+ false, false, false, false, 0, null);\r
+ first.target.dispatchEvent(simulatedEvent);\r
+\r
+ type = "mousedown";\r
+ simulatedEvent = document.createEvent("MouseEvent");\r
+\r
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,\r
+ false, false, false, false, 0, null);\r
+ first.target.dispatchEvent(simulatedEvent);\r
+\r
+\r
+ if (!tapValid) {\r
+ lastTap = first.target;\r
+ tapValid = true;\r
+ tapTimeout = window.setTimeout("cancelTap();", 600);\r
+ startHold(event);\r
+ }\r
+ else {\r
+ window.clearTimeout(tapTimeout);\r
+\r
+ //\r
+ // If a double tap is still a possibility and the elements are the same\r
+ // Then perform a double click\r
+ //\r
+ if (first.target == lastTap) {\r
+ lastTap = null;\r
+ tapValid = false;\r
+\r
+ type = "click";\r
+ simulatedEvent = document.createEvent("MouseEvent");\r
+\r
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,\r
+ false, false, false, false, 0/*left*/, null);\r
+ first.target.dispatchEvent(simulatedEvent);\r
+\r
+ type = "dblclick";\r
+ simulatedEvent = document.createEvent("MouseEvent");\r
+\r
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,\r
+ false, false, false, false, 0/*left*/, null);\r
+ first.target.dispatchEvent(simulatedEvent);\r
+ }\r
+ else {\r
+ lastTap = first.target;\r
+ tapValid = true;\r
+ tapTimeout = window.setTimeout("cancelTap();", 600);\r
+ startHold(event);\r
+ }\r
+ }\r
+}\r
+\r
+function iPadTouchHandler(event) {\r
+ var type = "",\r
+ button = 0; /*left*/\r
+\r
+ if (event.touches.length > 1)\r
+ return;\r
+\r
+ switch (event.type) {\r
+ case "touchstart":\r
+ if ($(event.changedTouches[0].target).is("select")) {\r
+ return;\r
+ }\r
+ iPadTouchStart(event); /*We need to trigger two events here to support one touch drag and drop*/\r
+ event.preventDefault();\r
+ return false;\r
+ break;\r
+\r
+ case "touchmove":\r
+ cancelHold();\r
+ type = "mousemove";\r
+ event.preventDefault();\r
+ break;\r
+\r
+ case "touchend":\r
+ if (cancelMouseUp) {\r
+ cancelMouseUp = false;\r
+ event.preventDefault();\r
+ return false;\r
+ }\r
+ cancelHold();\r
+ type = "mouseup";\r
+ break;\r
+\r
+ default:\r
+ return;\r
+ }\r
+\r
+ var touches = event.changedTouches,\r
+ first = touches[0],\r
+ simulatedEvent = document.createEvent("MouseEvent");\r
+\r
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,\r
+ false, false, false, false, button, null);\r
+\r
+ first.target.dispatchEvent(simulatedEvent);\r
+\r
+ if (type == "mouseup" && tapValid && first.target == lastTap) { // This actually emulates the ipads default behaviour (which we prevented)\r
+ simulatedEvent = document.createEvent("MouseEvent"); // This check avoids click being emulated on a double tap\r
+\r
+ simulatedEvent.initMouseEvent("click", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,\r
+ false, false, false, false, button, null);\r
+\r
+ first.target.dispatchEvent(simulatedEvent);\r
+ }\r
+}\r
+\r
+\r