removed built in ajax page saving, added an optional user callback function instead
This commit is contained in:
parent
6981172789
commit
affa4dc418
1 changed files with 10 additions and 14 deletions
|
@ -47,7 +47,6 @@ function ComicBook(id, srcs, opts) {
|
||||||
displayMode: "double", // single / double
|
displayMode: "double", // single / double
|
||||||
zoomMode: "fitWidth", // manual / fitWidth
|
zoomMode: "fitWidth", // manual / fitWidth
|
||||||
manga: false, // true / false
|
manga: false, // true / false
|
||||||
savePosition: true, // true / false
|
|
||||||
enhance: {},
|
enhance: {},
|
||||||
keyboard: {
|
keyboard: {
|
||||||
next: 78,
|
next: 78,
|
||||||
|
@ -88,7 +87,6 @@ function ComicBook(id, srcs, opts) {
|
||||||
|
|
||||||
function setHash(pageNo) {
|
function setHash(pageNo) {
|
||||||
location.hash = pageNo;
|
location.hash = pageNo;
|
||||||
if (options.savePosition === true) { setLastPage(pageNo); };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,14 +112,6 @@ function ComicBook(id, srcs, opts) {
|
||||||
return (x <= canvas.width / 2) ? 'left' : 'right';
|
return (x <= canvas.width / 2) ? 'left' : 'right';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tell the library app where the user is up to
|
|
||||||
*/
|
|
||||||
function setLastPage(pageNo) {
|
|
||||||
if (!options.data.comicId) { throw 'options.data.comicId is not set.'; }
|
|
||||||
$.post('/comic/setlastpage', { page: pageNo, comic: options.data.comicId });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the canvas element for use throughout the class.
|
* Setup the canvas element for use throughout the class.
|
||||||
*
|
*
|
||||||
|
@ -325,10 +315,6 @@ function ComicBook(id, srcs, opts) {
|
||||||
context.drawImage(page, offsetW, offsetH, page_width, page_height);
|
context.drawImage(page, offsetW, offsetH, page_width, page_height);
|
||||||
if (options.displayMode === "double" && typeof page2 === "object") { context.drawImage(page2, page_width + offsetW, offsetH, page_width, page_height); }
|
if (options.displayMode === "double" && typeof page2 === "object") { context.drawImage(page2, page_width + offsetW, offsetH, page_width, page_height); }
|
||||||
|
|
||||||
if (getHash() !== pointer) {
|
|
||||||
setHash(pointer + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply any image enhancements previously defined
|
// apply any image enhancements previously defined
|
||||||
$.each(options.enhance, function(action, options) {
|
$.each(options.enhance, function(action, options) {
|
||||||
ComicBook.prototype.enhance[action](options);
|
ComicBook.prototype.enhance[action](options);
|
||||||
|
@ -336,6 +322,16 @@ function ComicBook(id, srcs, opts) {
|
||||||
|
|
||||||
// revert page mode back to double if it was auto switched for a double page spread
|
// revert page mode back to double if it was auto switched for a double page spread
|
||||||
if (is_double_page_spread) { options.displayMode = "double"; }
|
if (is_double_page_spread) { options.displayMode = "double"; }
|
||||||
|
|
||||||
|
// user callback
|
||||||
|
if (typeof options.afterDrawPage === "function") {
|
||||||
|
options.afterDrawPage(pointer + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update hash location
|
||||||
|
if (getHash() !== pointer) {
|
||||||
|
setHash(pointer + 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue