disable the strech button if in an auto zoom mode
This commit is contained in:
parent
f049aa9899
commit
81a5dc907f
3 changed files with 36 additions and 33 deletions
|
@ -105,7 +105,8 @@
|
|||
background-position-x: -24px;
|
||||
}
|
||||
|
||||
#cb-toolbar button.disabled {
|
||||
#cb-toolbar button[disabled=disabled] {
|
||||
cursor: auto;
|
||||
background-position-x: -48px;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
]
|
||||
);
|
||||
book.draw();
|
||||
|
||||
|
||||
window.onresize = book.drawPage;
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
Fo sho:
|
||||
- fix last page loading bug
|
||||
- disable the strech button if in an auto zoom mode
|
||||
- improve prev/next buttons, only show them when they can possibly work (not at beginning/end)
|
||||
- check for html5 feature support where used: diveintohtml5.org/everything.html or www.modernizr.com
|
||||
- write bin scripts to minify & join all js
|
||||
|
@ -103,24 +102,24 @@ function ComicBook(id, srcs, opts) {
|
|||
* Gets the window.innerWidth - scrollbars
|
||||
*/
|
||||
function windowWidth() {
|
||||
|
||||
|
||||
var height = window.innerHeight + 1;
|
||||
|
||||
|
||||
if (shiv === false) {
|
||||
shiv = $(document.createElement("div"))
|
||||
.attr("id", "cb-width-shiv")
|
||||
.css({
|
||||
width: "100%",
|
||||
position: "absolute",
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
zIndex: "-1000"
|
||||
});
|
||||
|
||||
|
||||
$("body").append(shiv);
|
||||
}
|
||||
|
||||
|
||||
shiv.height(height);
|
||||
|
||||
|
||||
return shiv.innerWidth();
|
||||
}
|
||||
|
||||
|
@ -311,7 +310,7 @@ function ComicBook(id, srcs, opts) {
|
|||
ComicBook.prototype.drawNextPage();
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
loadingOverlay: $(document.createElement("div"))
|
||||
.attr("id", "cb-loading-overlay")
|
||||
.addClass("cb-control")
|
||||
|
@ -321,7 +320,7 @@ function ComicBook(id, srcs, opts) {
|
|||
* TODO: center, make sure they never leave the visible portion of the screen
|
||||
*/
|
||||
ComicBook.prototype.renderControls = function() {
|
||||
|
||||
|
||||
$(canvas)
|
||||
.before(this.getControl("loadingOverlay"))
|
||||
.before(this.getControl("status"))
|
||||
|
@ -329,11 +328,11 @@ function ComicBook(id, srcs, opts) {
|
|||
.after(this.getControl("navigation").left)
|
||||
.after(this.getControl("navigation").right)
|
||||
.after(this.getControl("color").hide());
|
||||
|
||||
|
||||
$(".cb-menu-button").click(function(e) {
|
||||
$(this).toggleClass("active");
|
||||
});
|
||||
|
||||
|
||||
$("#cb-desaturate").click(function(){
|
||||
if ($(this).is(":checked")) {
|
||||
ComicBook.prototype.enhance.desaturate();
|
||||
|
@ -401,11 +400,11 @@ function ComicBook(id, srcs, opts) {
|
|||
* @return Image
|
||||
*/
|
||||
ComicBook.prototype.getPage = function(i) {
|
||||
|
||||
|
||||
if (i < 0 || i > srcs.length) {
|
||||
throw new ComicBookException(ComicBookException.INVALID_PAGE, i);
|
||||
}
|
||||
|
||||
|
||||
if (typeof pages[i] === "object") {
|
||||
return pages[i];
|
||||
} else {
|
||||
|
@ -425,7 +424,7 @@ function ComicBook(id, srcs, opts) {
|
|||
$(".cb-control.cb-navigate").outerHeight(window.innerHeight);
|
||||
$("#cb-toolbar").outerWidth(windowWidth());
|
||||
$("#cb-loading-overlay").outerWidth(windowWidth()).height(window.innerHeight);
|
||||
|
||||
|
||||
// preload images if needed
|
||||
if (pages.length !== no_pages) {
|
||||
this.preload();
|
||||
|
@ -451,7 +450,7 @@ function ComicBook(id, srcs, opts) {
|
|||
* @see #drawPage
|
||||
*/
|
||||
ComicBook.prototype.preload = function () {
|
||||
|
||||
|
||||
this.showControl("loadingOverlay");
|
||||
|
||||
//var srcs = this.srcs;
|
||||
|
@ -492,16 +491,16 @@ function ComicBook(id, srcs, opts) {
|
|||
|
||||
// double page mode needs an extra page added to the buffer
|
||||
padding = (options.displayMode === "double") ? 1 : 0;
|
||||
|
||||
|
||||
// start rendering the comic when the buffer level has been reached (FIXME: buggy, fails if trying to load the last couple of pages)
|
||||
if (loaded[loaded.length-1] === pointer + buffer + padding || loaded[loaded.length-1] === page_requested) {
|
||||
|
||||
|
||||
// if the user is waiting for a page to be loaded, render that one instead of the default pointer
|
||||
if (typeof page_requested === "number") {
|
||||
pointer = page_requested-1;
|
||||
page_requested = false;
|
||||
}
|
||||
|
||||
|
||||
ComicBook.prototype.drawPage();
|
||||
ComicBook.prototype.hideControl("loadingOverlay");
|
||||
}
|
||||
|
@ -512,7 +511,7 @@ function ComicBook(id, srcs, opts) {
|
|||
// manually trigger the first load
|
||||
preload(i);
|
||||
};
|
||||
|
||||
|
||||
ComicBook.prototype.pageLoaded = function (page_no) {
|
||||
return (typeof loaded[page_no-1] !== "undefined");
|
||||
};
|
||||
|
@ -521,9 +520,9 @@ function ComicBook(id, srcs, opts) {
|
|||
* Draw the current page in the canvas
|
||||
*/
|
||||
ComicBook.prototype.drawPage = function(page_no) {
|
||||
|
||||
|
||||
// if a specific page is given try to render it, if not bail and wait for preload() to render it
|
||||
if (typeof page_no === "number" && page_no < srcs.length) {
|
||||
if (typeof page_no === "number" && page_no < srcs.length) {
|
||||
pointer = page_no-1;
|
||||
if (!this.pageLoaded(page_no)) {
|
||||
this.showControl("loadingOverlay");
|
||||
|
@ -546,7 +545,7 @@ function ComicBook(id, srcs, opts) {
|
|||
// reset the canvas to stop duplicate pages showing
|
||||
canvas.width = 0;
|
||||
canvas.height = 0;
|
||||
|
||||
|
||||
// show double page spreads on a single page
|
||||
is_double_page_spread = ((page.width > page.height || page2.width > page2.height) && options.displayMode === "double");
|
||||
if (is_double_page_spread) { options.displayMode = "single"; }
|
||||
|
@ -570,7 +569,7 @@ function ComicBook(id, srcs, opts) {
|
|||
|
||||
case "fitWidth":
|
||||
document.body.style.overflowX = "hidden";
|
||||
|
||||
|
||||
zoom_scale = (windowWidth() > width)
|
||||
? ((windowWidth() - width) / windowWidth()) + 1 // scale up if the window is wider than the page
|
||||
: windowWidth() / width; // scale down if the window is narrower than the page
|
||||
|
@ -629,6 +628,9 @@ function ComicBook(id, srcs, opts) {
|
|||
// revert page mode back to double if it was auto switched for a double page spread
|
||||
if (is_double_page_spread) { options.displayMode = "double"; }
|
||||
|
||||
// disable the fit width button if needed
|
||||
$("button.cb-fit-width").attr("disabled", (options.zoomMode === "fitWidth"));
|
||||
|
||||
// user callback
|
||||
if (typeof options.afterDrawPage === "function") {
|
||||
options.afterDrawPage(pointer + 1);
|
||||
|
@ -638,7 +640,7 @@ function ComicBook(id, srcs, opts) {
|
|||
if (getHash() !== pointer) {
|
||||
setHash(pointer + 1);
|
||||
}
|
||||
|
||||
|
||||
// make sure the top of the page is in view
|
||||
window.scroll(0, 0);
|
||||
};
|
||||
|
@ -649,9 +651,9 @@ function ComicBook(id, srcs, opts) {
|
|||
* @see #drawPage
|
||||
*/
|
||||
ComicBook.prototype.drawNextPage = function () {
|
||||
|
||||
|
||||
if (!this.getPage(pointer+1)) { return false; }
|
||||
|
||||
|
||||
if (pointer + 1 < pages.length) {
|
||||
pointer += (options.displayMode === "single" || is_double_page_spread) ? 1 : 2;
|
||||
this.drawPage();
|
||||
|
@ -664,10 +666,10 @@ function ComicBook(id, srcs, opts) {
|
|||
* @see #drawPage
|
||||
*/
|
||||
ComicBook.prototype.drawPrevPage = function () {
|
||||
|
||||
var page = this.getPage(pointer-1);
|
||||
|
||||
var page = this.getPage(pointer-1);
|
||||
if (!page) { return false; }
|
||||
|
||||
|
||||
is_double_page_spread = (page.width > page.height); // need to run double page check again here as we are going backwards
|
||||
|
||||
if (pointer > 0) {
|
||||
|
@ -793,7 +795,7 @@ function ComicBook(id, srcs, opts) {
|
|||
ComicBook.prototype.toggleToolbar();
|
||||
break;
|
||||
case "keydown":
|
||||
|
||||
|
||||
// navigation
|
||||
if (e.keyCode === options.keyboard.previous) { side = "left"; }
|
||||
if (e.keyCode === options.keyboard.next) { side = "right"; }
|
||||
|
@ -830,5 +832,5 @@ function ComicBook(id, srcs, opts) {
|
|||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue