diff --git a/lib/ComicBook.js b/lib/ComicBook.js index 879ca19..ec62bfe 100755 --- a/lib/ComicBook.js +++ b/lib/ComicBook.js @@ -65,6 +65,7 @@ var ComicBookException = { function ComicBook(id, srcs, opts) { + var self = this; var canvas_id = id; // canvas element id this.srcs = srcs; // array of image srcs for pages @@ -128,7 +129,7 @@ function ComicBook(id, srcs, opts) { if (hash !== pointer && loaded.indexOf(hash) > -1) { pointer = hash; - ComicBook.prototype.draw(); + self.draw(); } } @@ -164,14 +165,14 @@ function ComicBook(id, srcs, opts) { // render user controls if (controlsRendered === false) { - ComicBook.prototype.renderControls(); + self.renderControls(); controlsRendered = true; } // add page controls // TODO: add IE event listeners too. - canvas.addEventListener("click", ComicBook.prototype.navigation, false); - window.addEventListener("keydown", ComicBook.prototype.navigation, false); + canvas.addEventListener("click", self.navigation, false); + window.addEventListener("keydown", self.navigation, false); window.addEventListener("hashchange", checkHash, false); //setInterval(function() { checkHash(); }, 300); // TODO: enable this when there is no onhashchange event } @@ -200,7 +201,7 @@ function ComicBook(id, srcs, opts) { .attr("title", "close the toolbar") .addClass("cb-close") .click(function(){ - ComicBook.prototype.toggleToolbar(); + self.toggleToolbar(); }) ) .append( @@ -208,7 +209,7 @@ function ComicBook(id, srcs, opts) { .attr("title", "switch between dual and single page modes") .addClass("cb-layout " + options.displayMode) .click(function(){ - ComicBook.prototype.toggleLayout(); + self.toggleLayout(); }) ) .append( @@ -216,7 +217,7 @@ function ComicBook(id, srcs, opts) { .attr("title", "tweak the page colors") .addClass("cb-color cb-menu-button") .click(function(){ - ComicBook.prototype.toggleControl("color"); + self.toggleControl("color"); }) ) .append( @@ -224,7 +225,7 @@ function ComicBook(id, srcs, opts) { .attr("title", "zoom out") .addClass("cb-zoom-out") .click(function(){ - ComicBook.prototype.zoom(scale - 0.1); + self.zoom(scale - 0.1); }) ) .append( @@ -232,7 +233,7 @@ function ComicBook(id, srcs, opts) { .attr("title", "zoom in") .addClass("cb-zoom-in") .click(function(){ - ComicBook.prototype.zoom(scale + 0.1); + self.zoom(scale + 0.1); }) ) .append( @@ -241,7 +242,7 @@ function ComicBook(id, srcs, opts) { .addClass("cb-fit-width") .click(function(){ options.zoomMode = "fitWidth" - ComicBook.prototype.drawPage(); + self.drawPage(); }) ) .append( @@ -264,7 +265,7 @@ function ComicBook(id, srcs, opts) { min: -1000, max: 1000, change: function(event, ui) { - ComicBook.prototype.enhance.brightness({ brightness: ui.value }); + self.enhance.brightness({ brightness: ui.value }); } }) ) @@ -276,7 +277,7 @@ function ComicBook(id, srcs, opts) { min: 0, max: 1, change: function(event, ui) { - ComicBook.prototype.enhance.brightness({ contrast: ui.value }); + self.enhance.brightness({ contrast: ui.value }); } }) ) @@ -288,7 +289,7 @@ function ComicBook(id, srcs, opts) { min: 0, max: 1, change: function(event, ui) { - ComicBook.prototype.enhance.sharpen({ amount: ui.value }); + self.enhance.sharpen({ amount: ui.value }); } }) ) @@ -306,13 +307,13 @@ function ComicBook(id, srcs, opts) { left: $(document.createElement("div")) .addClass("cb-control cb-navigate cb-always-on left") .click(function(e){ - ComicBook.prototype.drawPrevPage(); + self.drawPrevPage(); }), right: $(document.createElement("div")) .addClass("cb-control cb-navigate cb-always-on right") .click(function(e) { - ComicBook.prototype.drawNextPage(); + self.drawNextPage(); }) }, @@ -337,9 +338,9 @@ function ComicBook(id, srcs, opts) { $("#cb-desaturate").click(function(){ if ($(this).is(":checked")) { - ComicBook.prototype.enhance.desaturate(); + self.enhance.desaturate(); } else { - ComicBook.prototype.enhance.resaturate(); + self.enhance.resaturate(); } }); @@ -351,7 +352,7 @@ function ComicBook(id, srcs, opts) { $("#cb-sharpen").slider("value", 0); var desaturate = $("#cb-desaturate"); desaturate.attr("checked", false); - ComicBook.prototype.enhance.reset(); + self.enhance.reset(); }); }; @@ -393,7 +394,7 @@ function ComicBook(id, srcs, opts) { options.displayMode = "double"; } $("#cb-toolbar .cb-layout").addClass(options.displayMode); - ComicBook.prototype.drawPage(); + self.drawPage(); }; /** @@ -485,8 +486,8 @@ function ComicBook(id, srcs, opts) { page_requested = false; } - ComicBook.prototype.drawPage(); - ComicBook.prototype.hideControl("loadingOverlay"); + self.drawPage(); + self.hideControl("loadingOverlay"); rendered = true; } @@ -560,11 +561,11 @@ function ComicBook(id, srcs, opts) { var zoom_scale; var offsetW = 0, offsetH = 0; - var page = ComicBook.prototype.getPage(pointer); + var page = self.getPage(pointer); var page2 = false; if (options.displayMode === "double" && pointer < srcs.length-1) { - page2 = ComicBook.prototype.getPage(pointer + 1); + page2 = self.getPage(pointer + 1); } if (typeof page !== "object") { @@ -656,7 +657,7 @@ function ComicBook(id, srcs, opts) { // apply any image enhancements previously defined $.each(options.enhance, function(action, options) { - ComicBook.prototype.enhance[action](options); + self.enhance[action](options); }); var current_page = (options.displayMode === "double" && pointer+2 <= srcs.length) @@ -764,7 +765,7 @@ function ComicBook(id, srcs, opts) { } else { delete options.enhance[method]; } - ComicBook.prototype.drawPage(null, false); + self.drawPage(null, false); }, /** @@ -814,7 +815,7 @@ function ComicBook(id, srcs, opts) { */ resaturate: function() { delete options.enhance.desaturate; - ComicBook.prototype.drawPage(null, false); + self.drawPage(null, false); }, /** @@ -842,7 +843,7 @@ function ComicBook(id, srcs, opts) { desharpen: function() { delete options.enhance.sharpen; - ComicBook.prototype.drawPage(null, false); + self.drawPage(null, false); } }; @@ -855,7 +856,7 @@ function ComicBook(id, srcs, opts) { switch (e.type) { case "click": - ComicBook.prototype.toggleToolbar(); + self.toggleToolbar(); break; case "keydown": @@ -865,10 +866,10 @@ function ComicBook(id, srcs, opts) { // display controls if (e.keyCode === options.keyboard.toolbar) { - ComicBook.prototype.toggleToolbar(); + self.toggleToolbar(); } if (e.keyCode === options.keyboard.toggleLayout) { - ComicBook.prototype.toggleLayout(); + self.toggleLayout(); } break; default: @@ -881,13 +882,13 @@ function ComicBook(id, srcs, opts) { // western style (left to right) if (!options.manga) { - if (side === "left") { ComicBook.prototype.drawPrevPage(); } - if (side === "right") { ComicBook.prototype.drawNextPage(); } + if (side === "left") { self.drawPrevPage(); } + if (side === "right") { self.drawNextPage(); } } // manga style (right to left) else { - if (side === "left") { ComicBook.prototype.drawNextPage(); } - if (side === "right") { ComicBook.prototype.drawPrevPage(); } + if (side === "left") { self.drawNextPage(); } + if (side === "right") { self.drawPrevPage(); } } return false; @@ -899,7 +900,7 @@ function ComicBook(id, srcs, opts) { $("#cb-loading-overlay, #cb-status, #cb-color, .cb-control, .cb-toolbar, #cb-width-shiv").remove(); canvas.width = 0; canvas.height = 0; - window.removeEventListener("keydown", ComicBook.prototype.navigation, false); + window.removeEventListener("keydown", self.navigation, false); window.removeEventListener("hashchange", checkHash, false); setHash(''); diff --git a/lib/ComicBook.min.js b/lib/ComicBook.min.js index 7d3c040..e72c20d 100644 --- a/lib/ComicBook.min.js +++ b/lib/ComicBook.min.js @@ -1,40 +1,39 @@ -var Pixastic=function(){function e(a,g,m){a.addEventListener?a.addEventListener(g,m,!1):a.attachEvent&&a.attachEvent("on"+g,m)}function c(a){var g=!1,m=function(){g||(g=!0,a())};document.write('