From 0cfaa9cf2e891e6e13d35ebcddf5ce662e6342ce Mon Sep 17 00:00:00 2001 From: Fred Chasen Date: Sun, 30 Jun 2013 23:32:39 -0700 Subject: [PATCH] Fixed typo and built --- build/epub.js | 34 ++++++++++++++++++++++++---------- build/hooks.js | 2 +- build/reader.js | 2 +- demo/js/epub.min.js | 2 +- src/book.js | 1 - src/renderer.js | 2 +- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/build/epub.js b/build/epub.js index 6bb3424..ec20da8 100644 --- a/build/epub.js +++ b/build/epub.js @@ -1,4 +1,4 @@ -/*! FuturePress - v0.1.0 - 2013-06-25 */ +/*! FuturePress - v0.1.0 - 2013-06-30 */ var EPUBJS = EPUBJS || {}; EPUBJS.VERSION = "0.1.5"; @@ -592,17 +592,18 @@ EPUBJS.Book.prototype.fromStorage = function(stored) { */ EPUBJS.Book.prototype.setStyle = function(style, val, prefixed) { - this.renderer.style(style, val, prefixed); + this.renderer.setStyle(style, val, prefixed); this.settings.styles[style] = val; } -EPUBJS.Book.prototype.applyStyles = function() { - for (style in this.settings.styles) { - this.setStyle(style, this.settings.styles[style]); - } +EPUBJS.Book.prototype.removeStyle = function(style, val, prefixed) { + this.renderer.removeStyle(style); + + delete this.settings.styles[style] = ''; } + //-- Get pre-registered hooks EPUBJS.Book.prototype.getHooks = function(){ var book = this, @@ -1605,8 +1606,6 @@ EPUBJS.Renderer.prototype.crossBrowserColumnCss = function(){ } - - EPUBJS.Renderer.prototype.setIframeSrc = function(url){ var renderer = this, promise = new RSVP.Promise(); @@ -1621,6 +1620,8 @@ EPUBJS.Renderer.prototype.setIframeSrc = function(url){ renderer.docEl = renderer.doc.documentElement; renderer.bodyEl = renderer.doc.body; + renderer.applyStyles(); + renderer.formatSpread(); //-- Trigger registered hooks before displaying @@ -1725,12 +1726,25 @@ EPUBJS.Renderer.prototype.fixedLayout = function(){ this.displayedPages = 1; } -EPUBJS.Renderer.prototype.style = function(style, val, prefixed){ +EPUBJS.Renderer.prototype.setStyle = function(style, val, prefixed){ if(prefixed) { style = EPUBJS.core.prefixed(style); } - this.bodyEl.style[style] = val; + if(this.bodyEl) this.bodyEl.style[style] = val; +} + +EPUBJS.Renderer.prototype.removeStyle = function(style){ + + if(this.bodyEl) this.bodyEl.style[style] = ''; + +} + +EPUBJS.Renderer.prototype.applyStyles = function() { + var styles = this.book.settings.styles; + for (style in styles) { + this.setStyle(style, styles[style]); + } } EPUBJS.Renderer.prototype.gotoChapterEnd = function(){ diff --git a/build/hooks.js b/build/hooks.js index 7107a0e..f1340f8 100644 --- a/build/hooks.js +++ b/build/hooks.js @@ -1,4 +1,4 @@ -/*! FuturePress - v0.1.0 - 2013-06-25 */ +/*! FuturePress - v0.1.0 - 2013-06-30 */ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chapter){ diff --git a/build/reader.js b/build/reader.js index ba3172d..020ba0a 100644 --- a/build/reader.js +++ b/build/reader.js @@ -1,4 +1,4 @@ -/*! FuturePress - v0.1.0 - 2013-06-25 */ +/*! FuturePress - v0.1.0 - 2013-06-30 */ var EPUBJSR = EPUBJSR || {}; diff --git a/demo/js/epub.min.js b/demo/js/epub.min.js index 56539b7..72cad63 100644 --- a/demo/js/epub.min.js +++ b/demo/js/epub.min.js @@ -1 +1 @@ -(function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=i.toString,l=i.hasOwnProperty,c=r.forEach,h=r.map,p=r.reduce,d=r.reduceRight,v=r.filter,m=r.every,g=r.some,y=r.indexOf,b=r.lastIndexOf,w=Array.isArray,E=Object.keys,S=s.bind,x=function(e){return e instanceof x?e:this instanceof x?(this._wrapped=e,void 0):new x(e)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=x),exports._=x):e._=x,x.VERSION="1.4.4";var T=x.each=x.forEach=function(e,t,r){if(null!=e)if(c&&e.forEach===c)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;s>i;i++)if(t.call(r,e[i],i,e)===n)return}else for(var o in e)if(x.has(e,o)&&t.call(r,e[o],o,e)===n)return};x.map=x.collect=function(e,t,n){var r=[];return null==e?r:h&&e.map===h?e.map(t,n):(T(e,function(e,i,s){r[r.length]=t.call(n,e,i,s)}),r)};var N="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(e,t,n,r){var i=arguments.length>2;if(null==e&&(e=[]),p&&e.reduce===p)return r&&(t=x.bind(t,r)),i?e.reduce(t,n):e.reduce(t);if(T(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)}),!i)throw new TypeError(N);return n},x.reduceRight=x.foldr=function(e,t,n,r){var i=arguments.length>2;if(null==e&&(e=[]),d&&e.reduceRight===d)return r&&(t=x.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=x.keys(e);s=o.length}if(T(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)}),!i)throw new TypeError(N);return n},x.find=x.detect=function(e,t,n){var r;return C(e,function(e,i,s){return t.call(n,e,i,s)?(r=e,!0):void 0}),r},x.filter=x.select=function(e,t,n){var r=[];return null==e?r:v&&e.filter===v?e.filter(t,n):(T(e,function(e,i,s){t.call(n,e,i,s)&&(r[r.length]=e)}),r)},x.reject=function(e,t,n){return x.filter(e,function(e,r,i){return!t.call(n,e,r,i)},n)},x.every=x.all=function(e,t,r){t||(t=x.identity);var i=!0;return null==e?i:m&&e.every===m?e.every(t,r):(T(e,function(e,s,o){return(i=i&&t.call(r,e,s,o))?void 0:n}),!!i)};var C=x.some=x.any=function(e,t,r){t||(t=x.identity);var i=!1;return null==e?i:g&&e.some===g?e.some(t,r):(T(e,function(e,s,o){return i||(i=t.call(r,e,s,o))?n:void 0}),!!i)};x.contains=x.include=function(e,t){return null==e?!1:y&&e.indexOf===y?e.indexOf(t)!=-1:C(e,function(e){return e===t})},x.invoke=function(e,t){var n=u.call(arguments,2),r=x.isFunction(t);return x.map(e,function(e){return(r?t:e[t]).apply(e,n)})},x.pluck=function(e,t){return x.map(e,function(e){return e[t]})},x.where=function(e,t,n){return x.isEmpty(t)?n?null:[]:x[n?"find":"filter"](e,function(e){for(var n in t)if(t[n]!==e[n])return!1;return!0})},x.findWhere=function(e,t){return x.where(e,t,!0)},x.max=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.max.apply(Math,e);if(!t&&x.isEmpty(e))return-1/0;var r={computed:-1/0,value:-1/0};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},x.min=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.min.apply(Math,e);if(!t&&x.isEmpty(e))return 1/0;var r={computed:1/0,value:1/0};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;r.computed>o&&(r={value:e,computed:o})}),r.value},x.shuffle=function(e){var t,n=0,r=[];return T(e,function(e){t=x.random(n++),r[n-1]=r[t],r[t]=e}),r};var k=function(e){return x.isFunction(e)?e:function(t){return t[e]}};x.sortBy=function(e,t,n){var r=k(t);return x.pluck(x.map(e,function(e,t,i){return{value:e,index:t,criteria:r.call(n,e,t,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(r>n||r===void 0)return-1}return e.indexs;){var u=s+o>>>1;i>n.call(r,e[u])?s=u+1:o=u}return s},x.toArray=function(e){return e?x.isArray(e)?u.call(e):e.length===+e.length?x.map(e,x.identity):x.values(e):[]},x.size=function(e){return null==e?0:e.length===+e.length?e.length:x.keys(e).length},x.first=x.head=x.take=function(e,t,n){return null==e?void 0:null==t||n?e[0]:u.call(e,0,t)},x.initial=function(e,t,n){return u.call(e,0,e.length-(null==t||n?1:t))},x.last=function(e,t,n){return null==e?void 0:null==t||n?e[e.length-1]:u.call(e,Math.max(e.length-t,0))},x.rest=x.tail=x.drop=function(e,t,n){return u.call(e,null==t||n?1:t)},x.compact=function(e){return x.filter(e,x.identity)};var A=function(e,t,n){return T(e,function(e){x.isArray(e)?t?o.apply(n,e):A(e,t,n):n.push(e)}),n};x.flatten=function(e,t){return A(e,t,[])},x.without=function(e){return x.difference(e,u.call(arguments,1))},x.uniq=x.unique=function(e,t,n,r){x.isFunction(t)&&(r=n,n=t,t=!1);var i=n?x.map(e,n,r):e,s=[],o=[];return T(i,function(n,r){(t?r&&o[o.length-1]===n:x.contains(o,n))||(o.push(n),s.push(e[r]))}),s},x.union=function(){return x.uniq(a.apply(r,arguments))},x.intersection=function(e){var t=u.call(arguments,1);return x.filter(x.uniq(e),function(e){return x.every(t,function(t){return x.indexOf(t,e)>=0})})},x.difference=function(e){var t=a.apply(r,u.call(arguments,1));return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){for(var e=u.call(arguments),t=x.max(x.pluck(e,"length")),n=Array(t),r=0;t>r;r++)n[r]=x.pluck(e,""+r);return n},x.object=function(e,t){if(null==e)return{};for(var n={},r=0,i=e.length;i>r;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},x.indexOf=function(e,t,n){if(null==e)return-1;var r=0,i=e.length;if(n){if("number"!=typeof n)return r=x.sortedIndex(e,t),e[r]===t?r:-1;r=0>n?Math.max(0,i+n):n}if(y&&e.indexOf===y)return e.indexOf(t,n);for(;i>r;r++)if(e[r]===t)return r;return-1},x.lastIndexOf=function(e,t,n){if(null==e)return-1;var r=null!=n;if(b&&e.lastIndexOf===b)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);for(var i=r?n:e.length;i--;)if(e[i]===t)return i;return-1},x.range=function(e,t,n){1>=arguments.length&&(t=e||0,e=0),n=arguments[2]||1;for(var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=Array(r);r>i;)s[i++]=e,e+=n;return s},x.bind=function(e,t){if(e.bind===S&&S)return S.apply(e,u.call(arguments,1));var n=u.call(arguments,2);return function(){return e.apply(t,n.concat(u.call(arguments)))}},x.partial=function(e){var t=u.call(arguments,1);return function(){return e.apply(this,t.concat(u.call(arguments)))}},x.bindAll=function(e){var t=u.call(arguments,1);return 0===t.length&&(t=x.functions(e)),T(t,function(t){e[t]=x.bind(e[t],e)}),e},x.memoize=function(e,t){var n={};return t||(t=x.identity),function(){var r=t.apply(this,arguments);return x.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},x.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},x.defer=function(e){return x.delay.apply(x,[e,1].concat(u.call(arguments,1)))},x.throttle=function(e,t){var n,r,i,s,o=0,u=function(){o=new Date,i=null,s=e.apply(n,r)};return function(){var a=new Date,f=t-(a-o);return n=this,r=arguments,0>=f?(clearTimeout(i),i=null,o=a,s=e.apply(n,r)):i||(i=setTimeout(u,f)),s}},x.debounce=function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},x.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},x.wrap=function(e,t){return function(){var n=[e];return o.apply(n,arguments),t.apply(this,n)}},x.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},x.after=function(e,t){return 0>=e?t():function(){return 1>--e?t.apply(this,arguments):void 0}},x.keys=E||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)x.has(e,n)&&(t[t.length]=n);return t},x.values=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push(e[n]);return t},x.pairs=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push([n,e[n]]);return t},x.invert=function(e){var t={};for(var n in e)x.has(e,n)&&(t[e[n]]=n);return t},x.functions=x.methods=function(e){var t=[];for(var n in e)x.isFunction(e[n])&&t.push(n);return t.sort()},x.extend=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]=t[n]}),e},x.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return T(n,function(n){n in e&&(t[n]=e[n])}),t},x.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)x.contains(n,i)||(t[i]=e[i]);return t},x.defaults=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)null==e[n]&&(e[n]=t[n])}),e},x.clone=function(e){return x.isObject(e)?x.isArray(e)?e.slice():x.extend({},e):e},x.tap=function(e,t){return t(e),e};var O=function(e,t,n,r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;e instanceof x&&(e=e._wrapped),t instanceof x&&(t=t._wrapped);var i=f.call(e);if(i!=f.call(t))return!1;switch(i){case"[object String]":return e==t+"";case"[object Number]":return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return!1;for(var s=n.length;s--;)if(n[s]==e)return r[s]==t;n.push(e),r.push(t);var o=0,u=!0;if("[object Array]"==i){if(o=e.length,u=o==t.length)for(;o--&&(u=O(e[o],t[o],n,r)););}else{var a=e.constructor,l=t.constructor;if(a!==l&&!(x.isFunction(a)&&a instanceof a&&x.isFunction(l)&&l instanceof l))return!1;for(var c in e)if(x.has(e,c)&&(o++,!(u=x.has(t,c)&&O(e[c],t[c],n,r))))break;if(u){for(c in t)if(x.has(t,c)&&!(o--))break;u=!o}}return n.pop(),r.pop(),u};x.isEqual=function(e,t){return O(e,t,[],[])},x.isEmpty=function(e){if(null==e)return!0;if(x.isArray(e)||x.isString(e))return 0===e.length;for(var t in e)if(x.has(e,t))return!1;return!0},x.isElement=function(e){return!!e&&1===e.nodeType},x.isArray=w||function(e){return"[object Array]"==f.call(e)},x.isObject=function(e){return e===Object(e)},T(["Arguments","Function","String","Number","Date","RegExp"],function(e){x["is"+e]=function(t){return f.call(t)=="[object "+e+"]"}}),x.isArguments(arguments)||(x.isArguments=function(e){return!!e&&!!x.has(e,"callee")}),"function"!=typeof /./&&(x.isFunction=function(e){return"function"==typeof e}),x.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},x.isNaN=function(e){return x.isNumber(e)&&e!=+e},x.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"==f.call(e)},x.isNull=function(e){return null===e},x.isUndefined=function(e){return e===void 0},x.has=function(e,t){return l.call(e,t)},x.noConflict=function(){return e._=t,this},x.identity=function(e){return e},x.times=function(e,t,n){for(var r=Array(e),i=0;e>i;i++)r[i]=t.call(n,i);return r},x.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=x.invert(M.escape);var _={escape:RegExp("["+x.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+x.keys(M.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(e){x[e]=function(t){return null==t?"":(""+t).replace(_[e],function(t){return M[e][t]})}}),x.result=function(e,t){if(null==e)return null;var n=e[t];return x.isFunction(n)?n.call(e):n},x.mixin=function(e){T(x.functions(e),function(t){var n=x[t]=e[t];x.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),j.call(this,n.apply(x,e))}})};var D=0;x.uniqueId=function(e){var t=++D+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var P=/(.)^/,H={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(e,t,n){var r;n=x.defaults({},n,x.templateSettings);var i=RegExp([(n.escape||P).source,(n.interpolate||P).source,(n.evaluate||P).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(B,function(e){return"\\"+H[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,x);var a=function(e){return r.call(this,e,x)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},x.chain=function(e){return x(e).chain()};var j=function(e){return this._chain?x(e).chain():e};x.mixin(x),T(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];x.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!=e&&"splice"!=e||0!==n.length||delete n[0],j.call(this,n)}}),T(["concat","join","slice"],function(e){var t=r[e];x.prototype[e]=function(){return j.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this),function(e){"use strict";function t(e,t){s.async(function(){e.trigger("promise:resolved",{detail:t}),e.isResolved=!0,e.resolvedValue=t})}function n(e,t){s.async(function(){e.trigger("promise:failed",{detail:t}),e.isRejected=!0,e.rejectedValue=t})}function r(e){var t,n=[],r=new m,i=e.length;i===0&&r.resolve([]);var s=function(e){return function(t){o(e,t)}},o=function(e,t){n[e]=t,--i===0&&r.resolve(n)},u=function(e){r.reject(e)};for(t=0;t=this.spine.length?!1:s<0?!1:(this.spinePos=s,this.chapter=new EPUBJS.Chapter(this.spine[s]),r=n.render.chapter(this.chapter),i?r.then(function(t){t.currentLocationCfi=e,t.gotoCfiFragment(i)}):t&&r.then(function(e){e.gotoChapterEnd()}),this.settings.storage||r.then(function(){n.preloadNextChapter()}),r)},EPUBJS.Book.prototype.nextPage=function(){var e=this.render.nextPage();if(!e)return this.nextChapter()},EPUBJS.Book.prototype.prevPage=function(){var e=this.render.prevPage();if(!e)return this.prevChapter()},EPUBJS.Book.prototype.nextChapter=function(){return this.spinePos++,this.displayChapter(this.spinePos)},EPUBJS.Book.prototype.prevChapter=function(){return this.spinePos--,this.displayChapter(this.spinePos,!0)},EPUBJS.Book.prototype.goto=function(e){var t=e.split("#"),n=t[0],r=t[1]||!1,i=n.search("://")==-1?this.settings.contentsPath+n:n,s=this.spineIndexByURL[i],o;return n||(s=this.chapter.spinePos),typeof s!="number"?!1:s!=this.chapter.spinePos||!this.chapter?this.displayChapter(s).then(function(){r&&o.render.section(r)}):(r&&this.render.section(r),(new RSVP.Promise).resolve(this.currentChapter))},EPUBJS.Book.prototype.preloadNextChapter=function(){var e=document.createElement("iframe");next;if(this.spinePos>=this.spine.length)return!1;next=new EPUBJS.Chapter(this.spine[this.spinePos+1]),EPUBJS.core.request(next.href)},EPUBJS.Book.prototype.storeOffline=function(){var e=this,t=_.values(this.manifest);return EPUBJS.storage.batch(t).then(function(){e.settings.stored=!0,e.trigger("book:stored")})},EPUBJS.Book.prototype.availableOffline=function(){return this.settings.stored>0?!0:!1},EPUBJS.Book.prototype.setStyle=function(e,t,n){this.renderer.style(e,t,n),this.settings.styles[e]=t},EPUBJS.Book.prototype.applyStyles=function(){for(style in this.settings.styles)this.setStyle(style,this.settings.styles[style])},EPUBJS.Book.prototype.getHooks=function(){var e=this,t;plugTypes=_.values(this.hooks);for(plugType in this.hooks)t=_.values(EPUBJS.Hooks[plugType]),t.forEach(function(t){e.registerHook(plugType,t)})},EPUBJS.Book.prototype.registerHook=function(e,t){var n=this;typeof this.hooks[e]!="undefined"?typeof t=="function"?this.hooks[e].push(t):Array.isArray(t)&&t.forEach(function(t){n.hooks[e].push(t)}):this.hooks[e]=[func]},EPUBJS.Book.prototype.triggerHooks=function(e,t,n){function s(){i--,i<=0&&t&&t()}var r,i;if(typeof this.hooks[e]=="undefined")return!1;r=this.hooks[e],i=r.length,r.forEach(function(e){e(s,n)})},RSVP.EventTarget.mixin(EPUBJS.Book.prototype),EPUBJS.Chapter=function(e){this.href=e.href,this.id=e.id,this.spinePos=e.index,this.properties=e.properties,this.linear=e.linear,this.pages=1},EPUBJS.Chapter.prototype.contents=function(e){return e?e.get(href):EPUBJS.core.request(href,"xml")},EPUBJS.Chapter.prototype.url=function(e){var t=new RSVP.Promise;return e?e.getUrl(href):(t.resolve(this.href),t)},EPUBJS.Chapter.prototype.setPages=function(e){this.pages=e},EPUBJS.Chapter.prototype.getPages=function(e){return this.pages},EPUBJS.Chapter.prototype.getID=function(){return this.ID};var EPUBJS=EPUBJS||{};EPUBJS.core={},EPUBJS.core.getEl=function(e){return document.getElementById(e)},EPUBJS.core.getEls=function(e){return document.getElementsByClassName(e)},EPUBJS.core.request=function(e,t){function i(){if(this.readyState===this.DONE)if(this.status===200){var e;t=="xml"?e=this.responseXML:t=="json"?e=JSON.parse(this.response):e=this.response,n.resolve(e)}else n.reject(this)}var n=new RSVP.Promise,r=new XMLHttpRequest;return r.open("GET",e),r.onreadystatechange=i,t=="blob"&&(r.responseType=t),t=="json"&&r.setRequestHeader("Accept","application/json"),t=="xml"&&r.overrideMimeType("text/xml"),r.send(),n},EPUBJS.core.toArray=function(e){var t=[];for(member in e){var n;e.hasOwnProperty(member)&&(n=e[member],n.ident=member,t.push(n))}return t},EPUBJS.core.folder=function(e){var t=e.lastIndexOf("/"),n=e.slice(0,t+1);return n},EPUBJS.core.dataURLToBlob=function(e){var t=";base64,";if(e.indexOf(t)==-1){var n=e.split(","),r=n[0].split(":")[1],i=n[1];return new Blob([i],{type:r})}var n=e.split(t),r=n[0].split(":")[1],i=window.atob(n[1]),s=i.length,o=new Uint8Array(s);for(var u=0;u0)u=n.shift(),u.id?r=e.doc.querySelector("#"+u.id):(r=i[u.index],i||console.error("No Kids",r)),r||console.error("No Element For",u),i=Array.prototype.slice.call(r.children);return r},EPUBJS.Events=function(e,t){return this.events={},t?this.el=t:this.el=document.createElement("div"),e.createEvent=this.createEvent,e.tell=this.tell,e.listen=this.listen,e.deafen=this.deafen,e.listenUntil=this.listenUntil,this},EPUBJS.Events.prototype.createEvent=function(e){var t=new CustomEvent(e);return this.events[e]=t,t},EPUBJS.Events.prototype.tell=function(e,t){var n;this.events[e]?n=this.events[e]:(console.warn("No event:",e,"defined yet, creating."),n=this.createEvent(e)),t&&(n.msg=t),this.el.dispatchEvent(n)},EPUBJS.Events.prototype.listen=function(e,t,n){if(!this.events[e]){console.warn("No event:",e,"defined yet, creating."),this.createEvent(e);return}n?this.el.addEventListener(e,t.bind(n),!1):this.el.addEventListener(e,t,!1)},EPUBJS.Events.prototype.deafen=function(e,t){this.el.removeEventListener(e,t,!1)},EPUBJS.Events.prototype.listenUntil=function(e,t,n,r){function i(){this.deafen(e,n),this.deafen(t,i)}this.listen(e,n,r),this.listen(t,i,this)},EPUBJS.Hooks=function(){"use strict";return{register:function(e){this[e]===undefined&&(this[e]={});if(typeof this[e]!="object")throw"Already registered: "+e;return this[e]}}}(),EPUBJS.Parser=function(e){this.baseUrl=e||""},EPUBJS.Parser.prototype.container=function(e){var t=e.querySelector("rootfile"),n=t.getAttribute("full-path"),r=EPUBJS.core.folder(n);return{packagePath:n,basePath:r}},EPUBJS.Parser.prototype.package=function(e,t){var n=this;t&&(this.baseUrl=t);var r=e.querySelector("metadata"),i=e.querySelector("manifest"),s=e.querySelector("spine"),o=n.manifest(i),u=n.findTocPath(i),a=n.findCoverPath(i),f=Array.prototype.indexOf.call(s.parentNode.childNodes,s),l=n.spine(s,o),c={};return l.forEach(function(e){c[e.href]=e.index}),{metadata:n.metadata(r),spine:l,manifest:o,tocPath:u,coverPath:a,spineNodeIndex:f,spineIndexByURL:c}},EPUBJS.Parser.prototype.findTocPath=function(e){var t=e.querySelector("item[media-type='application/x-dtbncx+xml']");return t.getAttribute("href")},EPUBJS.Parser.prototype.findCoverPath=function(e){var t=e.querySelector("item[properties='cover-image']");return t.getAttribute("href")},EPUBJS.Parser.prototype.metadata=function(e){var t={},n=this;return t.bookTitle=n.getElement(e,"title"),t.creator=n.getElement(e,"creator"),t.description=n.getElement(e,"description"),t.pubdate=n.getElement(e,"date"),t.publisher=n.getElement(e,"publisher"),t.identifier=n.getElement(e,"identifier"),t.language=n.getElement(e,"language"),t.rights=n.getElement(e,"rights"),t.modified_date=n.querySelector(e,"meta[property='dcterms:modified']"),t.layout=n.querySelector(e,"meta[property='rendition:orientation']"),t.orientation=n.querySelector(e,"meta[property='rendition:orientation']"),t.spread=n.querySelector(e,"meta[property='rendition:spread']"),t},EPUBJS.Parser.prototype.getElement=function(e,t){var n=e.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",t),r;return n?(r=n[0],r?r.childNodes[0].nodeValue:""):""},EPUBJS.Parser.prototype.querySelector=function(e,t){var n=e.querySelector(t);return n?n.childNodes[0].nodeValue:""},EPUBJS.Parser.prototype.manifest=function(e){var t=this.baseUrl,n={},r=e.querySelectorAll("item"),i=Array.prototype.slice.call(r);return i.forEach(function(e){var r=e.getAttribute("id"),i=e.getAttribute("href")||"",s=e.getAttribute("media-type")||"";n[r]={href:t+i,type:s}}),n},EPUBJS.Parser.prototype.spine=function(e,t){var n=[],r=e.getElementsByTagName("itemref"),i=Array.prototype.slice.call(r);return i.forEach(function(e,r){var i=e.getAttribute("idref"),s={id:i,linear:e.getAttribute("linear")||"",properties:e.getAttribute("properties")||"",href:t[i].href,index:r};n.push(s)}),n},EPUBJS.Parser.prototype.toc=function(e){function r(e,t,n){var n=n||[];return items=Array.prototype.slice.call(e),items.forEach(function(e){var t=e.getAttribute("id"),i=e.querySelector("content"),s=i.getAttribute("src"),o=s.split("#"),u=e.querySelector("navLabel"),a=u.textContent?u.textContent:"",f=e.querySelectorAll("navPoint");n.push({id:t,href:s,label:a,subitems:f.length?r(e.querySelectorAll("navPoint"),e,n):!1})}),n}var t=[],n=e.querySelector("navMap");return r(n.querySelectorAll("navPoint"),n)},EPUBJS.Renderer=function(e){var t=e.settings.element;this.book=e,this.settings=e.settings;if(_.isElement(t))this.el=t;else{if(typeof t!="string"){console.error("Not an Element");return}this.el=EPUBJS.core.getEl(t)}e.registerHook("beforeChapterDisplay",[this.replaceLinks.bind(this),this.replaceResources.bind(this)]),this.crossBrowserColumnCss(),this.epubcfi=new EPUBJS.EpubCFI,this.initialize(),this.listeners()},EPUBJS.Renderer.prototype.initialize=function(){this.iframe=document.createElement("iframe"),this.resizeIframe(!1,this.el.clientWidth,this.el.clientHeight),this.on("book:resized",this.resizeIframe,this),this.el.appendChild(this.iframe)},EPUBJS.Renderer.prototype.listeners=function(){this.resized=_.debounce(this.onResized.bind(this),10),window.addEventListener("resize",this.resized,!1)},EPUBJS.Renderer.prototype.chapter=function(e){var t=this,n=this.settings.stored?this.store:!1;return this.currentChapter&&this.trigger("book:chapterDestroyed"),this.currentChapter=e,this.chapterPos=1,this.pageIds={},this.leftPos=0,this.currentChapterCfi=this.epubcfi.generateChapter(this.book.spineNodeIndex,e.spinePos,e.id),this.visibileEl=!1,e.url(n).then(function(e){return t.setIframeSrc(e)})},EPUBJS.Renderer.prototype.onResized=function(){this.trigger("book:resized",{width:this.el.clientWidth,height:this.el.clientHeight}),this.reformat()},EPUBJS.Renderer.prototype.reformat=function(){var e=this;this.formatSpread(),setTimeout(function(){e.calcPages(),e.currentLocationCfi&&e.gotoCfiFragment(e.currentLocationCfi)},10)},EPUBJS.Renderer.prototype.destroy=function(){window.removeEventListener("resize",this.resized,!1)},EPUBJS.Renderer.prototype.resizeIframe=function(e,t,n){var r,i;e?(r=e.width,i=e.height):(r=t,i=n),this.iframe.height=i,r%2!=0&&(r+=1),this.iframe.width=r},EPUBJS.Renderer.prototype.crossBrowserColumnCss=function(){EPUBJS.Renderer.columnAxis=EPUBJS.core.prefixed("columnAxis"),EPUBJS.Renderer.columnGap=EPUBJS.core.prefixed("columnGap"),EPUBJS.Renderer.columnWidth=EPUBJS.core.prefixed("columnWidth")},EPUBJS.Renderer.prototype.setIframeSrc=function(e){var t=this,n=new RSVP.Promise;return this.visible(!1),this.iframe.src=e,this.iframe.onload=function(){t.doc=t.iframe.contentDocument,t.docEl=t.doc.documentElement,t.bodyEl=t.doc.body,t.formatSpread(),t.beforeDisplay(function(){t.calcPages(),t.currentLocationCfi=t.getPageCfi(),t.trigger("book:chapterDisplayed"),t.visible(!0)}),n.resolve(t)},n},EPUBJS.Renderer.prototype.formatSpread=function(){var e=2,t=800;this.colWidth&&(this.OldcolWidth=this.colWidth,this.OldspreadWidth=this.spreadWidth),this.elWidth=this.iframe.width,this.gap=this.gap||Math.ceil(this.elWidth/8),this.elWidth1?(this.chapterPos--,this.leftPos-=this.spreadWidth,this.setLeft(this.leftPos),this.currentLocationCfi=this.getPageCfi(),this.trigger("book:pageChanged",this.currentLocationCfi),this.chapterPos):!1},EPUBJS.Renderer.prototype.chapterEnd=function(){this.page(this.displayedPages)},EPUBJS.Renderer.prototype.setLeft=function(e){this.doc.defaultView.scrollTo(e,0)},EPUBJS.Renderer.prototype.replaceLinks=function(e){var t=this.doc.querySelectorAll("[href]"),n=Array.prototype.slice.call(t),r=this;n.forEach(function(e){var t,n=e.getAttribute("href"),i=n.search("://"),s=n[0]=="#";i!=-1?e.setAttribute("target","_blank"):e.onclick=function(){r.book.goto(n)}}),e&&e()},EPUBJS.Renderer.prototype.replaceResources=function(e){var t,n,r;if(this.book.online&&!this.book.contained||EPUBJS.storage.getStorageType()=="filesystem")return e&&e(),!1;t=this.doc.querySelectorAll("[src]"),n=Array.prototype.slice.call(t),r=n.length,n.forEach(function(t){var n=t.getAttribute("src"),i=this.book.basePath+n;EPUBJS.storage.get(i,function(n){t.setAttribute("src",n),r--,r<=0&&e&&e()})}.bind(this))},EPUBJS.Renderer.prototype.page=function(e){return e>=1&&e<=this.displayedPages?(this.chapterPos=e,this.leftPos=this.spreadWidth*(e-1),this.setLeft(this.leftPos),!0):(console.log("false",e,this.displayedPages),!1)},EPUBJS.Renderer.prototype.section=function(e){var t=this.doc.getElementById(e),n,r;t&&this.pageByElement(t)},EPUBJS.Renderer.prototype.pageByElement=function(e){var t,n;if(!e)return;t=this.leftPos+e.getBoundingClientRect().left,n=Math.floor(t/this.spreadWidth)+1,this.page(n)},EPUBJS.Renderer.prototype.beforeDisplay=function(e){this.book.triggerHooks("beforeChapterDisplay",e.bind(this),this)},EPUBJS.Renderer.prototype.walk=function(e){var t,e,n,r,i=e,s,o=[i],u=1e4,a=0;while(!t&&o.length){e=o.shift(),this.isElementVisible(e)&&(t=e);if(!t&&e&&e.childElementCount>0){n=e.children,r=n.length;for(var f=0;fu){console.error("ENDLESS LOOP");break}}return t},EPUBJS.Renderer.prototype.getPageCfi=function(){var e=this.visibileEl;return this.visibileEl=this.findFirstVisible(e),this.visibileEl.id||(this.visibileEl.id="@EPUBJS-PAGE-"+this.chapterPos),this.pageIds[this.chapterPos]=this.visibileEl.id,this.epubcfi.generateFragment(this.visibileEl,this.currentChapterCfi)},EPUBJS.Renderer.prototype.gotoCfiFragment=function(e){var t;_.isString(e)&&(e=this.epubcfi.parse(e)),t=this.epubcfi.getElement(e,this.doc),this.pageByElement(t)},EPUBJS.Renderer.prototype.findFirstVisible=function(e){var t=e||this.bodyEl,n;return n=this.walk(t),n?n:e},EPUBJS.Renderer.prototype.isElementVisible=function(e){var t;if(e){t=e.getBoundingClientRect().left;if(t>=0&&ti;i++)if(t.call(r,e[i],i,e)===n)return}else for(var o in e)if(x.has(e,o)&&t.call(r,e[o],o,e)===n)return};x.map=x.collect=function(e,t,n){var r=[];return null==e?r:h&&e.map===h?e.map(t,n):(T(e,function(e,i,s){r[r.length]=t.call(n,e,i,s)}),r)};var N="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(e,t,n,r){var i=arguments.length>2;if(null==e&&(e=[]),p&&e.reduce===p)return r&&(t=x.bind(t,r)),i?e.reduce(t,n):e.reduce(t);if(T(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)}),!i)throw new TypeError(N);return n},x.reduceRight=x.foldr=function(e,t,n,r){var i=arguments.length>2;if(null==e&&(e=[]),d&&e.reduceRight===d)return r&&(t=x.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=x.keys(e);s=o.length}if(T(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)}),!i)throw new TypeError(N);return n},x.find=x.detect=function(e,t,n){var r;return C(e,function(e,i,s){return t.call(n,e,i,s)?(r=e,!0):void 0}),r},x.filter=x.select=function(e,t,n){var r=[];return null==e?r:v&&e.filter===v?e.filter(t,n):(T(e,function(e,i,s){t.call(n,e,i,s)&&(r[r.length]=e)}),r)},x.reject=function(e,t,n){return x.filter(e,function(e,r,i){return!t.call(n,e,r,i)},n)},x.every=x.all=function(e,t,r){t||(t=x.identity);var i=!0;return null==e?i:m&&e.every===m?e.every(t,r):(T(e,function(e,s,o){return(i=i&&t.call(r,e,s,o))?void 0:n}),!!i)};var C=x.some=x.any=function(e,t,r){t||(t=x.identity);var i=!1;return null==e?i:g&&e.some===g?e.some(t,r):(T(e,function(e,s,o){return i||(i=t.call(r,e,s,o))?n:void 0}),!!i)};x.contains=x.include=function(e,t){return null==e?!1:y&&e.indexOf===y?e.indexOf(t)!=-1:C(e,function(e){return e===t})},x.invoke=function(e,t){var n=u.call(arguments,2),r=x.isFunction(t);return x.map(e,function(e){return(r?t:e[t]).apply(e,n)})},x.pluck=function(e,t){return x.map(e,function(e){return e[t]})},x.where=function(e,t,n){return x.isEmpty(t)?n?null:[]:x[n?"find":"filter"](e,function(e){for(var n in t)if(t[n]!==e[n])return!1;return!0})},x.findWhere=function(e,t){return x.where(e,t,!0)},x.max=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.max.apply(Math,e);if(!t&&x.isEmpty(e))return-1/0;var r={computed:-1/0,value:-1/0};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},x.min=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.min.apply(Math,e);if(!t&&x.isEmpty(e))return 1/0;var r={computed:1/0,value:1/0};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;r.computed>o&&(r={value:e,computed:o})}),r.value},x.shuffle=function(e){var t,n=0,r=[];return T(e,function(e){t=x.random(n++),r[n-1]=r[t],r[t]=e}),r};var k=function(e){return x.isFunction(e)?e:function(t){return t[e]}};x.sortBy=function(e,t,n){var r=k(t);return x.pluck(x.map(e,function(e,t,i){return{value:e,index:t,criteria:r.call(n,e,t,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(r>n||r===void 0)return-1}return e.indexs;){var u=s+o>>>1;i>n.call(r,e[u])?s=u+1:o=u}return s},x.toArray=function(e){return e?x.isArray(e)?u.call(e):e.length===+e.length?x.map(e,x.identity):x.values(e):[]},x.size=function(e){return null==e?0:e.length===+e.length?e.length:x.keys(e).length},x.first=x.head=x.take=function(e,t,n){return null==e?void 0:null==t||n?e[0]:u.call(e,0,t)},x.initial=function(e,t,n){return u.call(e,0,e.length-(null==t||n?1:t))},x.last=function(e,t,n){return null==e?void 0:null==t||n?e[e.length-1]:u.call(e,Math.max(e.length-t,0))},x.rest=x.tail=x.drop=function(e,t,n){return u.call(e,null==t||n?1:t)},x.compact=function(e){return x.filter(e,x.identity)};var A=function(e,t,n){return T(e,function(e){x.isArray(e)?t?o.apply(n,e):A(e,t,n):n.push(e)}),n};x.flatten=function(e,t){return A(e,t,[])},x.without=function(e){return x.difference(e,u.call(arguments,1))},x.uniq=x.unique=function(e,t,n,r){x.isFunction(t)&&(r=n,n=t,t=!1);var i=n?x.map(e,n,r):e,s=[],o=[];return T(i,function(n,r){(t?r&&o[o.length-1]===n:x.contains(o,n))||(o.push(n),s.push(e[r]))}),s},x.union=function(){return x.uniq(a.apply(r,arguments))},x.intersection=function(e){var t=u.call(arguments,1);return x.filter(x.uniq(e),function(e){return x.every(t,function(t){return x.indexOf(t,e)>=0})})},x.difference=function(e){var t=a.apply(r,u.call(arguments,1));return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){for(var e=u.call(arguments),t=x.max(x.pluck(e,"length")),n=Array(t),r=0;t>r;r++)n[r]=x.pluck(e,""+r);return n},x.object=function(e,t){if(null==e)return{};for(var n={},r=0,i=e.length;i>r;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},x.indexOf=function(e,t,n){if(null==e)return-1;var r=0,i=e.length;if(n){if("number"!=typeof n)return r=x.sortedIndex(e,t),e[r]===t?r:-1;r=0>n?Math.max(0,i+n):n}if(y&&e.indexOf===y)return e.indexOf(t,n);for(;i>r;r++)if(e[r]===t)return r;return-1},x.lastIndexOf=function(e,t,n){if(null==e)return-1;var r=null!=n;if(b&&e.lastIndexOf===b)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);for(var i=r?n:e.length;i--;)if(e[i]===t)return i;return-1},x.range=function(e,t,n){1>=arguments.length&&(t=e||0,e=0),n=arguments[2]||1;for(var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=Array(r);r>i;)s[i++]=e,e+=n;return s},x.bind=function(e,t){if(e.bind===S&&S)return S.apply(e,u.call(arguments,1));var n=u.call(arguments,2);return function(){return e.apply(t,n.concat(u.call(arguments)))}},x.partial=function(e){var t=u.call(arguments,1);return function(){return e.apply(this,t.concat(u.call(arguments)))}},x.bindAll=function(e){var t=u.call(arguments,1);return 0===t.length&&(t=x.functions(e)),T(t,function(t){e[t]=x.bind(e[t],e)}),e},x.memoize=function(e,t){var n={};return t||(t=x.identity),function(){var r=t.apply(this,arguments);return x.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},x.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},x.defer=function(e){return x.delay.apply(x,[e,1].concat(u.call(arguments,1)))},x.throttle=function(e,t){var n,r,i,s,o=0,u=function(){o=new Date,i=null,s=e.apply(n,r)};return function(){var a=new Date,f=t-(a-o);return n=this,r=arguments,0>=f?(clearTimeout(i),i=null,o=a,s=e.apply(n,r)):i||(i=setTimeout(u,f)),s}},x.debounce=function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},x.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},x.wrap=function(e,t){return function(){var n=[e];return o.apply(n,arguments),t.apply(this,n)}},x.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},x.after=function(e,t){return 0>=e?t():function(){return 1>--e?t.apply(this,arguments):void 0}},x.keys=E||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)x.has(e,n)&&(t[t.length]=n);return t},x.values=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push(e[n]);return t},x.pairs=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push([n,e[n]]);return t},x.invert=function(e){var t={};for(var n in e)x.has(e,n)&&(t[e[n]]=n);return t},x.functions=x.methods=function(e){var t=[];for(var n in e)x.isFunction(e[n])&&t.push(n);return t.sort()},x.extend=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]=t[n]}),e},x.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return T(n,function(n){n in e&&(t[n]=e[n])}),t},x.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)x.contains(n,i)||(t[i]=e[i]);return t},x.defaults=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)null==e[n]&&(e[n]=t[n])}),e},x.clone=function(e){return x.isObject(e)?x.isArray(e)?e.slice():x.extend({},e):e},x.tap=function(e,t){return t(e),e};var O=function(e,t,n,r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;e instanceof x&&(e=e._wrapped),t instanceof x&&(t=t._wrapped);var i=f.call(e);if(i!=f.call(t))return!1;switch(i){case"[object String]":return e==t+"";case"[object Number]":return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return!1;for(var s=n.length;s--;)if(n[s]==e)return r[s]==t;n.push(e),r.push(t);var o=0,u=!0;if("[object Array]"==i){if(o=e.length,u=o==t.length)for(;o--&&(u=O(e[o],t[o],n,r)););}else{var a=e.constructor,l=t.constructor;if(a!==l&&!(x.isFunction(a)&&a instanceof a&&x.isFunction(l)&&l instanceof l))return!1;for(var c in e)if(x.has(e,c)&&(o++,!(u=x.has(t,c)&&O(e[c],t[c],n,r))))break;if(u){for(c in t)if(x.has(t,c)&&!(o--))break;u=!o}}return n.pop(),r.pop(),u};x.isEqual=function(e,t){return O(e,t,[],[])},x.isEmpty=function(e){if(null==e)return!0;if(x.isArray(e)||x.isString(e))return 0===e.length;for(var t in e)if(x.has(e,t))return!1;return!0},x.isElement=function(e){return!!e&&1===e.nodeType},x.isArray=w||function(e){return"[object Array]"==f.call(e)},x.isObject=function(e){return e===Object(e)},T(["Arguments","Function","String","Number","Date","RegExp"],function(e){x["is"+e]=function(t){return f.call(t)=="[object "+e+"]"}}),x.isArguments(arguments)||(x.isArguments=function(e){return!!e&&!!x.has(e,"callee")}),"function"!=typeof /./&&(x.isFunction=function(e){return"function"==typeof e}),x.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},x.isNaN=function(e){return x.isNumber(e)&&e!=+e},x.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"==f.call(e)},x.isNull=function(e){return null===e},x.isUndefined=function(e){return e===void 0},x.has=function(e,t){return l.call(e,t)},x.noConflict=function(){return e._=t,this},x.identity=function(e){return e},x.times=function(e,t,n){for(var r=Array(e),i=0;e>i;i++)r[i]=t.call(n,i);return r},x.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=x.invert(M.escape);var _={escape:RegExp("["+x.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+x.keys(M.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(e){x[e]=function(t){return null==t?"":(""+t).replace(_[e],function(t){return M[e][t]})}}),x.result=function(e,t){if(null==e)return null;var n=e[t];return x.isFunction(n)?n.call(e):n},x.mixin=function(e){T(x.functions(e),function(t){var n=x[t]=e[t];x.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),j.call(this,n.apply(x,e))}})};var D=0;x.uniqueId=function(e){var t=++D+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var P=/(.)^/,H={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(e,t,n){var r;n=x.defaults({},n,x.templateSettings);var i=RegExp([(n.escape||P).source,(n.interpolate||P).source,(n.evaluate||P).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(B,function(e){return"\\"+H[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,x);var a=function(e){return r.call(this,e,x)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},x.chain=function(e){return x(e).chain()};var j=function(e){return this._chain?x(e).chain():e};x.mixin(x),T(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];x.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!=e&&"splice"!=e||0!==n.length||delete n[0],j.call(this,n)}}),T(["concat","join","slice"],function(e){var t=r[e];x.prototype[e]=function(){return j.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this),function(e){"use strict";function t(e,t){s.async(function(){e.trigger("promise:resolved",{detail:t}),e.isResolved=!0,e.resolvedValue=t})}function n(e,t){s.async(function(){e.trigger("promise:failed",{detail:t}),e.isRejected=!0,e.rejectedValue=t})}function r(e){var t,n=[],r=new m,i=e.length;i===0&&r.resolve([]);var s=function(e){return function(t){o(e,t)}},o=function(e,t){n[e]=t,--i===0&&r.resolve(n)},u=function(e){r.reject(e)};for(t=0;t=this.spine.length?!1:s<0?!1:(this.spinePos=s,this.chapter=new EPUBJS.Chapter(this.spine[s]),r=n.render.chapter(this.chapter),i?r.then(function(t){t.currentLocationCfi=e,t.gotoCfiFragment(i)}):t&&r.then(function(e){e.gotoChapterEnd()}),this.settings.storage||r.then(function(){n.preloadNextChapter()}),r)},EPUBJS.Book.prototype.nextPage=function(){var e=this.render.nextPage();if(!e)return this.nextChapter()},EPUBJS.Book.prototype.prevPage=function(){var e=this.render.prevPage();if(!e)return this.prevChapter()},EPUBJS.Book.prototype.nextChapter=function(){return this.spinePos++,this.displayChapter(this.spinePos)},EPUBJS.Book.prototype.prevChapter=function(){return this.spinePos--,this.displayChapter(this.spinePos,!0)},EPUBJS.Book.prototype.goto=function(e){var t=e.split("#"),n=t[0],r=t[1]||!1,i=n.search("://")==-1?this.settings.contentsPath+n:n,s=this.spineIndexByURL[i],o;return n||(s=this.chapter.spinePos),typeof s!="number"?!1:s!=this.chapter.spinePos||!this.chapter?this.displayChapter(s).then(function(){r&&o.render.section(r)}):(r&&this.render.section(r),(new RSVP.Promise).resolve(this.currentChapter))},EPUBJS.Book.prototype.preloadNextChapter=function(){var e=document.createElement("iframe");next;if(this.spinePos>=this.spine.length)return!1;next=new EPUBJS.Chapter(this.spine[this.spinePos+1]),EPUBJS.core.request(next.href)},EPUBJS.Book.prototype.storeOffline=function(){var e=this,t=_.values(this.manifest);return EPUBJS.storage.batch(t).then(function(){e.settings.stored=!0,e.trigger("book:stored")})},EPUBJS.Book.prototype.availableOffline=function(){return this.settings.stored>0?!0:!1},EPUBJS.Book.prototype.setStyle=function(e,t,n){this.renderer.setStyle(e,t,n),this.settings.styles[e]=t},EPUBJS.Book.prototype.removeStyle=function(e,t,n){this.renderer.removeStyle(e),delete this.settings.styles[e]=""},EPUBJS.Book.prototype.getHooks=function(){var e=this,t;plugTypes=_.values(this.hooks);for(plugType in this.hooks)t=_.values(EPUBJS.Hooks[plugType]),t.forEach(function(t){e.registerHook(plugType,t)})},EPUBJS.Book.prototype.registerHook=function(e,t){var n=this;typeof this.hooks[e]!="undefined"?typeof t=="function"?this.hooks[e].push(t):Array.isArray(t)&&t.forEach(function(t){n.hooks[e].push(t)}):this.hooks[e]=[func]},EPUBJS.Book.prototype.triggerHooks=function(e,t,n){function s(){i--,i<=0&&t&&t()}var r,i;if(typeof this.hooks[e]=="undefined")return!1;r=this.hooks[e],i=r.length,r.forEach(function(e){e(s,n)})},RSVP.EventTarget.mixin(EPUBJS.Book.prototype),EPUBJS.Chapter=function(e){this.href=e.href,this.id=e.id,this.spinePos=e.index,this.properties=e.properties,this.linear=e.linear,this.pages=1},EPUBJS.Chapter.prototype.contents=function(e){return e?e.get(href):EPUBJS.core.request(href,"xml")},EPUBJS.Chapter.prototype.url=function(e){var t=new RSVP.Promise;return e?e.getUrl(href):(t.resolve(this.href),t)},EPUBJS.Chapter.prototype.setPages=function(e){this.pages=e},EPUBJS.Chapter.prototype.getPages=function(e){return this.pages},EPUBJS.Chapter.prototype.getID=function(){return this.ID};var EPUBJS=EPUBJS||{};EPUBJS.core={},EPUBJS.core.getEl=function(e){return document.getElementById(e)},EPUBJS.core.getEls=function(e){return document.getElementsByClassName(e)},EPUBJS.core.request=function(e,t){function i(){if(this.readyState===this.DONE)if(this.status===200){var e;t=="xml"?e=this.responseXML:t=="json"?e=JSON.parse(this.response):e=this.response,n.resolve(e)}else n.reject(this)}var n=new RSVP.Promise,r=new XMLHttpRequest;return r.open("GET",e),r.onreadystatechange=i,t=="blob"&&(r.responseType=t),t=="json"&&r.setRequestHeader("Accept","application/json"),t=="xml"&&r.overrideMimeType("text/xml"),r.send(),n},EPUBJS.core.toArray=function(e){var t=[];for(member in e){var n;e.hasOwnProperty(member)&&(n=e[member],n.ident=member,t.push(n))}return t},EPUBJS.core.folder=function(e){var t=e.lastIndexOf("/"),n=e.slice(0,t+1);return n},EPUBJS.core.dataURLToBlob=function(e){var t=";base64,";if(e.indexOf(t)==-1){var n=e.split(","),r=n[0].split(":")[1],i=n[1];return new Blob([i],{type:r})}var n=e.split(t),r=n[0].split(":")[1],i=window.atob(n[1]),s=i.length,o=new Uint8Array(s);for(var u=0;u0)u=n.shift(),u.id?r=e.doc.querySelector("#"+u.id):(r=i[u.index],i||console.error("No Kids",r)),r||console.error("No Element For",u),i=Array.prototype.slice.call(r.children);return r},EPUBJS.Events=function(e,t){return this.events={},t?this.el=t:this.el=document.createElement("div"),e.createEvent=this.createEvent,e.tell=this.tell,e.listen=this.listen,e.deafen=this.deafen,e.listenUntil=this.listenUntil,this},EPUBJS.Events.prototype.createEvent=function(e){var t=new CustomEvent(e);return this.events[e]=t,t},EPUBJS.Events.prototype.tell=function(e,t){var n;this.events[e]?n=this.events[e]:(console.warn("No event:",e,"defined yet, creating."),n=this.createEvent(e)),t&&(n.msg=t),this.el.dispatchEvent(n)},EPUBJS.Events.prototype.listen=function(e,t,n){if(!this.events[e]){console.warn("No event:",e,"defined yet, creating."),this.createEvent(e);return}n?this.el.addEventListener(e,t.bind(n),!1):this.el.addEventListener(e,t,!1)},EPUBJS.Events.prototype.deafen=function(e,t){this.el.removeEventListener(e,t,!1)},EPUBJS.Events.prototype.listenUntil=function(e,t,n,r){function i(){this.deafen(e,n),this.deafen(t,i)}this.listen(e,n,r),this.listen(t,i,this)},EPUBJS.Hooks=function(){"use strict";return{register:function(e){this[e]===undefined&&(this[e]={});if(typeof this[e]!="object")throw"Already registered: "+e;return this[e]}}}(),EPUBJS.Parser=function(e){this.baseUrl=e||""},EPUBJS.Parser.prototype.container=function(e){var t=e.querySelector("rootfile"),n=t.getAttribute("full-path"),r=EPUBJS.core.folder(n);return{packagePath:n,basePath:r}},EPUBJS.Parser.prototype.package=function(e,t){var n=this;t&&(this.baseUrl=t);var r=e.querySelector("metadata"),i=e.querySelector("manifest"),s=e.querySelector("spine"),o=n.manifest(i),u=n.findTocPath(i),a=n.findCoverPath(i),f=Array.prototype.indexOf.call(s.parentNode.childNodes,s),l=n.spine(s,o),c={};return l.forEach(function(e){c[e.href]=e.index}),{metadata:n.metadata(r),spine:l,manifest:o,tocPath:u,coverPath:a,spineNodeIndex:f,spineIndexByURL:c}},EPUBJS.Parser.prototype.findTocPath=function(e){var t=e.querySelector("item[media-type='application/x-dtbncx+xml']");return t.getAttribute("href")},EPUBJS.Parser.prototype.findCoverPath=function(e){var t=e.querySelector("item[properties='cover-image']");return t.getAttribute("href")},EPUBJS.Parser.prototype.metadata=function(e){var t={},n=this;return t.bookTitle=n.getElement(e,"title"),t.creator=n.getElement(e,"creator"),t.description=n.getElement(e,"description"),t.pubdate=n.getElement(e,"date"),t.publisher=n.getElement(e,"publisher"),t.identifier=n.getElement(e,"identifier"),t.language=n.getElement(e,"language"),t.rights=n.getElement(e,"rights"),t.modified_date=n.querySelector(e,"meta[property='dcterms:modified']"),t.layout=n.querySelector(e,"meta[property='rendition:orientation']"),t.orientation=n.querySelector(e,"meta[property='rendition:orientation']"),t.spread=n.querySelector(e,"meta[property='rendition:spread']"),t},EPUBJS.Parser.prototype.getElement=function(e,t){var n=e.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",t),r;return n?(r=n[0],r?r.childNodes[0].nodeValue:""):""},EPUBJS.Parser.prototype.querySelector=function(e,t){var n=e.querySelector(t);return n?n.childNodes[0].nodeValue:""},EPUBJS.Parser.prototype.manifest=function(e){var t=this.baseUrl,n={},r=e.querySelectorAll("item"),i=Array.prototype.slice.call(r);return i.forEach(function(e){var r=e.getAttribute("id"),i=e.getAttribute("href")||"",s=e.getAttribute("media-type")||"";n[r]={href:t+i,type:s}}),n},EPUBJS.Parser.prototype.spine=function(e,t){var n=[],r=e.getElementsByTagName("itemref"),i=Array.prototype.slice.call(r);return i.forEach(function(e,r){var i=e.getAttribute("idref"),s={id:i,linear:e.getAttribute("linear")||"",properties:e.getAttribute("properties")||"",href:t[i].href,index:r};n.push(s)}),n},EPUBJS.Parser.prototype.toc=function(e){function r(e,t,n){var n=n||[];return items=Array.prototype.slice.call(e),items.forEach(function(e){var t=e.getAttribute("id"),i=e.querySelector("content"),s=i.getAttribute("src"),o=s.split("#"),u=e.querySelector("navLabel"),a=u.textContent?u.textContent:"",f=e.querySelectorAll("navPoint");n.push({id:t,href:s,label:a,subitems:f.length?r(e.querySelectorAll("navPoint"),e,n):!1})}),n}var t=[],n=e.querySelector("navMap");return r(n.querySelectorAll("navPoint"),n)},EPUBJS.Renderer=function(e){var t=e.settings.element;this.book=e,this.settings=e.settings;if(_.isElement(t))this.el=t;else{if(typeof t!="string"){console.error("Not an Element");return}this.el=EPUBJS.core.getEl(t)}e.registerHook("beforeChapterDisplay",[this.replaceLinks.bind(this),this.replaceResources.bind(this)]),this.crossBrowserColumnCss(),this.epubcfi=new EPUBJS.EpubCFI,this.initialize(),this.listeners()},EPUBJS.Renderer.prototype.initialize=function(){this.iframe=document.createElement("iframe"),this.resizeIframe(!1,this.el.clientWidth,this.el.clientHeight),this.on("book:resized",this.resizeIframe,this),this.el.appendChild(this.iframe)},EPUBJS.Renderer.prototype.listeners=function(){this.resized=_.debounce(this.onResized.bind(this),10),window.addEventListener("resize",this.resized,!1)},EPUBJS.Renderer.prototype.chapter=function(e){var t=this,n=this.settings.stored?this.store:!1;return this.currentChapter&&this.trigger("book:chapterDestroyed"),this.currentChapter=e,this.chapterPos=1,this.pageIds={},this.leftPos=0,this.currentChapterCfi=this.epubcfi.generateChapter(this.book.spineNodeIndex,e.spinePos,e.id),this.visibileEl=!1,e.url(n).then(function(e){return t.setIframeSrc(e)})},EPUBJS.Renderer.prototype.onResized=function(){this.trigger("book:resized",{width:this.el.clientWidth,height:this.el.clientHeight}),this.reformat()},EPUBJS.Renderer.prototype.reformat=function(){var e=this;this.formatSpread(),setTimeout(function(){e.calcPages(),e.currentLocationCfi&&e.gotoCfiFragment(e.currentLocationCfi)},10)},EPUBJS.Renderer.prototype.destroy=function(){window.removeEventListener("resize",this.resized,!1)},EPUBJS.Renderer.prototype.resizeIframe=function(e,t,n){var r,i;e?(r=e.width,i=e.height):(r=t,i=n),this.iframe.height=i,r%2!=0&&(r+=1),this.iframe.width=r},EPUBJS.Renderer.prototype.crossBrowserColumnCss=function(){EPUBJS.Renderer.columnAxis=EPUBJS.core.prefixed("columnAxis"),EPUBJS.Renderer.columnGap=EPUBJS.core.prefixed("columnGap"),EPUBJS.Renderer.columnWidth=EPUBJS.core.prefixed("columnWidth")},EPUBJS.Renderer.prototype.setIframeSrc=function(e){var t=this,n=new RSVP.Promise;return this.visible(!1),this.iframe.src=e,this.iframe.onload=function(){t.doc=t.iframe.contentDocument,t.docEl=t.doc.documentElement,t.bodyEl=t.doc.body,t.applyStyles(),t.formatSpread(),t.beforeDisplay(function(){t.calcPages(),t.currentLocationCfi=t.getPageCfi(),t.trigger("book:chapterDisplayed"),t.visible(!0)}),n.resolve(t)},n},EPUBJS.Renderer.prototype.formatSpread=function(){var e=2,t=800;this.colWidth&&(this.OldcolWidth=this.colWidth,this.OldspreadWidth=this.spreadWidth),this.elWidth=this.iframe.width,this.gap=this.gap||Math.ceil(this.elWidth/8),this.elWidth1?(this.chapterPos--,this.leftPos-=this.spreadWidth,this.setLeft(this.leftPos),this.currentLocationCfi=this.getPageCfi(),this.trigger("book:pageChanged",this.currentLocationCfi),this.chapterPos):!1},EPUBJS.Renderer.prototype.chapterEnd=function(){this.page(this.displayedPages)},EPUBJS.Renderer.prototype.setLeft=function(e){this.doc.defaultView.scrollTo(e,0)},EPUBJS.Renderer.prototype.replaceLinks=function(e){var t=this.doc.querySelectorAll("[href]"),n=Array.prototype.slice.call(t),r=this;n.forEach(function(e){var t,n=e.getAttribute("href"),i=n.search("://"),s=n[0]=="#";i!=-1?e.setAttribute("target","_blank"):e.onclick=function(){r.book.goto(n)}}),e&&e()},EPUBJS.Renderer.prototype.replaceResources=function(e){var t,n,r;if(this.book.online&&!this.book.contained||EPUBJS.storage.getStorageType()=="filesystem")return e&&e(),!1;t=this.doc.querySelectorAll("[src]"),n=Array.prototype.slice.call(t),r=n.length,n.forEach(function(t){var n=t.getAttribute("src"),i=this.book.basePath+n;EPUBJS.storage.get(i,function(n){t.setAttribute("src",n),r--,r<=0&&e&&e()})}.bind(this))},EPUBJS.Renderer.prototype.page=function(e){return e>=1&&e<=this.displayedPages?(this.chapterPos=e,this.leftPos=this.spreadWidth*(e-1),this.setLeft(this.leftPos),!0):(console.log("false",e,this.displayedPages),!1)},EPUBJS.Renderer.prototype.section=function(e){var t=this.doc.getElementById(e),n,r;t&&this.pageByElement(t)},EPUBJS.Renderer.prototype.pageByElement=function(e){var t,n;if(!e)return;t=this.leftPos+e.getBoundingClientRect().left,n=Math.floor(t/this.spreadWidth)+1,this.page(n)},EPUBJS.Renderer.prototype.beforeDisplay=function(e){this.book.triggerHooks("beforeChapterDisplay",e.bind(this),this)},EPUBJS.Renderer.prototype.walk=function(e){var t,e,n,r,i=e,s,o=[i],u=1e4,a=0;while(!t&&o.length){e=o.shift(),this.isElementVisible(e)&&(t=e);if(!t&&e&&e.childElementCount>0){n=e.children,r=n.length;for(var f=0;fu){console.error("ENDLESS LOOP");break}}return t},EPUBJS.Renderer.prototype.getPageCfi=function(){var e=this.visibileEl;return this.visibileEl=this.findFirstVisible(e),this.visibileEl.id||(this.visibileEl.id="@EPUBJS-PAGE-"+this.chapterPos),this.pageIds[this.chapterPos]=this.visibileEl.id,this.epubcfi.generateFragment(this.visibileEl,this.currentChapterCfi)},EPUBJS.Renderer.prototype.gotoCfiFragment=function(e){var t;_.isString(e)&&(e=this.epubcfi.parse(e)),t=this.epubcfi.getElement(e,this.doc),this.pageByElement(t)},EPUBJS.Renderer.prototype.findFirstVisible=function(e){var t=e||this.bodyEl,n;return n=this.walk(t),n?n:e},EPUBJS.Renderer.prototype.isElementVisible=function(e){var t;if(e){t=e.getBoundingClientRect().left;if(t>=0&&t