mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
upgraded rsvp.js, small bug fixes
This commit is contained in:
parent
8bc693b2ce
commit
f525d86fb1
20 changed files with 2488 additions and 1370 deletions
34
Gruntfile.js
34
Gruntfile.js
|
@ -8,7 +8,7 @@ module.exports = function(grunt) {
|
|||
'<%= grunt.template.today("yyyy-mm-dd") %> */'
|
||||
},
|
||||
concat : {
|
||||
'build/epub.js': ['<banner>', 'libs/rsvp/rsvp.min.js', 'src/*.js'],
|
||||
'build/epub.js': ['<banner>', 'libs/rsvp/rsvp.js', 'src/*.js'],
|
||||
'build/reader.js': ['<banner>', 'reader/*.js'],
|
||||
'build/hooks.js': ['<banner>', 'hooks/default/*.js'],
|
||||
'demo/js/libs/fileStorage.min.js': 'libs/fileStorage/fileStorage.min.js',
|
||||
|
@ -17,22 +17,22 @@ module.exports = function(grunt) {
|
|||
'demo/js/libs/inflate.js': 'libs/zip/inflate.js'
|
||||
},
|
||||
uglify: {
|
||||
options: {
|
||||
preserveComments: 'some'
|
||||
},
|
||||
my_target: {
|
||||
files: {
|
||||
'demo/js/epub.min.js': ['libs/underscore/underscore-min.js', 'build/epub.js'],
|
||||
'build/epub.min.js': ['libs/underscore/underscore-min.js', 'build/epub.js'],
|
||||
'demo/js/reader.min.js': 'build/reader.js',
|
||||
'demo/js/hooks.min.js': 'build/hooks.js',
|
||||
'build/hooks.min.js': 'build/hooks.js',
|
||||
'demo/js/libs/zip.min.js': ['libs/zip/zip.js', 'libs/zip/zip-fs.js', 'libs/zip/zip-ext.js', 'libs/zip/mime-types.js'],
|
||||
'demo/js/libs/inflate.min.js': ['libs/zip/inflate.js'],
|
||||
'build/libs/zip.min.js': ['libs/zip/zip.js', 'libs/zip/zip-fs.js', 'libs/zip/zip-ext.js', 'libs/zip/mime-types.js'],
|
||||
'build/libs/inflate.js': ['libs/zip/inflate.js']
|
||||
}
|
||||
}
|
||||
options: {
|
||||
preserveComments: 'some'
|
||||
},
|
||||
my_target: {
|
||||
files: {
|
||||
'demo/js/epub.min.js': ['libs/underscore/underscore-min.js', 'build/epub.js'],
|
||||
'build/epub.min.js': ['libs/underscore/underscore-min.js', 'build/epub.js'],
|
||||
'demo/js/reader.min.js': ['build/reader.js'],
|
||||
'demo/js/hooks.min.js': ['build/hooks.js'],
|
||||
'build/hooks.min.js': ['build/hooks.js'],
|
||||
'demo/js/libs/zip.min.js': ['libs/zip/zip.js', 'libs/zip/zip-fs.js', 'libs/zip/zip-ext.js', 'libs/zip/mime-types.js'],
|
||||
'demo/js/libs/inflate.min.js': ['libs/zip/inflate.js'],
|
||||
'build/libs/zip.min.js': ['libs/zip/zip.js', 'libs/zip/zip-fs.js', 'libs/zip/zip-ext.js', 'libs/zip/mime-types.js'],
|
||||
'build/libs/inflate.js': ['libs/zip/inflate.js']
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
1625
build/epub.js
1625
build/epub.js
File diff suppressed because it is too large
Load diff
4
build/epub.min.js
vendored
4
build/epub.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -45,6 +45,7 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap
|
|||
txt = pop.querySelector("p");
|
||||
}
|
||||
|
||||
chapter.replaceLinks.bind(this)
|
||||
//-- create a popup with endnote inside of it
|
||||
if(!popups[id]) {
|
||||
popups[id] = document.createElement("div");
|
||||
|
|
2
build/hooks.min.js
vendored
2
build/hooks.min.js
vendored
|
@ -1 +1 @@
|
|||
EPUBJS.Hooks.register("beforeChapterDisplay").endnotes=function(a,b){var c=b.doc.querySelectorAll("a[href]"),d=Array.prototype.slice.call(c),e="epub:type",f="noteref",g=EPUBJS.core.folder(location.pathname),h=g+EPUBJS.cssPath||g,i={};EPUBJS.core.addCss(h+"popup.css",!1,b.doc.head),d.forEach(function(a){function c(){var c,e=b.iframe.height,f=b.iframe.width,j=225;o||(c=l.cloneNode(!0),o=c.querySelector("p")),i[k]||(i[k]=document.createElement("div"),i[k].setAttribute("class","popup"),pop_content=document.createElement("div"),i[k].appendChild(pop_content),pop_content.appendChild(o),pop_content.setAttribute("class","pop_content"),b.bodyEl.appendChild(i[k]),i[k].addEventListener("mouseover",d,!1),i[k].addEventListener("mouseout",g,!1),b.book.on("renderer:pageChanged",h,this),b.book.on("renderer:pageChanged",g,this)),c=i[k],itemRect=a.getBoundingClientRect(),m=itemRect.left,n=itemRect.top,c.classList.add("show"),popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width/2+"px",c.style.top=n+"px",j>e/2.5&&(j=e/2.5,pop_content.style.maxHeight=j+"px"),popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),m-popRect.width<=0?(c.style.left=m+"px",c.classList.add("left")):c.classList.remove("left"),m+popRect.width/2>=f?(c.style.left=m-300+"px",popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width+"px",popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),c.classList.add("right")):c.classList.remove("right")}function d(){i[k].classList.add("on")}function g(){i[k].classList.remove("on")}function h(){setTimeout(function(){i[k].classList.remove("show")},100)}var j,k,l,m,n,o,p=a.getAttribute(e);p==f&&(j=a.getAttribute("href"),k=j.replace("#",""),l=b.doc.getElementById(k),a.addEventListener("mouseover",c,!1),a.addEventListener("mouseout",h,!1))}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").smartimages=function(a,b){var c=b.doc.querySelectorAll("img"),d=Array.prototype.slice.call(c),e=b.bodyEl.clientHeight;d.forEach(function(a){function c(){var c,d=a.getBoundingClientRect(),f=d.height,g=d.top,h=a.getAttribute("data-height"),i=h||f;e=b.docEl.clientHeight,0>g&&(g=0),i+g>=e?(e/2>g?(c=e-g,a.style.maxHeight=c+"px",a.style.width="auto"):(c=e>i?i:e,a.style.maxHeight=c+"px",a.style.marginTop=e-g+"px",a.style.width="auto",console.log(c)),a.setAttribute("data-height",c)):(a.style.removeProperty("max-height"),a.style.removeProperty("margin-top"))}a.addEventListener("load",c,!1),b.on("renderer:resized",c),b.on("renderer:chapterUnloaded",function(){a.removeEventListener("load",c),b.off("renderer:resized",c)}),c()}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").transculsions=function(a,b){var c=b.doc.querySelectorAll("[transclusion]"),d=Array.prototype.slice.call(c);d.forEach(function(a){function c(){j=g,k=h,j>b.colWidth&&(d=b.colWidth/j,j=b.colWidth,k*=d),f.width=j,f.height=k}var d,e=a.getAttribute("ref"),f=document.createElement("iframe"),g=a.getAttribute("width"),h=a.getAttribute("height"),i=a.parentNode,j=g,k=h;c(),b.book.listenUntil("book:resized","book:chapterDestroy",c),f.src=e,i.replaceChild(f,a)}),a&&a()};
|
||||
EPUBJS.Hooks.register("beforeChapterDisplay").endnotes=function(a,b){var c=b.doc.querySelectorAll("a[href]"),d=Array.prototype.slice.call(c),e="epub:type",f="noteref",g=EPUBJS.core.folder(location.pathname),h=g+EPUBJS.cssPath||g,i={};EPUBJS.core.addCss(h+"popup.css",!1,b.doc.head),d.forEach(function(a){function c(){var c,e=b.iframe.height,f=b.iframe.width,j=225;o||(c=l.cloneNode(!0),o=c.querySelector("p")),b.replaceLinks.bind(this),i[k]||(i[k]=document.createElement("div"),i[k].setAttribute("class","popup"),pop_content=document.createElement("div"),i[k].appendChild(pop_content),pop_content.appendChild(o),pop_content.setAttribute("class","pop_content"),b.bodyEl.appendChild(i[k]),i[k].addEventListener("mouseover",d,!1),i[k].addEventListener("mouseout",g,!1),b.book.on("renderer:pageChanged",h,this),b.book.on("renderer:pageChanged",g,this)),c=i[k],itemRect=a.getBoundingClientRect(),m=itemRect.left,n=itemRect.top,c.classList.add("show"),popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width/2+"px",c.style.top=n+"px",j>e/2.5&&(j=e/2.5,pop_content.style.maxHeight=j+"px"),popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),m-popRect.width<=0?(c.style.left=m+"px",c.classList.add("left")):c.classList.remove("left"),m+popRect.width/2>=f?(c.style.left=m-300+"px",popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width+"px",popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),c.classList.add("right")):c.classList.remove("right")}function d(){i[k].classList.add("on")}function g(){i[k].classList.remove("on")}function h(){setTimeout(function(){i[k].classList.remove("show")},100)}var j,k,l,m,n,o,p=a.getAttribute(e);p==f&&(j=a.getAttribute("href"),k=j.replace("#",""),l=b.doc.getElementById(k),a.addEventListener("mouseover",c,!1),a.addEventListener("mouseout",h,!1))}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").smartimages=function(a,b){var c=b.doc.querySelectorAll("img"),d=Array.prototype.slice.call(c),e=b.bodyEl.clientHeight;d.forEach(function(a){function c(){var c,d=a.getBoundingClientRect(),f=d.height,g=d.top,h=a.getAttribute("data-height"),i=h||f;e=b.docEl.clientHeight,0>g&&(g=0),i+g>=e?(e/2>g?(c=e-g,a.style.maxHeight=c+"px",a.style.width="auto"):(c=e>i?i:e,a.style.maxHeight=c+"px",a.style.marginTop=e-g+"px",a.style.width="auto",console.log(c)),a.setAttribute("data-height",c)):(a.style.removeProperty("max-height"),a.style.removeProperty("margin-top"))}a.addEventListener("load",c,!1),b.on("renderer:resized",c),b.on("renderer:chapterUnloaded",function(){a.removeEventListener("load",c),b.off("renderer:resized",c)}),c()}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").transculsions=function(a,b){var c=b.doc.querySelectorAll("[transclusion]"),d=Array.prototype.slice.call(c);d.forEach(function(a){function c(){j=g,k=h,j>b.colWidth&&(d=b.colWidth/j,j=b.colWidth,k*=d),f.width=j,f.height=k}var d,e=a.getAttribute("ref"),f=document.createElement("iframe"),g=a.getAttribute("width"),h=a.getAttribute("height"),i=a.parentNode,j=g,k=h;c(),b.book.listenUntil("book:resized","book:chapterDestroy",c),f.src=e,i.replaceChild(f,a)}),a&&a()};
|
4
demo/js/epub.min.js
vendored
4
demo/js/epub.min.js
vendored
File diff suppressed because one or more lines are too long
2
demo/js/hooks.min.js
vendored
2
demo/js/hooks.min.js
vendored
|
@ -1 +1 @@
|
|||
EPUBJS.Hooks.register("beforeChapterDisplay").endnotes=function(a,b){var c=b.doc.querySelectorAll("a[href]"),d=Array.prototype.slice.call(c),e="epub:type",f="noteref",g=EPUBJS.core.folder(location.pathname),h=g+EPUBJS.cssPath||g,i={};EPUBJS.core.addCss(h+"popup.css",!1,b.doc.head),d.forEach(function(a){function c(){var c,e=b.iframe.height,f=b.iframe.width,j=225;o||(c=l.cloneNode(!0),o=c.querySelector("p")),i[k]||(i[k]=document.createElement("div"),i[k].setAttribute("class","popup"),pop_content=document.createElement("div"),i[k].appendChild(pop_content),pop_content.appendChild(o),pop_content.setAttribute("class","pop_content"),b.bodyEl.appendChild(i[k]),i[k].addEventListener("mouseover",d,!1),i[k].addEventListener("mouseout",g,!1),b.book.on("renderer:pageChanged",h,this),b.book.on("renderer:pageChanged",g,this)),c=i[k],itemRect=a.getBoundingClientRect(),m=itemRect.left,n=itemRect.top,c.classList.add("show"),popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width/2+"px",c.style.top=n+"px",j>e/2.5&&(j=e/2.5,pop_content.style.maxHeight=j+"px"),popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),m-popRect.width<=0?(c.style.left=m+"px",c.classList.add("left")):c.classList.remove("left"),m+popRect.width/2>=f?(c.style.left=m-300+"px",popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width+"px",popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),c.classList.add("right")):c.classList.remove("right")}function d(){i[k].classList.add("on")}function g(){i[k].classList.remove("on")}function h(){setTimeout(function(){i[k].classList.remove("show")},100)}var j,k,l,m,n,o,p=a.getAttribute(e);p==f&&(j=a.getAttribute("href"),k=j.replace("#",""),l=b.doc.getElementById(k),a.addEventListener("mouseover",c,!1),a.addEventListener("mouseout",h,!1))}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").smartimages=function(a,b){var c=b.doc.querySelectorAll("img"),d=Array.prototype.slice.call(c),e=b.bodyEl.clientHeight;d.forEach(function(a){function c(){var c,d=a.getBoundingClientRect(),f=d.height,g=d.top,h=a.getAttribute("data-height"),i=h||f;e=b.docEl.clientHeight,0>g&&(g=0),i+g>=e?(e/2>g?(c=e-g,a.style.maxHeight=c+"px",a.style.width="auto"):(c=e>i?i:e,a.style.maxHeight=c+"px",a.style.marginTop=e-g+"px",a.style.width="auto",console.log(c)),a.setAttribute("data-height",c)):(a.style.removeProperty("max-height"),a.style.removeProperty("margin-top"))}a.addEventListener("load",c,!1),b.on("renderer:resized",c),b.on("renderer:chapterUnloaded",function(){a.removeEventListener("load",c),b.off("renderer:resized",c)}),c()}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").transculsions=function(a,b){var c=b.doc.querySelectorAll("[transclusion]"),d=Array.prototype.slice.call(c);d.forEach(function(a){function c(){j=g,k=h,j>b.colWidth&&(d=b.colWidth/j,j=b.colWidth,k*=d),f.width=j,f.height=k}var d,e=a.getAttribute("ref"),f=document.createElement("iframe"),g=a.getAttribute("width"),h=a.getAttribute("height"),i=a.parentNode,j=g,k=h;c(),b.book.listenUntil("book:resized","book:chapterDestroy",c),f.src=e,i.replaceChild(f,a)}),a&&a()};
|
||||
EPUBJS.Hooks.register("beforeChapterDisplay").endnotes=function(a,b){var c=b.doc.querySelectorAll("a[href]"),d=Array.prototype.slice.call(c),e="epub:type",f="noteref",g=EPUBJS.core.folder(location.pathname),h=g+EPUBJS.cssPath||g,i={};EPUBJS.core.addCss(h+"popup.css",!1,b.doc.head),d.forEach(function(a){function c(){var c,e=b.iframe.height,f=b.iframe.width,j=225;o||(c=l.cloneNode(!0),o=c.querySelector("p")),b.replaceLinks.bind(this),i[k]||(i[k]=document.createElement("div"),i[k].setAttribute("class","popup"),pop_content=document.createElement("div"),i[k].appendChild(pop_content),pop_content.appendChild(o),pop_content.setAttribute("class","pop_content"),b.bodyEl.appendChild(i[k]),i[k].addEventListener("mouseover",d,!1),i[k].addEventListener("mouseout",g,!1),b.book.on("renderer:pageChanged",h,this),b.book.on("renderer:pageChanged",g,this)),c=i[k],itemRect=a.getBoundingClientRect(),m=itemRect.left,n=itemRect.top,c.classList.add("show"),popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width/2+"px",c.style.top=n+"px",j>e/2.5&&(j=e/2.5,pop_content.style.maxHeight=j+"px"),popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),m-popRect.width<=0?(c.style.left=m+"px",c.classList.add("left")):c.classList.remove("left"),m+popRect.width/2>=f?(c.style.left=m-300+"px",popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width+"px",popRect.height+n>=e-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),c.classList.add("right")):c.classList.remove("right")}function d(){i[k].classList.add("on")}function g(){i[k].classList.remove("on")}function h(){setTimeout(function(){i[k].classList.remove("show")},100)}var j,k,l,m,n,o,p=a.getAttribute(e);p==f&&(j=a.getAttribute("href"),k=j.replace("#",""),l=b.doc.getElementById(k),a.addEventListener("mouseover",c,!1),a.addEventListener("mouseout",h,!1))}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").smartimages=function(a,b){var c=b.doc.querySelectorAll("img"),d=Array.prototype.slice.call(c),e=b.bodyEl.clientHeight;d.forEach(function(a){function c(){var c,d=a.getBoundingClientRect(),f=d.height,g=d.top,h=a.getAttribute("data-height"),i=h||f;e=b.docEl.clientHeight,0>g&&(g=0),i+g>=e?(e/2>g?(c=e-g,a.style.maxHeight=c+"px",a.style.width="auto"):(c=e>i?i:e,a.style.maxHeight=c+"px",a.style.marginTop=e-g+"px",a.style.width="auto",console.log(c)),a.setAttribute("data-height",c)):(a.style.removeProperty("max-height"),a.style.removeProperty("margin-top"))}a.addEventListener("load",c,!1),b.on("renderer:resized",c),b.on("renderer:chapterUnloaded",function(){a.removeEventListener("load",c),b.off("renderer:resized",c)}),c()}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").transculsions=function(a,b){var c=b.doc.querySelectorAll("[transclusion]"),d=Array.prototype.slice.call(c);d.forEach(function(a){function c(){j=g,k=h,j>b.colWidth&&(d=b.colWidth/j,j=b.colWidth,k*=d),f.width=j,f.height=k}var d,e=a.getAttribute("ref"),f=document.createElement("iframe"),g=a.getAttribute("width"),h=a.getAttribute("height"),i=a.parentNode,j=g,k=h;c(),b.book.listenUntil("book:resized","book:chapterDestroy",c),f.src=e,i.replaceChild(f,a)}),a&&a()};
|
|
@ -49,13 +49,14 @@
|
|||
<style type="text/css">
|
||||
|
||||
body {
|
||||
overflow: hidden;
|
||||
|
||||
}
|
||||
|
||||
#main {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#area {
|
||||
|
@ -103,7 +104,7 @@
|
|||
<script>
|
||||
"use strict";
|
||||
|
||||
var Book = ePub("../demo/moby-dick.epub", {restore: true, reload: true });
|
||||
var Book = ePub("../demo/moby-dick/", {restore: true, reload: false });
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div id="main">
|
||||
<div id="prev" onclick="Book.prevPage();" class="arrow">‹</div>
|
||||
<div id="area"></div>
|
||||
<div id="next" onclick="Book.nextPage();"class="arrow">›</div>
|
||||
<div id="next" onclick="Book.nextPage();" class="arrow">›</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
|
|
@ -45,6 +45,7 @@ EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, chap
|
|||
txt = pop.querySelector("p");
|
||||
}
|
||||
|
||||
chapter.replaceLinks.bind(this)
|
||||
//-- create a popup with endnote inside of it
|
||||
if(!popups[id]) {
|
||||
popups[id] = document.createElement("div");
|
||||
|
|
|
@ -1,289 +1,672 @@
|
|||
(function(exports) {
|
||||
"use strict";
|
||||
var config = {};
|
||||
(function(globals) {
|
||||
var define, requireModule;
|
||||
|
||||
var browserGlobal = (typeof window !== 'undefined') ? window : {};
|
||||
(function() {
|
||||
var registry = {}, seen = {};
|
||||
|
||||
var MutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
|
||||
var RSVP;
|
||||
define = function(name, deps, callback) {
|
||||
registry[name] = { deps: deps, callback: callback };
|
||||
};
|
||||
|
||||
if (typeof process !== 'undefined' &&
|
||||
{}.toString.call(process) === '[object process]') {
|
||||
config.async = function(callback, binding) {
|
||||
process.nextTick(function() {
|
||||
callback.call(binding);
|
||||
requireModule = function(name) {
|
||||
if (seen[name]) { return seen[name]; }
|
||||
seen[name] = {};
|
||||
|
||||
var mod = registry[name];
|
||||
if (!mod) {
|
||||
throw new Error("Module '" + name + "' not found.");
|
||||
}
|
||||
|
||||
var deps = mod.deps,
|
||||
callback = mod.callback,
|
||||
reified = [],
|
||||
exports;
|
||||
|
||||
for (var i=0, l=deps.length; i<l; i++) {
|
||||
if (deps[i] === 'exports') {
|
||||
reified.push(exports = {});
|
||||
} else {
|
||||
reified.push(requireModule(deps[i]));
|
||||
}
|
||||
}
|
||||
|
||||
var value = callback.apply(this, reified);
|
||||
return seen[name] = exports || value;
|
||||
};
|
||||
})();
|
||||
|
||||
define("rsvp/all",
|
||||
["rsvp/promise","exports"],
|
||||
function(__dependency1__, __exports__) {
|
||||
"use strict";
|
||||
var Promise = __dependency1__.Promise;
|
||||
/* global toString */
|
||||
|
||||
|
||||
function all(promises) {
|
||||
if (Object.prototype.toString.call(promises) !== "[object Array]") {
|
||||
throw new TypeError('You must pass an array to all.');
|
||||
}
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
var results = [], remaining = promises.length,
|
||||
promise;
|
||||
|
||||
if (remaining === 0) {
|
||||
resolve([]);
|
||||
}
|
||||
|
||||
function resolver(index) {
|
||||
return function(value) {
|
||||
resolveAll(index, value);
|
||||
};
|
||||
}
|
||||
|
||||
function resolveAll(index, value) {
|
||||
results[index] = value;
|
||||
if (--remaining === 0) {
|
||||
resolve(results);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < promises.length; i++) {
|
||||
promise = promises[i];
|
||||
|
||||
if (promise && typeof promise.then === 'function') {
|
||||
promise.then(resolver(i), reject);
|
||||
} else {
|
||||
resolveAll(i, promise);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
} else if (MutationObserver) {
|
||||
}
|
||||
|
||||
|
||||
__exports__.all = all;
|
||||
});
|
||||
define("rsvp/async",
|
||||
["exports"],
|
||||
function(__exports__) {
|
||||
"use strict";
|
||||
var browserGlobal = (typeof window !== 'undefined') ? window : {};
|
||||
var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
|
||||
var local = (typeof global !== 'undefined') ? global : this;
|
||||
|
||||
// node
|
||||
function useNextTick() {
|
||||
return function() {
|
||||
process.nextTick(flush);
|
||||
};
|
||||
}
|
||||
|
||||
function useMutationObserver() {
|
||||
var observer = new BrowserMutationObserver(flush);
|
||||
var element = document.createElement('div');
|
||||
observer.observe(element, { attributes: true });
|
||||
|
||||
// Chrome Memory Leak: https://bugs.webkit.org/show_bug.cgi?id=93661
|
||||
window.addEventListener('unload', function(){
|
||||
observer.disconnect();
|
||||
observer = null;
|
||||
}, false);
|
||||
|
||||
return function() {
|
||||
element.setAttribute('drainQueue', 'drainQueue');
|
||||
};
|
||||
}
|
||||
|
||||
function useSetTimeout() {
|
||||
return function() {
|
||||
local.setTimeout(flush, 1);
|
||||
};
|
||||
}
|
||||
|
||||
var queue = [];
|
||||
|
||||
var observer = new MutationObserver(function() {
|
||||
var toProcess = queue.slice();
|
||||
function flush() {
|
||||
for (var i = 0; i < queue.length; i++) {
|
||||
var tuple = queue[i];
|
||||
var callback = tuple[0], arg = tuple[1];
|
||||
callback(arg);
|
||||
}
|
||||
queue = [];
|
||||
}
|
||||
|
||||
toProcess.forEach(function(tuple) {
|
||||
var callback = tuple[0], binding = tuple[1];
|
||||
callback.call(binding);
|
||||
var scheduleFlush;
|
||||
|
||||
// Decide what async method to use to triggering processing of queued callbacks:
|
||||
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
|
||||
scheduleFlush = useNextTick();
|
||||
} else if (BrowserMutationObserver) {
|
||||
scheduleFlush = useMutationObserver();
|
||||
} else {
|
||||
scheduleFlush = useSetTimeout();
|
||||
}
|
||||
|
||||
function async(callback, arg) {
|
||||
var length = queue.push([callback, arg]);
|
||||
if (length === 1) {
|
||||
// If length is 1, that means that we need to schedule an async flush.
|
||||
// If additional callbacks are queued before the queue is flushed, they
|
||||
// will be processed by this flush that we are scheduling.
|
||||
scheduleFlush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__exports__.async = async;
|
||||
});
|
||||
define("rsvp/config",
|
||||
["rsvp/async","exports"],
|
||||
function(__dependency1__, __exports__) {
|
||||
"use strict";
|
||||
var async = __dependency1__.async;
|
||||
|
||||
var config = {};
|
||||
config.async = async;
|
||||
|
||||
|
||||
__exports__.config = config;
|
||||
});
|
||||
define("rsvp/defer",
|
||||
["rsvp/promise","exports"],
|
||||
function(__dependency1__, __exports__) {
|
||||
"use strict";
|
||||
var Promise = __dependency1__.Promise;
|
||||
|
||||
function defer() {
|
||||
var deferred = {
|
||||
// pre-allocate shape
|
||||
resolve: undefined,
|
||||
reject: undefined,
|
||||
promise: undefined
|
||||
};
|
||||
|
||||
deferred.promise = new Promise(function(resolve, reject) {
|
||||
deferred.resolve = resolve;
|
||||
deferred.reject = reject;
|
||||
});
|
||||
});
|
||||
|
||||
var element = document.createElement('div');
|
||||
observer.observe(element, { attributes: true });
|
||||
|
||||
// Chrome Memory Leak: https://bugs.webkit.org/show_bug.cgi?id=93661
|
||||
window.addEventListener('unload', function(){
|
||||
observer.disconnect();
|
||||
observer = null;
|
||||
});
|
||||
|
||||
config.async = function(callback, binding) {
|
||||
queue.push([callback, binding]);
|
||||
element.setAttribute('drainQueue', 'drainQueue');
|
||||
};
|
||||
} else {
|
||||
config.async = function(callback, binding) {
|
||||
setTimeout(function() {
|
||||
callback.call(binding);
|
||||
}, 1);
|
||||
};
|
||||
}
|
||||
|
||||
var Event = function(type, options) {
|
||||
this.type = type;
|
||||
|
||||
for (var option in options) {
|
||||
if (!options.hasOwnProperty(option)) { continue; }
|
||||
|
||||
this[option] = options[option];
|
||||
}
|
||||
};
|
||||
|
||||
var indexOf = function(callbacks, callback) {
|
||||
for (var i=0, l=callbacks.length; i<l; i++) {
|
||||
if (callbacks[i][0] === callback) { return i; }
|
||||
return deferred;
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
||||
var callbacksFor = function(object) {
|
||||
var callbacks = object._promiseCallbacks;
|
||||
__exports__.defer = defer;
|
||||
});
|
||||
define("rsvp/events",
|
||||
["exports"],
|
||||
function(__exports__) {
|
||||
"use strict";
|
||||
var Event = function(type, options) {
|
||||
this.type = type;
|
||||
|
||||
if (!callbacks) {
|
||||
callbacks = object._promiseCallbacks = {};
|
||||
}
|
||||
for (var option in options) {
|
||||
if (!options.hasOwnProperty(option)) { continue; }
|
||||
|
||||
return callbacks;
|
||||
};
|
||||
|
||||
var EventTarget = {
|
||||
mixin: function(object) {
|
||||
object.on = this.on;
|
||||
object.off = this.off;
|
||||
object.trigger = this.trigger;
|
||||
return object;
|
||||
},
|
||||
|
||||
on: function(eventNames, callback, binding) {
|
||||
var allCallbacks = callbacksFor(this), callbacks, eventName;
|
||||
eventNames = eventNames.split(/\s+/);
|
||||
binding = binding || this;
|
||||
|
||||
while (eventName = eventNames.shift()) {
|
||||
callbacks = allCallbacks[eventName];
|
||||
|
||||
if (!callbacks) {
|
||||
callbacks = allCallbacks[eventName] = [];
|
||||
}
|
||||
|
||||
if (indexOf(callbacks, callback) === -1) {
|
||||
callbacks.push([callback, binding]);
|
||||
}
|
||||
this[option] = options[option];
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
off: function(eventNames, callback) {
|
||||
var allCallbacks = callbacksFor(this), callbacks, eventName, index;
|
||||
eventNames = eventNames.split(/\s+/);
|
||||
|
||||
while (eventName = eventNames.shift()) {
|
||||
if (!callback) {
|
||||
allCallbacks[eventName] = [];
|
||||
continue;
|
||||
}
|
||||
|
||||
callbacks = allCallbacks[eventName];
|
||||
|
||||
index = indexOf(callbacks, callback);
|
||||
|
||||
if (index !== -1) { callbacks.splice(index, 1); }
|
||||
var indexOf = function(callbacks, callback) {
|
||||
for (var i=0, l=callbacks.length; i<l; i++) {
|
||||
if (callbacks[i][0] === callback) { return i; }
|
||||
}
|
||||
},
|
||||
|
||||
trigger: function(eventName, options) {
|
||||
var allCallbacks = callbacksFor(this),
|
||||
callbacks, callbackTuple, callback, binding, event;
|
||||
return -1;
|
||||
};
|
||||
|
||||
if (callbacks = allCallbacks[eventName]) {
|
||||
for (var i=0, l=callbacks.length; i<l; i++) {
|
||||
callbackTuple = callbacks[i];
|
||||
callback = callbackTuple[0];
|
||||
binding = callbackTuple[1];
|
||||
var callbacksFor = function(object) {
|
||||
var callbacks = object._promiseCallbacks;
|
||||
|
||||
if (typeof options !== 'object') {
|
||||
options = { detail: options };
|
||||
if (!callbacks) {
|
||||
callbacks = object._promiseCallbacks = {};
|
||||
}
|
||||
|
||||
return callbacks;
|
||||
};
|
||||
|
||||
var EventTarget = {
|
||||
mixin: function(object) {
|
||||
object.on = this.on;
|
||||
object.off = this.off;
|
||||
object.trigger = this.trigger;
|
||||
return object;
|
||||
},
|
||||
|
||||
on: function(eventNames, callback, binding) {
|
||||
var allCallbacks = callbacksFor(this), callbacks, eventName;
|
||||
eventNames = eventNames.split(/\s+/);
|
||||
binding = binding || this;
|
||||
|
||||
while (eventName = eventNames.shift()) {
|
||||
callbacks = allCallbacks[eventName];
|
||||
|
||||
if (!callbacks) {
|
||||
callbacks = allCallbacks[eventName] = [];
|
||||
}
|
||||
|
||||
event = new Event(eventName, options);
|
||||
callback.call(binding, event);
|
||||
if (indexOf(callbacks, callback) === -1) {
|
||||
callbacks.push([callback, binding]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
off: function(eventNames, callback) {
|
||||
var allCallbacks = callbacksFor(this), callbacks, eventName, index;
|
||||
eventNames = eventNames.split(/\s+/);
|
||||
|
||||
while (eventName = eventNames.shift()) {
|
||||
if (!callback) {
|
||||
allCallbacks[eventName] = [];
|
||||
continue;
|
||||
}
|
||||
|
||||
callbacks = allCallbacks[eventName];
|
||||
|
||||
index = indexOf(callbacks, callback);
|
||||
|
||||
if (index !== -1) { callbacks.splice(index, 1); }
|
||||
}
|
||||
},
|
||||
|
||||
trigger: function(eventName, options) {
|
||||
var allCallbacks = callbacksFor(this),
|
||||
callbacks, callbackTuple, callback, binding, event;
|
||||
|
||||
if (callbacks = allCallbacks[eventName]) {
|
||||
// Don't cache the callbacks.length since it may grow
|
||||
for (var i=0; i<callbacks.length; i++) {
|
||||
callbackTuple = callbacks[i];
|
||||
callback = callbackTuple[0];
|
||||
binding = callbackTuple[1];
|
||||
|
||||
if (typeof options !== 'object') {
|
||||
options = { detail: options };
|
||||
}
|
||||
|
||||
event = new Event(eventName, options);
|
||||
callback.call(binding, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var Promise = function() {
|
||||
this.on('promise:resolved', function(event) {
|
||||
this.trigger('success', { detail: event.detail });
|
||||
}, this);
|
||||
|
||||
this.on('promise:failed', function(event) {
|
||||
this.trigger('error', { detail: event.detail });
|
||||
}, this);
|
||||
};
|
||||
__exports__.EventTarget = EventTarget;
|
||||
});
|
||||
define("rsvp/hash",
|
||||
["rsvp/defer","exports"],
|
||||
function(__dependency1__, __exports__) {
|
||||
"use strict";
|
||||
var defer = __dependency1__.defer;
|
||||
|
||||
var noop = function() {};
|
||||
function size(object) {
|
||||
var s = 0;
|
||||
|
||||
var invokeCallback = function(type, promise, callback, event) {
|
||||
var hasCallback = typeof callback === 'function',
|
||||
value, error, succeeded, failed;
|
||||
|
||||
if (hasCallback) {
|
||||
try {
|
||||
value = callback(event.detail);
|
||||
succeeded = true;
|
||||
} catch(e) {
|
||||
failed = true;
|
||||
error = e;
|
||||
}
|
||||
} else {
|
||||
value = event.detail;
|
||||
succeeded = true;
|
||||
}
|
||||
|
||||
if (value && typeof value.then === 'function') {
|
||||
value.then(function(value) {
|
||||
promise.resolve(value);
|
||||
}, function(error) {
|
||||
promise.reject(error);
|
||||
});
|
||||
} else if (hasCallback && succeeded) {
|
||||
promise.resolve(value);
|
||||
} else if (failed) {
|
||||
promise.reject(error);
|
||||
} else {
|
||||
promise[type](value);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype = {
|
||||
then: function(done, fail) {
|
||||
var thenPromise = new Promise();
|
||||
|
||||
if (this.isResolved) {
|
||||
config.async(function() {
|
||||
invokeCallback('resolve', thenPromise, done, { detail: this.resolvedValue });
|
||||
}, this);
|
||||
for (var prop in object) {
|
||||
s++;
|
||||
}
|
||||
|
||||
if (this.isRejected) {
|
||||
config.async(function() {
|
||||
invokeCallback('reject', thenPromise, fail, { detail: this.rejectedValue });
|
||||
}, this);
|
||||
return s;
|
||||
}
|
||||
|
||||
function hash(promises) {
|
||||
var results = {}, deferred = defer(), remaining = size(promises);
|
||||
|
||||
if (remaining === 0) {
|
||||
deferred.resolve({});
|
||||
}
|
||||
|
||||
this.on('promise:resolved', function(event) {
|
||||
invokeCallback('resolve', thenPromise, done, event);
|
||||
});
|
||||
var resolver = function(prop) {
|
||||
return function(value) {
|
||||
resolveAll(prop, value);
|
||||
};
|
||||
};
|
||||
|
||||
var resolveAll = function(prop, value) {
|
||||
results[prop] = value;
|
||||
if (--remaining === 0) {
|
||||
deferred.resolve(results);
|
||||
}
|
||||
};
|
||||
|
||||
var rejectAll = function(error) {
|
||||
deferred.reject(error);
|
||||
};
|
||||
|
||||
for (var prop in promises) {
|
||||
if (promises[prop] && typeof promises[prop].then === 'function') {
|
||||
promises[prop].then(resolver(prop), rejectAll);
|
||||
} else {
|
||||
resolveAll(prop, promises[prop]);
|
||||
}
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
__exports__.hash = hash;
|
||||
});
|
||||
define("rsvp/node",
|
||||
["rsvp/promise","rsvp/all","exports"],
|
||||
function(__dependency1__, __dependency2__, __exports__) {
|
||||
"use strict";
|
||||
var Promise = __dependency1__.Promise;
|
||||
var all = __dependency2__.all;
|
||||
|
||||
function makeNodeCallbackFor(resolve, reject) {
|
||||
return function (error, value) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else if (arguments.length > 2) {
|
||||
resolve(Array.prototype.slice.call(arguments, 1));
|
||||
} else {
|
||||
resolve(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function denodeify(nodeFunc) {
|
||||
return function() {
|
||||
var nodeArgs = Array.prototype.slice.call(arguments), resolve, reject;
|
||||
var thisArg = this;
|
||||
|
||||
var promise = new Promise(function(nodeResolve, nodeReject) {
|
||||
resolve = nodeResolve;
|
||||
reject = nodeReject;
|
||||
});
|
||||
|
||||
all(nodeArgs).then(function(nodeArgs) {
|
||||
nodeArgs.push(makeNodeCallbackFor(resolve, reject));
|
||||
|
||||
try {
|
||||
nodeFunc.apply(thisArg, nodeArgs);
|
||||
} catch(e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
|
||||
return promise;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
__exports__.denodeify = denodeify;
|
||||
});
|
||||
define("rsvp/promise",
|
||||
["rsvp/config","rsvp/events","exports"],
|
||||
function(__dependency1__, __dependency2__, __exports__) {
|
||||
"use strict";
|
||||
var config = __dependency1__.config;
|
||||
var EventTarget = __dependency2__.EventTarget;
|
||||
|
||||
function objectOrFunction(x) {
|
||||
return isFunction(x) || (typeof x === "object" && x !== null);
|
||||
}
|
||||
|
||||
function isFunction(x){
|
||||
return typeof x === "function";
|
||||
}
|
||||
|
||||
var Promise = function(resolver) {
|
||||
var promise = this,
|
||||
resolved = false;
|
||||
|
||||
if (typeof resolver !== 'function') {
|
||||
throw new TypeError('You must pass a resolver function as the sole argument to the promise constructor');
|
||||
}
|
||||
|
||||
if (!(promise instanceof Promise)) {
|
||||
return new Promise(resolver);
|
||||
}
|
||||
|
||||
var resolvePromise = function(value) {
|
||||
if (resolved) { return; }
|
||||
resolved = true;
|
||||
resolve(promise, value);
|
||||
};
|
||||
|
||||
var rejectPromise = function(value) {
|
||||
if (resolved) { return; }
|
||||
resolved = true;
|
||||
reject(promise, value);
|
||||
};
|
||||
|
||||
this.on('promise:failed', function(event) {
|
||||
invokeCallback('reject', thenPromise, fail, event);
|
||||
});
|
||||
this.trigger('error', { detail: event.detail });
|
||||
}, this);
|
||||
|
||||
return thenPromise;
|
||||
},
|
||||
this.on('error', onerror);
|
||||
|
||||
resolve: function(value) {
|
||||
resolve(this, value);
|
||||
|
||||
this.resolve = noop;
|
||||
this.reject = noop;
|
||||
},
|
||||
|
||||
reject: function(value) {
|
||||
reject(this, value);
|
||||
|
||||
this.resolve = noop;
|
||||
this.reject = noop;
|
||||
}
|
||||
};
|
||||
|
||||
function resolve(promise, value) {
|
||||
config.async(function() {
|
||||
promise.trigger('promise:resolved', { detail: value });
|
||||
promise.isResolved = true;
|
||||
promise.resolvedValue = value;
|
||||
});
|
||||
}
|
||||
|
||||
function reject(promise, value) {
|
||||
config.async(function() {
|
||||
promise.trigger('promise:failed', { detail: value });
|
||||
promise.isRejected = true;
|
||||
promise.rejectedValue = value;
|
||||
});
|
||||
}
|
||||
|
||||
function all(promises) {
|
||||
var i, results = [];
|
||||
var allPromise = new Promise();
|
||||
var remaining = promises.length;
|
||||
|
||||
if (remaining === 0) {
|
||||
allPromise.resolve([]);
|
||||
}
|
||||
|
||||
var resolver = function(index) {
|
||||
return function(value) {
|
||||
resolve(index, value);
|
||||
};
|
||||
};
|
||||
|
||||
var resolve = function(index, value) {
|
||||
results[index] = value;
|
||||
if (--remaining === 0) {
|
||||
allPromise.resolve(results);
|
||||
try {
|
||||
resolver(resolvePromise, rejectPromise);
|
||||
} catch(e) {
|
||||
rejectPromise(e);
|
||||
}
|
||||
};
|
||||
|
||||
var reject = function(error) {
|
||||
allPromise.reject(error);
|
||||
function onerror(event) {
|
||||
if (config.onerror) {
|
||||
config.onerror(event.detail);
|
||||
}
|
||||
}
|
||||
|
||||
var invokeCallback = function(type, promise, callback, event) {
|
||||
var hasCallback = isFunction(callback),
|
||||
value, error, succeeded, failed;
|
||||
|
||||
if (hasCallback) {
|
||||
try {
|
||||
value = callback(event.detail);
|
||||
succeeded = true;
|
||||
} catch(e) {
|
||||
failed = true;
|
||||
error = e;
|
||||
}
|
||||
} else {
|
||||
value = event.detail;
|
||||
succeeded = true;
|
||||
}
|
||||
|
||||
if (handleThenable(promise, value)) {
|
||||
return;
|
||||
} else if (hasCallback && succeeded) {
|
||||
resolve(promise, value);
|
||||
} else if (failed) {
|
||||
reject(promise, error);
|
||||
} else if (type === 'resolve') {
|
||||
resolve(promise, value);
|
||||
} else if (type === 'reject') {
|
||||
reject(promise, value);
|
||||
}
|
||||
};
|
||||
|
||||
for (i = 0; i < remaining; i++) {
|
||||
promises[i].then(resolver(i), reject);
|
||||
Promise.prototype = {
|
||||
constructor: Promise,
|
||||
|
||||
isRejected: undefined,
|
||||
isFulfilled: undefined,
|
||||
rejectedReason: undefined,
|
||||
fulfillmentValue: undefined,
|
||||
|
||||
then: function(done, fail) {
|
||||
this.off('error', onerror);
|
||||
|
||||
var thenPromise = new this.constructor(function() {});
|
||||
|
||||
if (this.isFulfilled) {
|
||||
config.async(function(promise) {
|
||||
invokeCallback('resolve', thenPromise, done, { detail: promise.fulfillmentValue });
|
||||
}, this);
|
||||
}
|
||||
|
||||
if (this.isRejected) {
|
||||
config.async(function(promise) {
|
||||
invokeCallback('reject', thenPromise, fail, { detail: promise.rejectedReason });
|
||||
}, this);
|
||||
}
|
||||
|
||||
this.on('promise:resolved', function(event) {
|
||||
invokeCallback('resolve', thenPromise, done, event);
|
||||
});
|
||||
|
||||
this.on('promise:failed', function(event) {
|
||||
invokeCallback('reject', thenPromise, fail, event);
|
||||
});
|
||||
|
||||
return thenPromise;
|
||||
},
|
||||
|
||||
fail: function(fail) {
|
||||
return this.then(null, fail);
|
||||
}
|
||||
};
|
||||
|
||||
EventTarget.mixin(Promise.prototype);
|
||||
|
||||
function resolve(promise, value) {
|
||||
if (promise === value) {
|
||||
fulfill(promise, value);
|
||||
} else if (!handleThenable(promise, value)) {
|
||||
fulfill(promise, value);
|
||||
}
|
||||
}
|
||||
return allPromise;
|
||||
}
|
||||
|
||||
EventTarget.mixin(Promise.prototype);
|
||||
function handleThenable(promise, value) {
|
||||
var then = null,
|
||||
resolved;
|
||||
|
||||
function configure(name, value) {
|
||||
config[name] = value;
|
||||
}
|
||||
try {
|
||||
if (promise === value) {
|
||||
throw new TypeError("A promises callback cannot return that same promise.");
|
||||
}
|
||||
|
||||
exports.Promise = Promise;
|
||||
exports.Event = Event;
|
||||
exports.EventTarget = EventTarget;
|
||||
exports.all = all;
|
||||
exports.configure = configure;
|
||||
})(window.RSVP = {});
|
||||
if (objectOrFunction(value)) {
|
||||
then = value.then;
|
||||
|
||||
if (isFunction(then)) {
|
||||
then.call(value, function(val) {
|
||||
if (resolved) { return true; }
|
||||
resolved = true;
|
||||
|
||||
if (value !== val) {
|
||||
resolve(promise, val);
|
||||
} else {
|
||||
fulfill(promise, val);
|
||||
}
|
||||
}, function(val) {
|
||||
if (resolved) { return true; }
|
||||
resolved = true;
|
||||
|
||||
reject(promise, val);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
reject(promise, error);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function fulfill(promise, value) {
|
||||
config.async(function() {
|
||||
promise.trigger('promise:resolved', { detail: value });
|
||||
promise.isFulfilled = true;
|
||||
promise.fulfillmentValue = value;
|
||||
});
|
||||
}
|
||||
|
||||
function reject(promise, value) {
|
||||
config.async(function() {
|
||||
promise.trigger('promise:failed', { detail: value });
|
||||
promise.isRejected = true;
|
||||
promise.rejectedReason = value;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
__exports__.Promise = Promise;
|
||||
});
|
||||
define("rsvp/reject",
|
||||
["rsvp/promise","exports"],
|
||||
function(__dependency1__, __exports__) {
|
||||
"use strict";
|
||||
var Promise = __dependency1__.Promise;
|
||||
|
||||
function reject(reason) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
reject(reason);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
__exports__.reject = reject;
|
||||
});
|
||||
define("rsvp/resolve",
|
||||
["rsvp/promise","exports"],
|
||||
function(__dependency1__, __exports__) {
|
||||
"use strict";
|
||||
var Promise = __dependency1__.Promise;
|
||||
|
||||
function resolve(thenable) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve(thenable);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
__exports__.resolve = resolve;
|
||||
});
|
||||
define("rsvp/rethrow",
|
||||
["exports"],
|
||||
function(__exports__) {
|
||||
"use strict";
|
||||
var local = (typeof global === "undefined") ? this : global;
|
||||
|
||||
function rethrow(reason) {
|
||||
local.setTimeout(function() {
|
||||
throw reason;
|
||||
});
|
||||
throw reason;
|
||||
}
|
||||
|
||||
|
||||
__exports__.rethrow = rethrow;
|
||||
});
|
||||
define("rsvp",
|
||||
["rsvp/events","rsvp/promise","rsvp/node","rsvp/all","rsvp/hash","rsvp/rethrow","rsvp/defer","rsvp/config","rsvp/resolve","rsvp/reject","exports"],
|
||||
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __exports__) {
|
||||
"use strict";
|
||||
var EventTarget = __dependency1__.EventTarget;
|
||||
var Promise = __dependency2__.Promise;
|
||||
var denodeify = __dependency3__.denodeify;
|
||||
var all = __dependency4__.all;
|
||||
var hash = __dependency5__.hash;
|
||||
var rethrow = __dependency6__.rethrow;
|
||||
var defer = __dependency7__.defer;
|
||||
var config = __dependency8__.config;
|
||||
var resolve = __dependency9__.resolve;
|
||||
var reject = __dependency10__.reject;
|
||||
|
||||
function configure(name, value) {
|
||||
config[name] = value;
|
||||
}
|
||||
|
||||
|
||||
__exports__.Promise = Promise;
|
||||
__exports__.EventTarget = EventTarget;
|
||||
__exports__.all = all;
|
||||
__exports__.hash = hash;
|
||||
__exports__.rethrow = rethrow;
|
||||
__exports__.defer = defer;
|
||||
__exports__.denodeify = denodeify;
|
||||
__exports__.configure = configure;
|
||||
__exports__.resolve = resolve;
|
||||
__exports__.reject = reject;
|
||||
});
|
||||
window.RSVP = requireModule("rsvp");
|
||||
})(window);
|
1
libs/rsvp/rsvp.min.js
vendored
1
libs/rsvp/rsvp.min.js
vendored
|
@ -1 +0,0 @@
|
|||
(function(e){"use strict";function v(e,n){t.async(function(){e.trigger("promise:resolved",{detail:n}),e.isResolved=!0,e.resolvedValue=n})}function m(e,n){t.async(function(){e.trigger("promise:failed",{detail:n}),e.isRejected=!0,e.rejectedValue=n})}function g(e){var t,n=[],r=new h,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<i;t++)e[t].then(s(t),u);return r}function y(e,n){t[e]=n}var t={},n=typeof window!="undefined"?window:{},r=n.MutationObserver||n.WebKitMutationObserver,i;if(typeof process!="undefined"&&{}.toString.call(process)==="[object process]")t.async=function(e,t){process.nextTick(function(){e.call(t)})};else if(r){var s=[],o=new r(function(){var e=s.slice();s=[],e.forEach(function(e){var t=e[0],n=e[1];t.call(n)})}),u=document.createElement("div");o.observe(u,{attributes:!0}),window.addEventListener("unload",function(){o.disconnect(),o=null}),t.async=function(e,t){s.push([e,t]),u.setAttribute("drainQueue","drainQueue")}}else t.async=function(e,t){setTimeout(function(){e.call(t)},1)};var a=function(e,t){this.type=e;for(var n in t){if(!t.hasOwnProperty(n))continue;this[n]=t[n]}},f=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n][0]===t)return n;return-1},l=function(e){var t=e._promiseCallbacks;return t||(t=e._promiseCallbacks={}),t},c={mixin:function(e){return e.on=this.on,e.off=this.off,e.trigger=this.trigger,e},on:function(e,t,n){var r=l(this),i,s;e=e.split(/\s+/),n=n||this;while(s=e.shift())i=r[s],i||(i=r[s]=[]),f(i,t)===-1&&i.push([t,n])},off:function(e,t){var n=l(this),r,i,s;e=e.split(/\s+/);while(i=e.shift()){if(!t){n[i]=[];continue}r=n[i],s=f(r,t),s!==-1&&r.splice(s,1)}},trigger:function(e,t){var n=l(this),r,i,s,o,u;if(r=n[e])for(var f=0,c=r.length;f<c;f++)i=r[f],s=i[0],o=i[1],typeof t!="object"&&(t={detail:t}),u=new a(e,t),s.call(o,u)}},h=function(){this.on("promise:resolved",function(e){this.trigger("success",{detail:e.detail})},this),this.on("promise:failed",function(e){this.trigger("error",{detail:e.detail})},this)},p=function(){},d=function(e,t,n,r){var i=typeof n=="function",s,o,u,a;if(i)try{s=n(r.detail),u=!0}catch(f){a=!0,o=f}else s=r.detail,u=!0;s&&typeof s.then=="function"?s.then(function(e){t.resolve(e)},function(e){t.reject(e)}):i&&u?t.resolve(s):a?t.reject(o):t[e](s)};h.prototype={then:function(e,n){var r=new h;return this.isResolved&&t.async(function(){d("resolve",r,e,{detail:this.resolvedValue})},this),this.isRejected&&t.async(function(){d("reject",r,n,{detail:this.rejectedValue})},this),this.on("promise:resolved",function(t){d("resolve",r,e,t)}),this.on("promise:failed",function(e){d("reject",r,n,e)}),r},resolve:function(e){v(this,e),this.resolve=p,this.reject=p},reject:function(e){m(this,e),this.resolve=p,this.reject=p}},c.mixin(h.prototype),e.Promise=h,e.Event=a,e.EventTarget=c,e.all=g,e.configure=y})(window.RSVP={});
|
88
src/book.js
88
src/book.js
|
@ -56,14 +56,22 @@ EPUBJS.Book = function(options){
|
|||
|
||||
|
||||
this.ready = {
|
||||
manifest: new RSVP.Promise(),
|
||||
spine: new RSVP.Promise(),
|
||||
metadata: new RSVP.Promise(),
|
||||
cover: new RSVP.Promise(),
|
||||
toc: new RSVP.Promise()
|
||||
manifest: new RSVP.defer(),
|
||||
spine: new RSVP.defer(),
|
||||
metadata: new RSVP.defer(),
|
||||
cover: new RSVP.defer(),
|
||||
toc: new RSVP.defer()
|
||||
};
|
||||
|
||||
this.ready.all = RSVP.all(_.values(this.ready));
|
||||
this.readyPromises = [
|
||||
this.ready.manifest.promise,
|
||||
this.ready.spine.promise,
|
||||
this.ready.metadata.promise,
|
||||
this.ready.cover.promise,
|
||||
this.ready.toc.promise
|
||||
];
|
||||
|
||||
this.ready.all = RSVP.all(this.readyPromises);
|
||||
|
||||
this.ready.all.then(this._ready);
|
||||
|
||||
|
@ -72,7 +80,8 @@ EPUBJS.Book = function(options){
|
|||
this._rendering = false;
|
||||
this._displayQ = [];
|
||||
|
||||
this.opened = new RSVP.Promise();
|
||||
this.defer_opened = new RSVP.defer();
|
||||
this.opened = this.defer_opened.promise;
|
||||
// BookUrl is optional, but if present start loading process
|
||||
if(this.settings.bookPath) {
|
||||
this.open(this.settings.bookPath, this.settings.reload);
|
||||
|
@ -144,7 +153,7 @@ EPUBJS.Book.prototype.open = function(bookPath, forceReload){
|
|||
}
|
||||
|
||||
opened.then(function(){
|
||||
book.opened.resolve();
|
||||
book.defer_opened.resolve();
|
||||
});
|
||||
|
||||
return opened;
|
||||
|
@ -195,7 +204,7 @@ EPUBJS.Book.prototype.unpack = function(containerPath){
|
|||
|
||||
book.loadXml(book.settings.tocUrl).
|
||||
then(function(tocXml){
|
||||
return parse.toc(tocXml); // Grab Table of Contents
|
||||
return parse.toc(tocXml); // Grab Table of Contents
|
||||
}).then(function(toc){
|
||||
book.toc = book.contents.toc = toc;
|
||||
book.ready.toc.resolve(book.contents.toc);
|
||||
|
@ -205,7 +214,7 @@ EPUBJS.Book.prototype.unpack = function(containerPath){
|
|||
}
|
||||
|
||||
}).
|
||||
then(null, function(error) {
|
||||
fail(function(error) {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
|
@ -213,11 +222,11 @@ EPUBJS.Book.prototype.unpack = function(containerPath){
|
|||
}
|
||||
|
||||
EPUBJS.Book.prototype.getMetadata = function() {
|
||||
return this.ready.metadata;
|
||||
return this.ready.metadata.promise;
|
||||
}
|
||||
|
||||
EPUBJS.Book.prototype.getToc = function() {
|
||||
return this.ready.toc;
|
||||
return this.ready.toc.promise;
|
||||
}
|
||||
|
||||
/* Private Helpers */
|
||||
|
@ -255,10 +264,18 @@ EPUBJS.Book.prototype.urlFrom = function(bookPath){
|
|||
fromRoot = bookPath[0] == "/",
|
||||
location = window.location,
|
||||
//-- Get URL orgin, try for native or combine
|
||||
origin = location.origin || location.protocol + "//" + location.host;
|
||||
origin = location.origin || location.protocol + "//" + location.host,
|
||||
baseTag = document.getElementsByTagName('base'),
|
||||
base;
|
||||
|
||||
// if(bookPath[bookPath.length - 1] != "/") bookPath += "/";
|
||||
|
||||
//-- Check is Base tag is set
|
||||
|
||||
if(baseTag.length) {
|
||||
base = baseTag[0].href;
|
||||
}
|
||||
|
||||
//-- 1. Check if url is absolute
|
||||
if(absolute){
|
||||
return bookPath;
|
||||
|
@ -266,7 +283,11 @@ EPUBJS.Book.prototype.urlFrom = function(bookPath){
|
|||
|
||||
//-- 2. Check if url starts with /, add base url
|
||||
if(!absolute && fromRoot){
|
||||
return origin + bookPath;
|
||||
if(base) {
|
||||
return base + bookPath;
|
||||
} else {
|
||||
return origin + bookPath;
|
||||
}
|
||||
}
|
||||
|
||||
//-- 3. Or find full path to url and add that
|
||||
|
@ -274,10 +295,15 @@ EPUBJS.Book.prototype.urlFrom = function(bookPath){
|
|||
|
||||
//-- go back
|
||||
if(bookPath.slice(0, 3) == "../"){
|
||||
return EPUBJS.core.resolveUrl(location.href, bookPath);
|
||||
return EPUBJS.core.resolveUrl(base || location.pathname, bookPath);
|
||||
}
|
||||
|
||||
if(base) {
|
||||
return base + bookPath;
|
||||
} else {
|
||||
return origin + EPUBJS.core.folder(location.pathname) + bookPath;
|
||||
}
|
||||
|
||||
return origin + EPUBJS.core.folder(location.pathname) + bookPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -407,7 +433,9 @@ EPUBJS.Book.prototype.startDisplay = function(){
|
|||
display = this.displayChapter(this.settings.previousLocationCfi);
|
||||
|
||||
}else{
|
||||
|
||||
display = this.displayChapter(this.spinePos);
|
||||
|
||||
}
|
||||
|
||||
return display;
|
||||
|
@ -417,7 +445,7 @@ EPUBJS.Book.prototype.restore = function(reject){
|
|||
|
||||
var book = this,
|
||||
contentsKey = this.settings.bookPath + ":contents:" + this.settings.version,
|
||||
promise = new RSVP.Promise(),
|
||||
deferred = new RSVP.defer(),
|
||||
fetch = ['manifest', 'spine', 'metadata', 'cover', 'toc', 'spineNodeIndex', 'spineIndexByURL'],
|
||||
reject = reject || false,
|
||||
fromStore = localStorage.getItem(contentsKey);
|
||||
|
@ -444,8 +472,8 @@ EPUBJS.Book.prototype.restore = function(reject){
|
|||
this.ready.metadata.resolve(this.metadata);
|
||||
this.ready.cover.resolve(this.cover);
|
||||
this.ready.toc.resolve(this.toc);
|
||||
promise.resolve();
|
||||
return promise;
|
||||
deferred.resolve();
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
|
@ -473,14 +501,8 @@ EPUBJS.Book.prototype.displayChapter = function(chap, end){
|
|||
pos = cfi.spinePos;
|
||||
}
|
||||
|
||||
|
||||
if(pos >= this.spine.length){
|
||||
// console.log("Reached End of Book");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(pos < 0){
|
||||
// console.log("Reached Start of Book");
|
||||
if(pos < 0 || pos >= this.spine.length){
|
||||
console.error("Not A Valid Chapter");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -555,19 +577,26 @@ EPUBJS.Book.prototype.prevPage = function() {
|
|||
|
||||
EPUBJS.Book.prototype.nextChapter = function() {
|
||||
this.spinePos++;
|
||||
if(this.spinePos > this.spine.length) return;
|
||||
|
||||
return this.displayChapter(this.spinePos);
|
||||
}
|
||||
|
||||
EPUBJS.Book.prototype.prevChapter = function() {
|
||||
this.spinePos--;
|
||||
if(this.spinePos < 0) return;
|
||||
|
||||
return this.displayChapter(this.spinePos, true);
|
||||
}
|
||||
|
||||
EPUBJS.Book.prototype.gotoCfi = function(cfi){
|
||||
if(!this.isRendered) return this._enqueue("gotoCfi", arguments);
|
||||
return this.displayChapter(cfi)
|
||||
}
|
||||
|
||||
EPUBJS.Book.prototype.goto = function(url){
|
||||
var split, chapter, section, absoluteURL, spinePos;
|
||||
|
||||
var deferred = new RSVP.defer();
|
||||
if(!this.isRendered) return this._enqueue("goto", arguments);
|
||||
|
||||
split = url.split("#"),
|
||||
|
@ -592,7 +621,8 @@ EPUBJS.Book.prototype.goto = function(url){
|
|||
}else{
|
||||
//-- Only goto section
|
||||
if(section) this.render.section(section);
|
||||
return new RSVP.Promise().resolve(this.currentChapter);
|
||||
deferred.resolve(this.currentChapter);
|
||||
return deferred.promise;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ EPUBJS.Chapter.prototype.contents = function(store){
|
|||
}
|
||||
|
||||
EPUBJS.Chapter.prototype.url = function(store){
|
||||
var promise = new RSVP.Promise();
|
||||
var deferred = new RSVP.defer();
|
||||
|
||||
if(store){
|
||||
if(!this.tempUrl) {
|
||||
|
@ -27,8 +27,8 @@ EPUBJS.Chapter.prototype.url = function(store){
|
|||
}
|
||||
return this.tempUrl;
|
||||
}else{
|
||||
promise.resolve(this.href); //-- this is less than ideal but keeps it a promise
|
||||
return promise;
|
||||
deferred.resolve(this.href); //-- this is less than ideal but keeps it a promise
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
10
src/core.js
10
src/core.js
|
@ -16,7 +16,7 @@ EPUBJS.core.request = function(url, type) {
|
|||
var supportsURL = window.URL;
|
||||
var BLOB_RESPONSE = supportsURL ? "blob" : "arraybuffer";
|
||||
|
||||
var promise = new RSVP.Promise();
|
||||
var deferred = new RSVP.defer();
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
|
@ -61,14 +61,14 @@ EPUBJS.core.request = function(url, type) {
|
|||
r = this.response;
|
||||
}
|
||||
|
||||
promise.resolve(r);
|
||||
deferred.resolve(r);
|
||||
}
|
||||
else { promise.reject(this); }
|
||||
else { deferred.reject(this); }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return promise;
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
// EPUBJS.core.loadXML = function(url, callback){
|
||||
|
@ -183,7 +183,7 @@ EPUBJS.core.toArray = function(obj) {
|
|||
EPUBJS.core.folder = function(url){
|
||||
|
||||
var slash = url.lastIndexOf('/'),
|
||||
folder = url.slice(0, slash + 1);
|
||||
folder = url.slice(0, slash + 1);
|
||||
|
||||
if(slash == -1) folder = '';
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ EPUBJS.EpubCFI.prototype.parse = function(cfiStr) {
|
|||
|
||||
chapId = cfi.chapter.match(/\[(.*)\]/);
|
||||
|
||||
cfi.spineId = chapId[1] || false;
|
||||
cfi.spineId = chapId ? chapId[1] : false;
|
||||
|
||||
path = cfi.fragment.split('/');
|
||||
end = path[path.length-1];
|
||||
|
|
809
src/renderer.js
809
src/renderer.js
File diff suppressed because it is too large
Load diff
|
@ -44,7 +44,7 @@ EPUBJS.replace.links = function(_store, full, done, link){
|
|||
}
|
||||
|
||||
EPUBJS.replace.stylesheets = function(_store, full) {
|
||||
var promise = new RSVP.Promise();
|
||||
var deferred = new RSVP.defer();
|
||||
|
||||
if(!_store) return;
|
||||
|
||||
|
@ -57,25 +57,25 @@ EPUBJS.replace.stylesheets = function(_store, full) {
|
|||
var blob = new Blob([newText], { "type" : "text\/css" }),
|
||||
url = _URL.createObjectURL(blob);
|
||||
|
||||
promise.resolve(url);
|
||||
deferred.resolve(url);
|
||||
|
||||
}, function(e) {console.error(e)});
|
||||
|
||||
});
|
||||
|
||||
return promise;
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
EPUBJS.replace.cssUrls = function(_store, base, text){
|
||||
var promise = new RSVP.Promise(),
|
||||
var deferred = new RSVP.defer(),
|
||||
promises = [],
|
||||
matches = text.match(/url\(\'?\"?([^\'|^\"]*)\'?\"?\)/g);
|
||||
|
||||
if(!_store) return;
|
||||
|
||||
if(!matches){
|
||||
promise.resolve(text);
|
||||
return promise;
|
||||
deferred.resolve(text);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
matches.forEach(function(str){
|
||||
|
@ -88,8 +88,8 @@ EPUBJS.replace.cssUrls = function(_store, base, text){
|
|||
});
|
||||
|
||||
RSVP.all(promises).then(function(){
|
||||
promise.resolve(text);
|
||||
deferred.resolve(text);
|
||||
});
|
||||
|
||||
return promise;
|
||||
return deferred.promise;
|
||||
}
|
|
@ -28,13 +28,13 @@ EPUBJS.Unarchiver.prototype.loadLib = function(callback){
|
|||
}
|
||||
|
||||
EPUBJS.Unarchiver.prototype.openZip = function(zipUrl, callback){
|
||||
var promise = new RSVP.Promise();
|
||||
var deferred = new RSVP.defer();
|
||||
var zipFs = this.zipFs;
|
||||
zipFs.importHttpContent(zipUrl, false, function() {
|
||||
promise.resolve(zipFs);
|
||||
deferred.resolve(zipFs);
|
||||
}, this.failed);
|
||||
|
||||
return promise
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// EPUBJS.Unarchiver.prototype.getXml = function(url){
|
||||
|
@ -63,29 +63,29 @@ EPUBJS.Unarchiver.prototype.getXml = function(url){
|
|||
|
||||
EPUBJS.Unarchiver.prototype.getUrl = function(url, mime){
|
||||
var unarchiver = this;
|
||||
var promise = new RSVP.Promise();
|
||||
var deferred = new RSVP.defer();
|
||||
var entry = this.zipFs.find(url);
|
||||
var _URL = window.URL || window.webkitURL || window.mozURL;
|
||||
|
||||
if(!entry) console.error(url);
|
||||
|
||||
if(url in this.urlCache) {
|
||||
promise.resolve(this.urlCache[url]);
|
||||
return promise;
|
||||
deferred.resolve(this.urlCache[url]);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
entry.getBlob(mime || zip.getMimeType(entry.name), function(blob){
|
||||
var tempUrl = _URL.createObjectURL(blob);
|
||||
promise.resolve(tempUrl);
|
||||
deferred.resolve(tempUrl);
|
||||
unarchiver.urlCache[url] = tempUrl;
|
||||
});
|
||||
|
||||
return promise;
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
EPUBJS.Unarchiver.prototype.getText = function(url){
|
||||
var unarchiver = this;
|
||||
var promise = new RSVP.Promise();
|
||||
var deferred = new RSVP.defer();
|
||||
var entry = this.zipFs.find(url);
|
||||
var _URL = window.URL || window.webkitURL || window.mozURL;
|
||||
|
||||
|
@ -93,10 +93,10 @@ EPUBJS.Unarchiver.prototype.getText = function(url){
|
|||
|
||||
|
||||
entry.getText(function(text){
|
||||
promise.resolve(text);
|
||||
deferred.resolve(text);
|
||||
}, null, null, 'ISO-8859-1');
|
||||
|
||||
return promise;
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
EPUBJS.Unarchiver.prototype.revokeUrl = function(url){
|
||||
|
|
|
@ -23,7 +23,7 @@ asyncTest("Get book URL from bookPath", 1, function() {
|
|||
var opended = Book.open('/demo/moby-dick/');
|
||||
|
||||
opended.then(function(){
|
||||
equal( Book.bookUrl, location.href.replace("tests/", '') + "/demo/moby-dick/", "bookUrl is correctly resolved" );
|
||||
equal( Book.bookUrl, location.href.replace("tests/", '') + "demo/moby-dick/", "bookUrl is correctly resolved" );
|
||||
start();
|
||||
});
|
||||
|
||||
|
@ -35,7 +35,7 @@ asyncTest("Get book URL from ../bookPath", 1, function() {
|
|||
var Book = ePub();
|
||||
var opended = Book.open('../demo/moby-dick/');
|
||||
opended.then(function(){
|
||||
equal( Book.bookUrl, location.href.replace("tests/", '') + "/demo/moby-dick/", "bookUrl with ../ is correctly resolved" );
|
||||
equal( Book.bookUrl, "/demo/moby-dick/", "bookUrl with ../ is correctly resolved" );
|
||||
start();
|
||||
});
|
||||
|
||||
|
@ -73,6 +73,7 @@ asyncTest("Get Contents from Uncompressed Epub", 5, function() {
|
|||
|
||||
Book.ready.all.then(function(){
|
||||
ok( true, "Book is all ready" );
|
||||
|
||||
equal( Book.cover, Book.settings.contentsPath + "images/9780316000000.jpg", "Cover url is set");
|
||||
start();
|
||||
});
|
||||
|
@ -117,7 +118,7 @@ asyncTest("Get Contents from Restored Epub", 7, function() {
|
|||
|
||||
var Book = ePub('../demo/moby-dick/', { restore: true });
|
||||
|
||||
equal( Book.settings.contentsPath, location.href.replace("tests/", '') + "/demo/moby-dick/OPS/", "contentsPath was restored");
|
||||
equal( Book.settings.contentsPath, "/demo/moby-dick/OPS/", "contentsPath was restored");
|
||||
|
||||
Book.getMetadata().then(function(meta){
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue