Merge remote-tracking branch 'Ganonmaster/master'
This commit is contained in:
commit
d113b9d950
6 changed files with 99 additions and 53 deletions
|
@ -4,7 +4,6 @@
|
|||
TODOs:
|
||||
|
||||
Fo sho:
|
||||
- fix manga mode
|
||||
- trigger preload if requesting valid but not loaded images (can happen if network was interupted)
|
||||
- loading and generally hackiness of pointer is buggy, fix.
|
||||
- check for html5 feature support where used: diveintohtml5.org/everything.html or www.modernizr.com
|
||||
|
@ -79,7 +78,8 @@ function ComicBook(id, srcs, opts) {
|
|||
previous: 80,
|
||||
toolbar: 84,
|
||||
toggleLayout: 76
|
||||
}
|
||||
},
|
||||
forward_buffer: 3
|
||||
};
|
||||
|
||||
var options = merge(defaults, opts); // options array for internal use
|
||||
|
@ -170,11 +170,9 @@ function ComicBook(id, srcs, opts) {
|
|||
}
|
||||
|
||||
// add page controls
|
||||
// TODO: add IE event listeners too.
|
||||
canvas.addEventListener("click", ComicBook.prototype.navigation, false);
|
||||
window.addEventListener("keydown", ComicBook.prototype.navigation, false);
|
||||
window.addEventListener("hashchange", checkHash, false);
|
||||
//setInterval(function() { checkHash(); }, 300); // TODO: enable this when there is no onhashchange event
|
||||
$(window).bind('hashchange', checkHash);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,6 +243,16 @@ function ComicBook(id, srcs, opts) {
|
|||
ComicBook.prototype.drawPage();
|
||||
})
|
||||
)
|
||||
.append(
|
||||
$(document.createElement("button"))
|
||||
.attr("title", ((options.manga == true) ? "change reading direction to 'left-to-right'" : "change reading direction to 'right-to-left'"))
|
||||
.addClass("cb-read-direction")
|
||||
.click(function(){
|
||||
options.manga = !options.manga;
|
||||
ComicBook.prototype.drawPage();
|
||||
})
|
||||
.attr("id", ((options.manga == true) ? "toright" : "toleft"))
|
||||
)
|
||||
.append(
|
||||
$(document.createElement("p"))
|
||||
.attr("id", "cb-comic-info")
|
||||
|
@ -307,13 +315,27 @@ function ComicBook(id, srcs, opts) {
|
|||
left: $(document.createElement("div"))
|
||||
.addClass("cb-control cb-navigate cb-always-on left")
|
||||
.click(function(e){
|
||||
ComicBook.prototype.drawPrevPage();
|
||||
if(options.manga == false)
|
||||
{
|
||||
ComicBook.prototype.drawPrevPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
ComicBook.prototype.drawNextPage();
|
||||
}
|
||||
}),
|
||||
|
||||
right: $(document.createElement("div"))
|
||||
.addClass("cb-control cb-navigate cb-always-on right")
|
||||
.click(function(e) {
|
||||
ComicBook.prototype.drawNextPage();
|
||||
if(options.manga == false)
|
||||
{
|
||||
ComicBook.prototype.drawNextPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
ComicBook.prototype.drawPrevPage();
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -515,9 +537,6 @@ function ComicBook(id, srcs, opts) {
|
|||
// loads pages in both directions so you don't have to wait for all pages
|
||||
// to be loaded before you can scroll backwards
|
||||
function preload(start, stop) {
|
||||
|
||||
var forward_buffer = 3; // TODO: make this into a config option?
|
||||
|
||||
var j = 0;
|
||||
var count = 1;
|
||||
var forward = start;
|
||||
|
@ -525,7 +544,7 @@ function ComicBook(id, srcs, opts) {
|
|||
|
||||
while (forward <= stop) {
|
||||
|
||||
if (count > forward_buffer && backward > -1) {
|
||||
if (count > options.forward_buffer && backward > -1) {
|
||||
queue.push(backward);
|
||||
backward--;
|
||||
count = 0;
|
||||
|
@ -678,19 +697,39 @@ function ComicBook(id, srcs, opts) {
|
|||
|
||||
// disable the fit width button if needed
|
||||
$("button.cb-fit-width").attr("disabled", (options.zoomMode === "fitWidth"));
|
||||
|
||||
//Change the icon on the read direction
|
||||
if(options.manga == true)
|
||||
{
|
||||
$("button.cb-read-direction").attr("id", "toright");
|
||||
}
|
||||
else
|
||||
{
|
||||
$("button.cb-read-direction").attr("id", "toleft");
|
||||
}
|
||||
|
||||
// disable prev/next buttons if not needed
|
||||
$(".cb-navigate").show();
|
||||
if (pointer === 0) {
|
||||
if ((pointer === 0) && (options.manga == false)) {
|
||||
$(".cb-navigate.left").hide();
|
||||
$(".cb-navigate.right").show();
|
||||
}
|
||||
|
||||
if (pointer === srcs.length-1 || (typeof page2 === "object" && pointer === srcs.length-2)) {
|
||||
else if ((pointer === 0) && (options.manga == true))
|
||||
{
|
||||
$(".cb-navigate.left").show();
|
||||
$(".cb-navigate.right").hide();
|
||||
}
|
||||
|
||||
if ((pointer === srcs.length-1 || (typeof page2 === "object" && pointer === srcs.length-2)) && (options.manga == false)) {
|
||||
$(".cb-navigate.left").show();
|
||||
$(".cb-navigate.right").hide();
|
||||
}
|
||||
else if ((pointer === srcs.length-1 || (typeof page2 === "object" && pointer === srcs.length-2)) && (options.manga == true))
|
||||
{
|
||||
$(".cb-navigate.left").hide();
|
||||
$(".cb-navigate.right").show();
|
||||
}
|
||||
|
||||
// user callback
|
||||
if (typeof options.afterDrawPage === "function") {
|
||||
options.afterDrawPage(pointer + 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue