Merge remote-tracking branch 'Ganonmaster/master'

This commit is contained in:
Puzzlet Chung 2012-12-29 15:47:28 +09:00
commit d113b9d950
6 changed files with 99 additions and 53 deletions

View file

@ -7,6 +7,19 @@
.cb-control { .cb-control {
color: #fff; color: #fff;
background-color: #111; background-color: #111;
background-image: linear-gradient(bottom, rgb(17,17,17) 20%, rgb(41,41,41) 72%);
background-image: -o-linear-gradient(bottom, rgb(17,17,17) 20%, rgb(41,41,41) 72%);
background-image: -moz-linear-gradient(bottom, rgb(17,17,17) 20%, rgb(41,41,41) 72%);
background-image: -webkit-linear-gradient(bottom, rgb(17,17,17) 20%, rgb(41,41,41) 72%);
background-image: -ms-linear-gradient(bottom, rgb(17,17,17) 20%, rgb(41,41,41) 72%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.2, rgb(17,17,17)),
color-stop(0.72, rgb(41,41,41))
);
padding: 10px; padding: 10px;
position: fixed !important; position: fixed !important;
-webkit-box-shadow: 0 0 4px #000; -webkit-box-shadow: 0 0 4px #000;
@ -94,7 +107,7 @@
#cb-toolbar { #cb-toolbar {
top: 0; top: 0;
border-bottom: 2px solid #444; border-bottom: 1px solid #888;
} }
#cb-toolbar button { #cb-toolbar button {
@ -129,6 +142,12 @@
#cb-toolbar button.cb-fit-width:hover { background-position: -24px -48px } #cb-toolbar button.cb-fit-width:hover { background-position: -24px -48px }
#cb-toolbar button.cb-fit-width[disabled=disabled] { background-position: -48px -48px } #cb-toolbar button.cb-fit-width[disabled=disabled] { background-position: -48px -48px }
#cb-toolbar button.cb-read-direction#toleft{ background-position: 0 -144px }
#cb-toolbar button.cb-read-direction:hover#toleft{ background-position: -24px -144px }
#cb-toolbar button.cb-read-direction#toright{ background-position: 0 -168px }
#cb-toolbar button.cb-read-direction:hover#toright { background-position: -24px -168px }
#cb-color { #cb-color {
width: 246px; width: 246px;
top: 44px; top: 44px;

View file

@ -6,7 +6,11 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<script src="../lib/ComicBook.min.js"></script> <script src="../lib/ComicBook.js"></script>
<script src="../lib/pixastic/pixastic.core.js"></script>
<script src="../lib/pixastic/actions/brightness.js"></script>
<script src="../lib/pixastic/actions/desaturate.js"></script>
<script src="../lib/pixastic/actions/brightness.js"></script>
<link rel="stylesheet" href="../css/reset.css"> <link rel="stylesheet" href="../css/reset.css">
<link rel="stylesheet" href="../css/Aristo/css/Aristo/Aristo.css"> <link rel="stylesheet" href="../css/Aristo/css/Aristo/Aristo.css">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Before After
Before After

Binary file not shown.

View file

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

58
lib/ComicBook.min.js vendored
View file

