started working on the toolbar, added buttons for layout switching, enhancements, zoom

This commit is contained in:
Bala Clark 2011-09-01 00:13:16 +02:00
parent 7dec54b89d
commit d6ca6736ca
2 changed files with 57 additions and 5 deletions

View file

@ -176,6 +176,39 @@ function ComicBook(id, srcs, opts) {
* TODO: save current values
*/
ComicBook.prototype.control = {
toolbar: $(document.createElement("div"))
.attr("id", "cb-toolbar")
.addClass("cb-control")
.append(
$(document.createElement("button"))
.text("layout")
.addClass(options.displayMode)
.click(function(){
ComicBook.prototype.toggleLayout();
})
)
.append(
$(document.createElement("button"))
.text("enhance")
.click(function(){
ComicBook.prototype.toggleControl("color");
})
)
.append(
$(document.createElement("button"))
.text("zoom out")
.click(function(){
ComicBook.prototype.zoom(scale - 0.1);
})
)
.append(
$(document.createElement("button"))
.text("zoom in")
.click(function(){
ComicBook.prototype.zoom(scale + 0.1);
})
),
/**
* Image enhancements
@ -287,7 +320,7 @@ function ComicBook(id, srcs, opts) {
ComicBook.prototype.hideControl = function(control) {
this.getControl(control).hide();
}
};
ComicBook.prototype.toggleControl = function(control) {
if (this.getControl(control).is(":visible")) {
@ -295,8 +328,17 @@ function ComicBook(id, srcs, opts) {
} else {
this.showControl(control);
}
}
};
ComicBook.prototype.toggleLayout = function() {
if (options.displayMode === "double") {
options.displayMode = "single";
} else {
options.displayMode = "double";
}
ComicBook.prototype.draw();
};
/**
* Get the image for a given page.
*
@ -495,6 +537,7 @@ function ComicBook(id, srcs, opts) {
// resize navigation controls
$(".cb-control.cb-navigate").height(window.innerHeight);
$("#cb-toolbar").width(window.innerWidth);
// user callback
if (typeof options.afterDrawPage === "function") {