@ -1,39 +1,23 @@
var Pixastic=function(){function c(a,g,o){a.addEventListener?a.addEventListener(g,o,!1):a.attachEvent&&a.attachEvent("on"+g,o)}function b(a){var g=!1,o=function(){g||(g=!0,a())};document.write('<script defer src="//:" id="__onload_ie_pixastic__"><\/script>');var e=document.getElementById("__onload_ie_pixastic__");e.onreadystatechange=function(){e.readyState=="complete"&&(e.parentNode.removeChild(e),o())};document.addEventListener&&document.addEventListener("DOMContentLoaded",o,!1);c(window,"load", function merge(j,d){var i;typeof d==="undefined"&&(d={});for(i in j)j.hasOwnProperty(i)&&!(i in d)&&(d[i]=j[i]);return d}var ComicBookException={INVALID_PAGE:"invalid page",INVALID_PAGE_TYPE:"invalid page type",UNDEFINED_CONTROL:"undefined control",INVALID_ZOOM_MODE:"invalid zoom mode",INVALID_NAVIGATION_EVENT:"invalid navigation event"};
o)}function k(){for(var a=d("pixastic",null,"img"),g=d("pixastic",null,"canvas"),o=a.concat(g),e=0;e<o.length;e++)(function(){for(var a=o[e],f=[],g=a.className.split(" "),b=0;b<g.length;b++){var d=g[b];d.substring(0,9)=="pixastic-"&&(d=d.substring(9),d!=""&&f.push(d))}if(f.length)if(a.tagName.toLowerCase()=="img")if(g=new Image,g.src=a.src,g.complete)for(g=0;g<f.length;g++)(b=Pixastic.applyAction(a,a,f[g],null))&&(a=b);else g.onload=function(){for(var e=0;e<f.length;e++){var g=Pixastic.applyAction(a, function ComicBook(j,d,i){function m(){var a=window.innerHeight+1;p===!1&&(p=$(document.createElement("div")).attr("id","cb-width-shiv").css({width:"100%",position:"absolute",top:0,zIndex:"-1000"}),$("body").append(p));p.height(a);return p.innerWidth()}function x(){var a=t();a!==c&&l.indexOf(a)>-1&&(c=a,ComicBook.prototype.draw())}function t(){var a=parseInt(location.hash.substring(1),10)-1||0;if(a<0)a=location.hash=0;return a}function s(){f=document.getElementById(y);u=f.getContext("2d");v===!1&&
a,f[e],null);g&&(a=g)}};else setTimeout(function(){for(var e=0;e<f.length;e++){var g=Pixastic.applyAction(a,a,f[e],null);g&&(a=g)}},1)})()}function d(a,g,b){var e=[];g==null&&(g=document);b==null&&(b="*");g=g.getElementsByTagName(b);b=g.length;a=RegExp("(^|\\s)"+a+"(\\s|$)");for(i=0,j=0;i<b;i++)a.test(g[i].className)&&(e[j]=g[i],j++);return e}function q(a,g){if(Pixastic.debug)try{switch(g){case "warn":console.warn("Pixastic:",a);break;case "error":console.error("Pixastic:",a);break;default:console.log("Pixastic:", (ComicBook.prototype.renderControls(),v=!0);f.addEventListener("click",ComicBook.prototype.navigation,!1);window.addEventListener("keydown",ComicBook.prototype.navigation,!1);window.addEventListener("hashchange",x,!1)}var y=j;this.srcs=d;var b=merge({displayMode:"double",zoomMode:"fitWidth",manga:!1,enhance:{},keyboard:{next:78,previous:80,toolbar:84,toggleLayout:76}},i),w=d.length,q=[],f,u,l=[],n=1,r=!1,v=!1,o=!1,p=!1,j=t(),c=j<d.length?j:0;ComicBook.prototype.control={status:$(document.createElement("div")).attr("id",
a)}}catch(b){}}typeof pixastic_parseonload!="undefined"&&pixastic_parseonload&&b(k);var n=function(){var a=document.createElement("canvas"),g=!1;try{g=!!(typeof a.getContext=="function"&&a.getContext("2d"))}catch(b){}return function(){return g}}(),h=function(){var a=document.createElement("canvas"),g=!1,b;try{if(typeof a.getContext=="function"&&(b=a.getContext("2d")))g=typeof b.getImageData=="function"}catch(e){}return function(){return g}}(),l=function(){var a=!1,g=document.createElement("canvas"); "cb-status").addClass("cb-control cb-always-on").append($(document.createElement("div")).attr("id","cb-progress-bar").progressbar()),toolbar:$(document.createElement("div")).attr("id","cb-toolbar").addClass("cb-control").append($(document.createElement("button")).attr("title","close the toolbar").addClass("cb-close").click(function(){ComicBook.prototype.toggleToolbar()})).append($(document.createElement("button")).attr("title","switch between dual and single page modes").addClass("cb-layout "+b.displayMode).click(function(){ComicBook.prototype.toggleLayout()})).append($(document.createElement("button")).attr("title",
if(n()&&h()){g.width=g.height=1;g=g.getContext("2d");g.fillStyle="rgb(255,0,0)";g.fillRect(0,0,1,1);var b=document.createElement("canvas");b.width=b.height=1;var e=b.getContext("2d");e.fillStyle="rgb(0,0,255)";e.fillRect(0,0,1,1);g.globalAlpha=0.5;g.drawImage(b,0,0);a=g.getImageData(0,0,1,1).data[2]!=255}return function(){return a}}();return{parseOnLoad:!1,debug:!1,applyAction:function(a,b,d,e){var e=e||{},c=a.tagName.toLowerCase()=="canvas";if(c&&Pixastic.Client.isIE())return Pixastic.debug&&q("Tried to process a canvas element but browser is IE."), "tweak the page colors").addClass("cb-color cb-menu-button").click(function(){ComicBook.prototype.toggleControl("color")})).append($(document.createElement("button")).attr("title","zoom out").addClass("cb-zoom-out").click(function(){ComicBook.prototype.zoom(n-0.1)})).append($(document.createElement("button")).attr("title","zoom in").addClass("cb-zoom-in").click(function(){ComicBook.prototype.zoom(n+0.1)})).append($(document.createElement("button")).attr("title","fit to page width").addClass("cb-fit-width").click(function(){b.zoomMode=
!1;var f,k,n=!1;Pixastic.Client.hasCanvas()&&(n=!!e.resultCanvas,f=e.resultCanvas||document.createElement("canvas"),k=f.getContext("2d"));var h=a.offsetWidth,l=a.offsetHeight;if(c)h=a.width,l=a.height;if(h==0||l==0)if(a.parentNode==null){var p=a.style.position,m=a.style.left;a.style.position="absolute";a.style.left="-9999px";document.body.appendChild(a);h=a.offsetWidth;l=a.offsetHeight;document.body.removeChild(a);a.style.position=p;a.style.left=m}else{Pixastic.debug&&q("Image has 0 width and/or height."); "fitWidth";ComicBook.prototype.drawPage()})).append($(document.createElement("button")).attr("title",b.manga==!0?"change reading direction to 'left-to-right'":"change reading direction to 'right-to-left'").addClass("cb-read-direction").click(function(){b.manga=!b.manga;ComicBook.prototype.drawPage()}).attr("id",b.manga==!0?"toright":"toleft")).append($(document.createElement("p")).attr("id","cb-comic-info").append("<span id='cb-current-page'></span> / "+d.length)),color:$(document.createElement("div")).attr("id",
return}if(d.indexOf("(")>-1&&(p=d,d=p.substr(0,p.indexOf("(")),p=p.match(/\((.*?)\)/),p[1])){p=p[1].split(";");for(m=0;m<p.length;m++)if(thisArg=p[m].split("="),thisArg.length==2)if(thisArg[0]=="rect"){var w=thisArg[1].split(",");e[thisArg[0]]={left:parseInt(w[0],10)||0,top:parseInt(w[1],10)||0,width:parseInt(w[2],10)||0,height:parseInt(w[3],10)||0}}else e[thisArg[0]]=thisArg[1]}e.rect?(e.rect.left=Math.round(e.rect.left),e.rect.top=Math.round(e.rect.top),e.rect.width=Math.round(e.rect.width),e.rect.height= "cb-color").addClass("cb-control").append("<label for='cb-sharpen'>Brightness</label>").append($("<div id='cb-brightness' class='cb-option'></div>").slider({value:0,step:10,min:-1E3,max:1E3,change:function(a,b){ComicBook.prototype.enhance.brightness({brightness:b.value})}})).append("<label for='cb-sharpen'>Contrast</label>").append($("<div id='cb-contrast' class='cb-option'></div>").slider({value:0,step:0.001,min:0,max:1,change:function(a,b){ComicBook.prototype.enhance.brightness({contrast:b.value})}})).append("<label for='cb-sharpen'>Sharpen</label>").append($("<div id='cb-sharpen' class='cb-option'></div>").slider({value:0,
Math.round(e.rect.height)):e.rect={left:0,top:0,width:h,height:l};p=!1;Pixastic.Actions[d]&&typeof Pixastic.Actions[d].process=="function"&&(p=!0);if(!p)return Pixastic.debug&&q('Invalid action "'+d+'". Maybe file not included?'),!1;if(!Pixastic.Actions[d].checkSupport())return Pixastic.debug&&q('Action "'+d+'" not supported by this browser.'),!1;if(Pixastic.Client.hasCanvas()){if(f!==a)f.width=h,f.height=l;if(!n)f.style.width=h+"px",f.style.height=l+"px";k.drawImage(b,0,0,h,l);a.__pixastic_org_image? step:0.001,min:0,max:1,change:function(a,b){ComicBook.prototype.enhance.sharpen({amount:b.value})}})).append($(document.createElement("div")).addClass("cb-option").append("<input type='checkbox' id='cb-desaturate' /> <label for='cb-desaturate'>Desaturate</label>").append("<button id='cb-reset'>reset</button>")),navigation:{left:$(document.createElement("div")).addClass("cb-control cb-navigate cb-always-on left").click(function(){b.manga==!1?ComicBook.prototype.drawPrevPage():ComicBook.prototype.drawNextPage()}),
(f.__pixastic_org_image=a.__pixastic_org_image,f.__pixastic_org_width=a.__pixastic_org_width,f.__pixastic_org_height=a.__pixastic_org_height):(f.__pixastic_org_image=a,f.__pixastic_org_width=h,f.__pixastic_org_height=l)}else if(Pixastic.Client.isIE()&&typeof a.__pixastic_org_style=="undefined")a.__pixastic_org_style=a.style.cssText;b={image:a,canvas:f,width:h,height:l,useData:!0,options:e};if(!Pixastic.Actions[d].process(b))return!1;if(Pixastic.Client.hasCanvas()){b.useData&&Pixastic.Client.hasCanvasImageData()&& right:$(document.createElement("div")).addClass("cb-control cb-navigate cb-always-on right").click(function(){b.manga==!1?ComicBook.prototype.drawNextPage():ComicBook.prototype.drawPrevPage()})},loadingOverlay:$(document.createElement("div")).attr("id","cb-loading-overlay").addClass("cb-control")};ComicBook.prototype.renderControls=function(){$(f).before(this.getControl("loadingOverlay")).before(this.getControl("status")).after(this.getControl("toolbar").hide()).after(this.getControl("navigation").left).after(this.getControl("navigation").right).after(this.getControl("color").hide());
(f.getContext("2d").putImageData(b.canvasData,e.rect.left,e.rect.top),f.getContext("2d").fillRect(0,0,0,0));if(!e.leaveDOM){f.title=a.title;f.imgsrc=a.imgsrc;if(!c)f.alt=a.alt;if(!c)f.imgsrc=a.src;f.className=a.className;f.style.cssText=a.style.cssText;f.name=a.name;f.tabIndex=a.tabIndex;f.id=a.id;a.parentNode&&a.parentNode.replaceChild&&a.parentNode.replaceChild(f,a)}return e.resultCanvas=f}return a},prepareData:function(a,b){var d=a.canvas.getContext("2d"),e=a.options.rect,d=d.getImageData(e.left,
e.top,e.width,e.height),e=d.data;if(!b)a.canvasData=d;return e},process:function(a,b,d,e){if(a.tagName.toLowerCase()=="img"){var c=new Image;c.src=a.src;if(c.complete){var f=Pixastic.applyAction(a,c,b,d);e&&e(f);return f}else c.onload=function(){var f=Pixastic.applyAction(a,c,b,d);e&&e(f)}}if(a.tagName.toLowerCase()=="canvas")return f=Pixastic.applyAction(a,a,b,d),e&&e(f),f},revert:function(a){if(Pixastic.Client.hasCanvas()){if(a.tagName.toLowerCase()=="canvas"&&a.__pixastic_org_image)return a.width=
a.__pixastic_org_width,a.height=a.__pixastic_org_height,a.getContext("2d").drawImage(a.__pixastic_org_image,0,0),a.parentNode&&a.parentNode.replaceChild&&a.parentNode.replaceChild(a.__pixastic_org_image,a),a}else if(Pixastic.Client.isIE()&&typeof a.__pixastic_org_style!="undefined")a.style.cssText=a.__pixastic_org_style},Client:{hasCanvas:n,hasCanvasImageData:h,hasGlobalAlpha:l,isIE:function(){return!!document.all&&!!window.attachEvent&&!window.opera}},Actions:{}}}();
Pixastic.Actions.brightness={process:function(c){var b=parseInt(c.options.brightness,10)||0,k=parseFloat(c.options.contrast)||0,d=!!(c.options.legacy&&c.options.legacy!="false");if(d)b=Math.min(150,Math.max(-150,b));else var q=1+Math.min(150,Math.max(-150,b))/150;k=Math.max(0,k+1);if(Pixastic.Client.hasCanvasImageData()){var n=Pixastic.prepareData(c),c=c.options.rect,c=c.width*c.height,h=c*4,l,a;k!=1?d?(d=k,b=(b-128)*k+128):(d=q*k,b=-k*128+128):d?d=1:(d=q,b=0);for(var g,o,e;c--;)n[h]=(g=n[h-=4]*d+
b)>255?255:g<0?0:g,n[l]=(o=n[l=h+1]*d+b)>255?255:o<0?0:o,n[a]=(e=n[a=h+2]*d+b)>255?255:e<0?0:e;return!0}},checkSupport:function(){return Pixastic.Client.hasCanvasImageData()}};
Pixastic.Actions.desaturate={process:function(c){var b=!!(c.options.average&&c.options.average!="false");if(Pixastic.Client.hasCanvasImageData()){var k=Pixastic.prepareData(c),c=c.options.rect,c=c.width*c.height,d=c*4,q,n;if(b)for(;c--;)k[d-=4]=k[q=d+1]=k[n=d+2]=(k[d]+k[q]+k[n])/3;else for(;c--;)k[d-=4]=k[q=d+1]=k[n=d+2]=k[d]*0.3+k[q]*0.59+k[n]*0.11;return!0}else if(Pixastic.Client.isIE())return c.image.style.filter+=" gray",!0},checkSupport:function(){return Pixastic.Client.hasCanvasImageData()||
Pixastic.Client.isIE()}};
Pixastic.Actions.sharpen={process:function(c){var b=0;typeof c.options.amount!="undefined"&&(b=parseFloat(c.options.amount)||0);b<0&&(b=0);b>1&&(b=1);if(Pixastic.Client.hasCanvasImageData()){for(var k=Pixastic.prepareData(c),d=Pixastic.prepareData(c,!0),q=15,b=1+3*b,n=[[0,-b,0],[-b,q,-b],[0,-b,0]],h=0,l=0;l<3;l++)for(var a=0;a<3;a++)h+=n[l][a];h=1/h;n=c.options.rect;c=n.width;n=n.height;q*=h;b*=h;h=c*4;l=n;do{var a=(l-1)*h,g=(l==1?0:l-2)*h,o=(l==n?l-1:l)*h,e=c;do{var r=a+(e*4-4),f=g+(e==1?0:e-2)*
4,s=o+(e==c?e-1:e)*4,t=(-d[f]-d[r-4]-d[r+4]-d[s])*b+d[r]*q,u=(-d[f+1]-d[r-3]-d[r+5]-d[s+1])*b+d[r+1]*q,f=(-d[f+2]-d[r-2]-d[r+6]-d[s+2])*b+d[r+2]*q;t<0&&(t=0);u<0&&(u=0);f<0&&(f=0);t>255&&(t=255);u>255&&(u=255);f>255&&(f=255);k[r]=t;k[r+1]=u;k[r+2]=f}while(--e)}while(--l);return!0}},checkSupport:function(){return Pixastic.Client.hasCanvasImageData()}};function merge(c,b){var k;typeof b==="undefined"&&(b={});for(k in c)c.hasOwnProperty(k)&&!(k in b)&&(b[k]=c[k]);return b}
var ComicBookException={INVALID_PAGE:"invalid page",INVALID_PAGE_TYPE:"invalid page type",UNDEFINED_CONTROL:"undefined control",INVALID_ZOOM_MODE:"invalid zoom mode",INVALID_NAVIGATION_EVENT:"invalid navigation event"};
function ComicBook(c,b,k){function d(){var a=window.innerHeight+1;p===!1&&(p=$(document.createElement("div")).attr("id","cb-width-shiv").css({width:"100%",position:"absolute",top:0,zIndex:"-1000"}),$("body").append(p));p.height(a);return p.innerWidth()}function q(){var a=n();a!==m&&f.indexOf(a)>-1&&(m=a,ComicBook.prototype.draw())}function n(){var a=parseInt(location.hash.substring(1),10)-1||0;if(a<0)a=location.hash=0;return a}function h(){e=document.getElementById(l);r=e.getContext("2d");u===!1&&
(ComicBook.prototype.renderControls(),u=!0);e.addEventListener("click",ComicBook.prototype.navigation,!1);window.addEventListener("keydown",ComicBook.prototype.navigation,!1);window.addEventListener("hashchange",q,!1)}var l=c;this.srcs=b;var a=merge({displayMode:"double",zoomMode:"fitWidth",manga:!1,enhance:{},keyboard:{next:78,previous:80,toolbar:84,toggleLayout:76}},k),g=b.length,o=[],e,r,f=[],s=1,t=!1,u=!1,v=!1,p=!1,c=n(),m=c<b.length?c:0;ComicBook.prototype.control={status:$(document.createElement("div")).attr("id",
"cb-status").addClass("cb-control cb-always-on").append($(document.createElement("div")).attr("id","cb-progress-bar").progressbar()),toolbar:$(document.createElement("div")).attr("id","cb-toolbar").addClass("cb-control").append($(document.createElement("button")).attr("title","close the toolbar").addClass("cb-close").click(function(){ComicBook.prototype.toggleToolbar()})).append($(document.createElement("button")).attr("title","switch between dual and single page modes").addClass("cb-layout "+a.displayMode).click(function(){ComicBook.prototype.toggleLayout()})).append($(document.createElement("button")).attr("title",
"tweak the page colors").addClass("cb-color cb-menu-button").click(function(){ComicBook.prototype.toggleControl("color")})).append($(document.createElement("button")).attr("title","zoom out").addClass("cb-zoom-out").click(function(){ComicBook.prototype.zoom(s-0.1)})).append($(document.createElement("button")).attr("title","zoom in").addClass("cb-zoom-in").click(function(){ComicBook.prototype.zoom(s+0.1)})).append($(document.createElement("button")).attr("title","fit to page width").addClass("cb-fit-width").click(function(){a.zoomMode=
"fitWidth";ComicBook.prototype.drawPage()})).append($(document.createElement("p")).attr("id","cb-comic-info").append("<span id='cb-current-page'></span> / "+b.length)),color:$(document.createElement("div")).attr("id","cb-color").addClass("cb-control").append("<label for='cb-sharpen'>Brightness</label>").append($("<div id='cb-brightness' class='cb-option'></div>").slider({value:0,step:10,min:-1E3,max:1E3,change:function(a,b){ComicBook.prototype.enhance.brightness({brightness:b.value})}})).append("<label for='cb-sharpen'>Contrast</label>").append($("<div id='cb-contrast' class='cb-option'></div>").slider({value:0,
step:0.0010,min:0,max:1,change:function(a,b){ComicBook.prototype.enhance.brightness({contrast:b.value})}})).append("<label for='cb-sharpen'>Sharpen</label>").append($("<div id='cb-sharpen' class='cb-option'></div>").slider({value:0,step:0.0010,min:0,max:1,change:function(a,b){ComicBook.prototype.enhance.sharpen({amount:b.value})}})).append($(document.createElement("div")).addClass("cb-option").append("<input type='checkbox' id='cb-desaturate' /> <label for='cb-desaturate'>Desaturate</label>").append("<button id='cb-reset'>reset</button>")),
navigation:{left:$(document.createElement("div")).addClass("cb-control cb-navigate cb-always-on left").click(function(){ComicBook.prototype.drawPrevPage()}),right:$(document.createElement("div")).addClass("cb-control cb-navigate cb-always-on right").click(function(){ComicBook.prototype.drawNextPage()})},loadingOverlay:$(document.createElement("div")).attr("id","cb-loading-overlay").addClass("cb-control")};ComicBook.prototype.renderControls=function(){$(e).before(this.getControl("loadingOverlay")).before(this.getControl("status")).after(this.getControl("toolbar").hide()).after(this.getControl("navigation").left).after(this.getControl("navigation").right).after(this.getControl("color").hide());
$(".cb-menu-button").click(function(){$(this).toggleClass("active")});$("#cb-desaturate").click(function(){$(this).is(":checked")?ComicBook.prototype.enhance.desaturate():ComicBook.prototype.enhance.resaturate()});$("#cb-reset").click(function(){$("#cb-brightness").slider("value",0);$("#cb-contrast").slider("value",0);$("#cb-saturation").slider("value",0);$("#cb-sharpen").slider("value",0);$("#cb-desaturate").attr("checked",!1);ComicBook.prototype.enhance.reset()})};ComicBook.prototype.getControl= $(".cb-menu-button").click(function(){$(this).toggleClass("active")});$("#cb-desaturate").click(function(){$(this).is(":checked")?ComicBook.prototype.enhance.desaturate():ComicBook.prototype.enhance.resaturate()});$("#cb-reset").click(function(){$("#cb-brightness").slider("value",0);$("#cb-contrast").slider("value",0);$("#cb-saturation").slider("value",0);$("#cb-sharpen").slider("value",0);$("#cb-desaturate").attr("checked",!1);ComicBook.prototype.enhance.reset()})};ComicBook.prototype.getControl=
function(a){if(typeof this.control[a]==="undefined")throw ComicBookException.UNDEFINED_CONTROL+" "+a;return this.control[a]};ComicBook.prototype.showControl=function(a){this.getControl(a).show().addClass("open")};ComicBook.prototype.hideControl=function(a){this.getControl(a).removeClass("open").hide()};ComicBook.prototype.toggleControl=function(a){this.getControl(a).toggle().toggleClass("open")};ComicBook.prototype.toggleToolbar=function(){$("#cb-toolbar").is(":visible")?$(".cb-control").not(".cb-always-on").hide(): function(a){if(typeof this.control[a]==="undefined")throw ComicBookException.UNDEFINED_CONTROL+" "+a;return this.control[a]};ComicBook.prototype.showControl=function(a){this.getControl(a).show().addClass("open")};ComicBook.prototype.hideControl=function(a){this.getControl(a).removeClass("open").hide()};ComicBook.prototype.toggleControl=function(a){this.getControl(a).toggle().toggleClass("open")};ComicBook.prototype.toggleToolbar=function(){$("#cb-toolbar").is(":visible")?$(".cb-control").not(".cb-always-on").hide():
$("#cb-toolbar, .cb-control.open").show()};ComicBook.prototype.toggleLayout=function(){a.displayMode==="double"?($("#cb-toolbar .cb-layout").removeClass("double"),a.displayMode="single"):($("#cb-toolbar .cb-layout").removeClass("single"),a.displayMode="double");$("#cb-toolbar .cb-layout").addClass(a.displayMode);ComicBook.prototype.drawPage()};ComicBook.prototype.getPage=function(a){if(a<0||a>b.length-1)throw ComicBookException.INVALID_PAGE+" "+a;if(typeof o[a]==="object")return o[a];else v=a,this.showControl("loadingOverlay")}; $("#cb-toolbar, .cb-control.open").show()};ComicBook.prototype.toggleLayout=function(){b.displayMode==="double"?($("#cb-toolbar .cb-layout").removeClass("double"),b.displayMode="single"):($("#cb-toolbar .cb-layout").removeClass("single"),b.displayMode="double");$("#cb-toolbar .cb-layout").addClass(b.displayMode);ComicBook.prototype.drawPage()};ComicBook.prototype.getPage=function(a){if(a<0||a>d.length-1)throw ComicBookException.INVALID_PAGE+" "+a;if(typeof q[a]==="object")return q[a];else o=a,this.showControl("loadingOverlay")};
ComicBook.prototype.draw=function(){h();$(".cb-control.cb-navigate").outerHeight(window.innerHeight);$("#cb-toolbar").outerWidth(d());$("#cb-loading-overlay").outerWidth(d()).height(window.innerHeight);o.length!==g?this.preload():this.drawPage()};ComicBook.prototype.zoom=function(b){a.zoomMode="manual";s=b;typeof this.getPage(m)==="object"&&this.drawPage()};ComicBook.prototype.preload=function(){function e(d){var h=new Image;h.src=b[d];h.onload=function(){o[d]=this;f.push(d);$("#cb-progress-bar").progressbar("value", ComicBook.prototype.draw=function(){s();$(".cb-control.cb-navigate").outerHeight(window.innerHeight);$("#cb-toolbar").outerWidth(m());$("#cb-loading-overlay").outerWidth(m()).height(window.innerHeight);q.length!==w?this.preload():this.drawPage()};ComicBook.prototype.zoom=function(a){b.zoomMode="manual";n=a;typeof this.getPage(c)==="object"&&this.drawPage()};ComicBook.prototype.preload=function(){function a(e){var g=new Image;g.src=d[e];g.onload=function(){q[e]=this;l.push(e);$("#cb-progress-bar").progressbar("value",
Math.floor(f.length/g*100));var h=a.displayMode==="double"&&m<b.length-1?1:0;if(c===!1&&$.inArray(m+h,f)!==-1||typeof v==="number"&&$.inArray(v,f)!==-1)typeof v==="number"&&(m=v-1,v=!1),ComicBook.prototype.drawPage(),ComicBook.prototype.hideControl("loadingOverlay"),c=!0;k.length?(e(k[0]),k.splice(0,1)):$("#cb-status").delay(500).fadeOut()}}var d=m,c=!1,k=[];this.showControl("loadingOverlay");(function(a,b){for(var d=1,f=a,c=a-1;f<=b;)d>3&&c>-1?(k.push(c),c--,d=0):(k.push(f),f++),d++;for(;c>-1;)k.push(c), Math.floor(l.length/w*100));var g=b.displayMode==="double"&&c<d.length-1?1:0;if(h===!1&&$.inArray(c+g,l)!==-1||typeof o==="number"&&$.inArray(o,l)!==-1)typeof o==="number"&&(c=o-1,o=!1),ComicBook.prototype.drawPage(),ComicBook.prototype.hideControl("loadingOverlay"),h=!0;f.length?(a(f[0]),f.splice(0,1)):$("#cb-status").delay(500).fadeOut()}}var e=c,h=!1,f=[];this.showControl("loadingOverlay");(function(b,c){for(var e=1,d=b,h=b-1;d<=c;)e>3&&h>-1?(f.push(h),h--,e=0):(f.push(d),d++),e++;for(;h>-1;)f.push(h),
c--;e(k[0])})(d,b.length-1)};ComicBook.prototype.pageLoaded=function(a){return typeof f[a-1]!=="undefined"};ComicBook.prototype.drawPage=function(c){if(typeof c==="number"&&c<b.length&&c>0&&(m=c-1,!this.pageLoaded(c))){this.showControl("loadingOverlay");return}m<0&&(m=0);var f,g=0,k=0,h=ComicBook.prototype.getPage(m),c=!1;a.displayMode==="double"&&m<b.length-1&&(c=ComicBook.prototype.getPage(m+1));if(typeof h!=="object")throw ComicBookException.INVALID_PAGE_TYPE+" "+typeof h;var l=h.width;e.width= h--;a(f[0])})(e,d.length-1)};ComicBook.prototype.pageLoaded=function(a){return typeof l[a-1]!=="undefined"};ComicBook.prototype.drawPage=function(a){if(typeof a==="number"&&a<d.length&&a>0&&(c=a-1,!this.pageLoaded(a))){this.showControl("loadingOverlay");return}c<0&&(c=0);var e,h=0,j=0,k=ComicBook.prototype.getPage(c),a=!1;b.displayMode==="double"&&c<d.length-1&&(a=ComicBook.prototype.getPage(c+1));if(typeof k!=="object")throw ComicBookException.INVALID_PAGE_TYPE+" "+typeof k;var g=k.width;f.width=
0;e.height=0;if(t=typeof c==="object"&&(h.width>h.height||c.width>c.height)&&a.displayMode==="double")a.displayMode="single";a.displayMode==="double"&&(l+=typeof c==="object"?c.width:l);switch(a.zoomMode){case "manual":document.body.style.overflowX="auto";f=a.displayMode==="double"?s*2:s;break;case "fitWidth":document.body.style.overflowX="hidden";s=f=d()>l?(d()-l)/d()+1:d()/l;break;default:throw ComicBookException.INVALID_ZOOM_MODE+" "+a.zoomMode;}var l=h.width*f,o=h.height*f;f=a.zoomMode==="manual"? 0;f.height=0;if(r=typeof a==="object"&&(k.width>k.height||a.width>a.height)&&b.displayMode==="double")b.displayMode="single";b.displayMode==="double"&&(g+=typeof a==="object"?a.width:g);switch(b.zoomMode){case "manual":document.body.style.overflowX="auto";e=b.displayMode==="double"?n*2:n;break;case "fitWidth":document.body.style.overflowX="hidden";n=e=m()>g?(m()-g)/m()+1:m()/g;break;default:throw ComicBookException.INVALID_ZOOM_MODE+" "+b.zoomMode;}var g=k.width*e,i=k.height*e;e=b.zoomMode==="manual"?
h.width*s:l;var p=a.zoomMode==="manual"?h.height*s:o,o=p;e.width=l<d()?d():l;e.height=o<window.innerHeight?window.innerHeight:o;l<d()&&a.zoomMode==="manual"&&(g=(d()-f)/2,a.displayMode==="double"&&(g-=f/2));o<window.innerHeight&&a.zoomMode==="manual"&&(k=(window.innerHeight-p)/2);a.manga&&a.displayMode==="double"&&typeof c==="object"&&(l=h,h=c,c=l);r.drawImage(h,g,k,f,p);a.displayMode==="double"&&typeof c==="object"&&r.drawImage(c,f+g,k,f,p);$.each(a.enhance,function(a,b){ComicBook.prototype.enhance[a](b)}); k.width*n:g;var l=b.zoomMode==="manual"?k.height*n:i,i=l;f.width=g<m()?m():g;f.height=i<window.innerHeight?window.innerHeight:i;g<m()&&b.zoomMode==="manual"&&(h=(m()-e)/2,b.displayMode==="double"&&(h-=e/2));i<window.innerHeight&&b.zoomMode==="manual"&&(j=(window.innerHeight-l)/2);b.manga&&b.displayMode==="double"&&typeof a==="object"&&(g=k,k=a,a=g);u.drawImage(k,h,j,e,l);b.displayMode==="double"&&typeof a==="object"&&u.drawImage(a,e+h,j,e,l);$.each(b.enhance,function(a,b){ComicBook.prototype.enhance[a](b)});
g=a.displayMode==="double"&&m+2<=b.length?m+1+"-"+(m+2):m+1;$("#cb-current-page").text(g);if(t)a.displayMode="double";$("button.cb-fit-width").attr("disabled",a.zoomMode==="fitWidth");$(".cb-navigate").show();m===0&&($(".cb-navigate.left").hide(),$(".cb-navigate.right").show());if(m===b.length-1||typeof c==="object"&&m===b.length-2)$(".cb-navigate.left").show(),$(".cb-navigate.right").hide();typeof a.afterDrawPage==="function"&&a.afterDrawPage(m+1);if(n()!==m)location.hash=m+1;window.scroll(0,0)}; h=b.displayMode==="double"&&c+2<=d.length?c+1+"-"+(c+2):c+1;$("#cb-current-page").text(h);if(r)b.displayMode="double";$("button.cb-fit-width").attr("disabled",b.zoomMode==="fitWidth");b.manga==!0?$("button.cb-read-direction").attr("id","toright"):$("button.cb-read-direction").attr("id","toleft");$(".cb-navigate").show();c===0&&b.manga==!1?($(".cb-navigate.left").hide(),$(".cb-navigate.right").show()):c===0&&b.manga==!0&&($(".cb-navigate.left").show(),$(".cb-navigate.right").hide());if((c===d.length-
ComicBook.prototype.drawNextPage=function(){var b;try{b=this.getPage(m+1)}catch(c){}if(!b)return!1;if(m+1<o.length){m+=a.displayMode==="single"||t?1:2;try{this.drawPage()}catch(e){}}};ComicBook.prototype.drawPrevPage=function(){var b;try{b=this.getPage(m-1)}catch(c){}if(!b)return!1;t=b.width>b.height;m>0&&(m-=a.displayMode==="single"||t?1:2,this.drawPage())};ComicBook.prototype.enhance={reset:function(b){b?delete a.enhance[b]:a.enhance={};ComicBook.prototype.drawPage()},brightness:function(b,c){c!== 1||typeof a==="object"&&c===d.length-2)&&b.manga==!1)$(".cb-navigate.left").show(),$(".cb-navigate.right").hide();else if((c===d.length-1||typeof a==="object"&&c===d.length-2)&&b.manga==!0)$(".cb-navigate.left").hide(),$(".cb-navigate.right").show();typeof b.afterDrawPage==="function"&&b.afterDrawPage(c+1);if(t()!==c)location.hash=c+1;window.scroll(0,0)};ComicBook.prototype.drawNextPage=function(){var a;try{a=this.getPage(c+1)}catch(e){}if(!a)return!1;if(c+1<q.length){c+=b.displayMode==="single"||
!1&&this.reset("brightness");var d=merge({brightness:0,contrast:0},b);a.enhance.brightness=d;Pixastic.process(e,"brightness",{brightness:d.brightness,contrast:d.contrast,legacy:!0});h()},desaturate:function(){a.enhance.desaturate={};Pixastic.process(e,"desaturate",{average:!1});h()},resaturate:function(){delete a.enhance.desaturate;ComicBook.prototype.drawPage()},sharpen:function(b){this.desharpen();b=merge({amount:0},b);a.enhance.sharpen=b;Pixastic.process(e,"sharpen",{amount:b.amount});h()},desharpen:function(){delete a.enhance.sharpen; r?1:2;try{this.drawPage()}catch(d){}}};ComicBook.prototype.drawPrevPage=function(){var a;try{a=this.getPage(c-1)}catch(e){}if(!a)return!1;r=a.width>a.height;c>0&&(c-=b.displayMode==="single"||r?1:2,this.drawPage())};ComicBook.prototype.enhance={reset:function(a){a?delete b.enhance[a]:b.enhance={};ComicBook.prototype.drawPage()},brightness:function(a,c){c!==!1&&this.reset("brightness");var d=merge({brightness:0,contrast:0},a);b.enhance.brightness=d;Pixastic.process(f,"brightness",{brightness:d.brightness,
ComicBook.prototype.drawPage()}};ComicBook.prototype.navigation=function(b){if($("#cb-loading-overlay").is(":visible"))return!1;var c=!1;switch(b.type){case "click":ComicBook.prototype.toggleToolbar();break;case "keydown":b.keyCode===a.keyboard.previous&&(c="left");b.keyCode===a.keyboard.next&&(c="right");b.keyCode===a.keyboard.toolbar&&ComicBook.prototype.toggleToolbar();b.keyCode===a.keyboard.toggleLayout&&ComicBook.prototype.toggleLayout();break;default:throw ComicBookException.INVALID_NAVIGATION_EVENT+ contrast:d.contrast,legacy:!0});s()},desaturate:function(){b.enhance.desaturate={};Pixastic.process(f,"desaturate",{average:!1});s()},resaturate:function(){delete b.enhance.desaturate;ComicBook.prototype.drawPage()},sharpen:function(a){this.desharpen();a=merge({amount:0},a);b.enhance.sharpen=a;Pixastic.process(f,"sharpen",{amount:a.amount});s()},desharpen:function(){delete b.enhance.sharpen;ComicBook.prototype.drawPage()}};ComicBook.prototype.navigation=function(a){if($("#cb-loading-overlay").is(":visible"))return!1;
" "+b.type;}if(c)return b.stopPropagation(),a.manga?(c==="left"&&ComicBook.prototype.drawNextPage(),c==="right"&&ComicBook.prototype.drawPrevPage()):(c==="left"&&ComicBook.prototype.drawPrevPage(),c==="right"&&ComicBook.prototype.drawNextPage()),!1}}; var c=!1;switch(a.type){case "click":ComicBook.prototype.toggleToolbar();break;case "keydown":a.keyCode===b.keyboard.previous&&(c="left");a.keyCode===b.keyboard.next&&(c="right");a.keyCode===b.keyboard.toolbar&&ComicBook.prototype.toggleToolbar();a.keyCode===b.keyboard.toggleLayout&&ComicBook.prototype.toggleLayout();break;default:throw ComicBookException.INVALID_NAVIGATION_EVENT+" "+a.type;}if(c)return a.stopPropagation(),b.manga?(c==="left"&&ComicBook.prototype.drawNextPage(),c==="right"&&ComicBook.prototype.drawPrevPage()):
(c==="left"&&ComicBook.prototype.drawPrevPage(),c==="right"&&ComicBook.prototype.drawNextPage()),!1}};