mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
merged, linted
This commit is contained in:
commit
0013cf417d
10 changed files with 68 additions and 40 deletions
50
dist/epub.js
vendored
50
dist/epub.js
vendored
|
@ -1897,7 +1897,14 @@ EPUBJS.core.request = function(url, type, withCredentials, headers) {
|
||||||
var r;
|
var r;
|
||||||
|
|
||||||
if(type == 'xml'){
|
if(type == 'xml'){
|
||||||
r = this.responseXML;
|
|
||||||
|
// If this.responseXML wasn't set, try to parse using a DOMParser from text
|
||||||
|
if(!this.responseXML){
|
||||||
|
r = new DOMParser().parseFromString(this.response, "text/xml");
|
||||||
|
} else {
|
||||||
|
r = this.responseXML;
|
||||||
|
}
|
||||||
|
|
||||||
}else
|
}else
|
||||||
if(type == 'json'){
|
if(type == 'json'){
|
||||||
r = JSON.parse(this.response);
|
r = JSON.parse(this.response);
|
||||||
|
@ -2810,7 +2817,7 @@ EPUBJS.Infinite.prototype.check = function(){
|
||||||
|
|
||||||
this.tick.call(window, this.check.bind(this));
|
this.tick.call(window, this.check.bind(this));
|
||||||
// setTimeout(this.check.bind(this), 100);
|
// setTimeout(this.check.bind(this), 100);
|
||||||
}
|
};
|
||||||
|
|
||||||
EPUBJS.Infinite.prototype.checkTop = function(){
|
EPUBJS.Infinite.prototype.checkTop = function(){
|
||||||
|
|
||||||
|
@ -3221,7 +3228,7 @@ EPUBJS.Navigation.prototype.loaded = function(toc) {
|
||||||
item = toc[i];
|
item = toc[i];
|
||||||
this.tocByHref[item.href] = i;
|
this.tocByHref[item.href] = i;
|
||||||
this.tocById[item.id] = i;
|
this.tocById[item.id] = i;
|
||||||
};
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3371,7 +3378,6 @@ EPUBJS.Paginate.prototype.registerLayoutMethod = function(view) {
|
||||||
EPUBJS.Paginate.prototype.page = function(pg){
|
EPUBJS.Paginate.prototype.page = function(pg){
|
||||||
|
|
||||||
this.currentPage = pg;
|
this.currentPage = pg;
|
||||||
console.log("page", this.currentPage * this.formated.pageWidth)
|
|
||||||
this.renderer.infinite.scrollTo(this.currentPage * this.formated.pageWidth, 0);
|
this.renderer.infinite.scrollTo(this.currentPage * this.formated.pageWidth, 0);
|
||||||
|
|
||||||
//-- Return false if page is greater than the total
|
//-- Return false if page is greater than the total
|
||||||
|
@ -3387,7 +3393,7 @@ EPUBJS.Paginate.prototype.prev = function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Paginate.prototype.display = function(what){
|
EPUBJS.Paginate.prototype.display = function(what){
|
||||||
return this.renderer.display(what)
|
return this.renderer.display(what);
|
||||||
};
|
};
|
||||||
EPUBJS.Parser = function(){};
|
EPUBJS.Parser = function(){};
|
||||||
|
|
||||||
|
@ -3930,9 +3936,13 @@ EPUBJS.Renderer.prototype.attachTo = function(_element){
|
||||||
this.infinite.on("forwards", function(){
|
this.infinite.on("forwards", function(){
|
||||||
var next = this.last().section.index + 1;
|
var next = this.last().section.index + 1;
|
||||||
|
|
||||||
if(!this.rendering && !this.filling && !this.displaying
|
if(!this.rendering &&
|
||||||
&& next < this.book.spine.length){
|
!this.filling &&
|
||||||
|
!this.displaying &&
|
||||||
|
next < this.book.spine.length){
|
||||||
|
|
||||||
this.forwards();
|
this.forwards();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -3940,9 +3950,13 @@ EPUBJS.Renderer.prototype.attachTo = function(_element){
|
||||||
this.infinite.on("backwards", function(){
|
this.infinite.on("backwards", function(){
|
||||||
var prev = this.first().section.index - 1;
|
var prev = this.first().section.index - 1;
|
||||||
|
|
||||||
if(!this.rendering && !this.filling && !this.displaying
|
if(!this.rendering &&
|
||||||
&& prev > 0){
|
!this.filling &&
|
||||||
|
!this.displaying &&
|
||||||
|
prev > 0){
|
||||||
|
|
||||||
this.backwards();
|
this.backwards();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -4017,7 +4031,7 @@ EPUBJS.Renderer.prototype.render = function(section){
|
||||||
right: parseFloat(styles["padding-right"]) || 0,
|
right: parseFloat(styles["padding-right"]) || 0,
|
||||||
top: parseFloat(styles["padding-top"]) || 0,
|
top: parseFloat(styles["padding-top"]) || 0,
|
||||||
bottom: parseFloat(styles["padding-bottom"]) || 0
|
bottom: parseFloat(styles["padding-bottom"]) || 0
|
||||||
};
|
};
|
||||||
var width = bounds.width - padding.left - padding.right;
|
var width = bounds.width - padding.left - padding.right;
|
||||||
var height = bounds.height - padding.top - padding.bottom;
|
var height = bounds.height - padding.top - padding.bottom;
|
||||||
|
|
||||||
|
@ -4026,7 +4040,7 @@ EPUBJS.Renderer.prototype.render = function(section){
|
||||||
rendered = new RSVP.defer();
|
rendered = new RSVP.defer();
|
||||||
rendered.reject(new Error("No Section Provided"));
|
rendered.reject(new Error("No Section Provided"));
|
||||||
return rendered.promise;
|
return rendered.promise;
|
||||||
};
|
}
|
||||||
|
|
||||||
view = new EPUBJS.View(section);
|
view = new EPUBJS.View(section);
|
||||||
|
|
||||||
|
@ -4076,7 +4090,7 @@ EPUBJS.Renderer.prototype.forwards = function(){
|
||||||
rendered.reject(new Error("Reject Forwards"));
|
rendered.reject(new Error("Reject Forwards"));
|
||||||
return rendered.promise;
|
return rendered.promise;
|
||||||
}
|
}
|
||||||
console.log("going forwards")
|
// console.log("going forwards")
|
||||||
|
|
||||||
this.rendering = true;
|
this.rendering = true;
|
||||||
|
|
||||||
|
@ -4132,7 +4146,7 @@ EPUBJS.Renderer.prototype.backwards = function(view){
|
||||||
rendered.reject(new Error("Reject Backwards"));
|
rendered.reject(new Error("Reject Backwards"));
|
||||||
return rendered.promise;
|
return rendered.promise;
|
||||||
}
|
}
|
||||||
console.log("going backwards")
|
// console.log("going backwards")
|
||||||
|
|
||||||
this.rendering = true;
|
this.rendering = true;
|
||||||
|
|
||||||
|
@ -4314,7 +4328,7 @@ EPUBJS.Renderer.prototype.replacements = function(view, renderer) {
|
||||||
|
|
||||||
for (var i = 0; i < links.length; i++) {
|
for (var i = 0; i < links.length; i++) {
|
||||||
replaceLinks(links[i]);
|
replaceLinks(links[i]);
|
||||||
};
|
}
|
||||||
|
|
||||||
task.resolve();
|
task.resolve();
|
||||||
return task.promise;
|
return task.promise;
|
||||||
|
@ -4358,10 +4372,10 @@ EPUBJS.Renderer.prototype.checkCurrent = function(position) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.current = view.section;
|
this.current = view.section;
|
||||||
this.trigger("current", this.current)
|
this.trigger("current", this.current);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4440,7 +4454,7 @@ EPUBJS.Section.prototype.replacements = function(_document){
|
||||||
|
|
||||||
EPUBJS.Section.prototype.beforeSectionLoad = function(){
|
EPUBJS.Section.prototype.beforeSectionLoad = function(){
|
||||||
// Stub for a hook - replace me for now
|
// Stub for a hook - replace me for now
|
||||||
}
|
};
|
||||||
|
|
||||||
EPUBJS.Section.prototype.render = function(_request){
|
EPUBJS.Section.prototype.render = function(_request){
|
||||||
var rendering = new RSVP.defer();
|
var rendering = new RSVP.defer();
|
||||||
|
@ -4685,7 +4699,7 @@ EPUBJS.View.prototype.display = function(contents) {
|
||||||
displaying.resolve(this);
|
displaying.resolve(this);
|
||||||
// this.observer = this.observe(this.document.body);
|
// this.observer = this.observe(this.document.body);
|
||||||
|
|
||||||
return displayed
|
return displayed;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
4
dist/epub.min.js
vendored
4
dist/epub.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -52,7 +52,14 @@ EPUBJS.core.request = function(url, type, withCredentials, headers) {
|
||||||
var r;
|
var r;
|
||||||
|
|
||||||
if(type == 'xml'){
|
if(type == 'xml'){
|
||||||
r = this.responseXML;
|
|
||||||
|
// If this.responseXML wasn't set, try to parse using a DOMParser from text
|
||||||
|
if(!this.responseXML){
|
||||||
|
r = new DOMParser().parseFromString(this.response, "text/xml");
|
||||||
|
} else {
|
||||||
|
r = this.responseXML;
|
||||||
|
}
|
||||||
|
|
||||||
}else
|
}else
|
||||||
if(type == 'json'){
|
if(type == 'json'){
|
||||||
r = JSON.parse(this.response);
|
r = JSON.parse(this.response);
|
||||||
|
|
|
@ -70,7 +70,7 @@ EPUBJS.Infinite.prototype.check = function(){
|
||||||
|
|
||||||
this.tick.call(window, this.check.bind(this));
|
this.tick.call(window, this.check.bind(this));
|
||||||
// setTimeout(this.check.bind(this), 100);
|
// setTimeout(this.check.bind(this), 100);
|
||||||
}
|
};
|
||||||
|
|
||||||
EPUBJS.Infinite.prototype.checkTop = function(){
|
EPUBJS.Infinite.prototype.checkTop = function(){
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ EPUBJS.Navigation.prototype.loaded = function(toc) {
|
||||||
item = toc[i];
|
item = toc[i];
|
||||||
this.tocByHref[item.href] = i;
|
this.tocByHref[item.href] = i;
|
||||||
this.tocById[item.id] = i;
|
this.tocById[item.id] = i;
|
||||||
};
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,6 @@ EPUBJS.Paginate.prototype.registerLayoutMethod = function(view) {
|
||||||
EPUBJS.Paginate.prototype.page = function(pg){
|
EPUBJS.Paginate.prototype.page = function(pg){
|
||||||
|
|
||||||
this.currentPage = pg;
|
this.currentPage = pg;
|
||||||
console.log("page", this.currentPage * this.formated.pageWidth)
|
|
||||||
this.renderer.infinite.scrollTo(this.currentPage * this.formated.pageWidth, 0);
|
this.renderer.infinite.scrollTo(this.currentPage * this.formated.pageWidth, 0);
|
||||||
|
|
||||||
//-- Return false if page is greater than the total
|
//-- Return false if page is greater than the total
|
||||||
|
@ -144,5 +143,5 @@ EPUBJS.Paginate.prototype.prev = function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Paginate.prototype.display = function(what){
|
EPUBJS.Paginate.prototype.display = function(what){
|
||||||
return this.renderer.display(what)
|
return this.renderer.display(what);
|
||||||
};
|
};
|
|
@ -173,9 +173,13 @@ EPUBJS.Renderer.prototype.attachTo = function(_element){
|
||||||
this.infinite.on("forwards", function(){
|
this.infinite.on("forwards", function(){
|
||||||
var next = this.last().section.index + 1;
|
var next = this.last().section.index + 1;
|
||||||
|
|
||||||
if(!this.rendering && !this.filling && !this.displaying
|
if(!this.rendering &&
|
||||||
&& next < this.book.spine.length){
|
!this.filling &&
|
||||||
|
!this.displaying &&
|
||||||
|
next < this.book.spine.length){
|
||||||
|
|
||||||
this.forwards();
|
this.forwards();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -183,9 +187,13 @@ EPUBJS.Renderer.prototype.attachTo = function(_element){
|
||||||
this.infinite.on("backwards", function(){
|
this.infinite.on("backwards", function(){
|
||||||
var prev = this.first().section.index - 1;
|
var prev = this.first().section.index - 1;
|
||||||
|
|
||||||
if(!this.rendering && !this.filling && !this.displaying
|
if(!this.rendering &&
|
||||||
&& prev > 0){
|
!this.filling &&
|
||||||
|
!this.displaying &&
|
||||||
|
prev > 0){
|
||||||
|
|
||||||
this.backwards();
|
this.backwards();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -260,7 +268,7 @@ EPUBJS.Renderer.prototype.render = function(section){
|
||||||
right: parseFloat(styles["padding-right"]) || 0,
|
right: parseFloat(styles["padding-right"]) || 0,
|
||||||
top: parseFloat(styles["padding-top"]) || 0,
|
top: parseFloat(styles["padding-top"]) || 0,
|
||||||
bottom: parseFloat(styles["padding-bottom"]) || 0
|
bottom: parseFloat(styles["padding-bottom"]) || 0
|
||||||
};
|
};
|
||||||
var width = bounds.width - padding.left - padding.right;
|
var width = bounds.width - padding.left - padding.right;
|
||||||
var height = bounds.height - padding.top - padding.bottom;
|
var height = bounds.height - padding.top - padding.bottom;
|
||||||
|
|
||||||
|
@ -269,7 +277,7 @@ EPUBJS.Renderer.prototype.render = function(section){
|
||||||
rendered = new RSVP.defer();
|
rendered = new RSVP.defer();
|
||||||
rendered.reject(new Error("No Section Provided"));
|
rendered.reject(new Error("No Section Provided"));
|
||||||
return rendered.promise;
|
return rendered.promise;
|
||||||
};
|
}
|
||||||
|
|
||||||
view = new EPUBJS.View(section);
|
view = new EPUBJS.View(section);
|
||||||
|
|
||||||
|
@ -319,7 +327,7 @@ EPUBJS.Renderer.prototype.forwards = function(){
|
||||||
rendered.reject(new Error("Reject Forwards"));
|
rendered.reject(new Error("Reject Forwards"));
|
||||||
return rendered.promise;
|
return rendered.promise;
|
||||||
}
|
}
|
||||||
console.log("going forwards")
|
// console.log("going forwards")
|
||||||
|
|
||||||
this.rendering = true;
|
this.rendering = true;
|
||||||
|
|
||||||
|
@ -375,7 +383,7 @@ EPUBJS.Renderer.prototype.backwards = function(view){
|
||||||
rendered.reject(new Error("Reject Backwards"));
|
rendered.reject(new Error("Reject Backwards"));
|
||||||
return rendered.promise;
|
return rendered.promise;
|
||||||
}
|
}
|
||||||
console.log("going backwards")
|
// console.log("going backwards")
|
||||||
|
|
||||||
this.rendering = true;
|
this.rendering = true;
|
||||||
|
|
||||||
|
@ -557,7 +565,7 @@ EPUBJS.Renderer.prototype.replacements = function(view, renderer) {
|
||||||
|
|
||||||
for (var i = 0; i < links.length; i++) {
|
for (var i = 0; i < links.length; i++) {
|
||||||
replaceLinks(links[i]);
|
replaceLinks(links[i]);
|
||||||
};
|
}
|
||||||
|
|
||||||
task.resolve();
|
task.resolve();
|
||||||
return task.promise;
|
return task.promise;
|
||||||
|
@ -601,10 +609,10 @@ EPUBJS.Renderer.prototype.checkCurrent = function(position) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.current = view.section;
|
this.current = view.section;
|
||||||
this.trigger("current", this.current)
|
this.trigger("current", this.current);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ EPUBJS.Section.prototype.replacements = function(_document){
|
||||||
|
|
||||||
EPUBJS.Section.prototype.beforeSectionLoad = function(){
|
EPUBJS.Section.prototype.beforeSectionLoad = function(){
|
||||||
// Stub for a hook - replace me for now
|
// Stub for a hook - replace me for now
|
||||||
}
|
};
|
||||||
|
|
||||||
EPUBJS.Section.prototype.render = function(_request){
|
EPUBJS.Section.prototype.render = function(_request){
|
||||||
var rendering = new RSVP.defer();
|
var rendering = new RSVP.defer();
|
||||||
|
|
|
@ -129,7 +129,7 @@ EPUBJS.View.prototype.display = function(contents) {
|
||||||
displaying.resolve(this);
|
displaying.resolve(this);
|
||||||
// this.observer = this.observe(this.document.body);
|
// this.observer = this.observe(this.document.body);
|
||||||
|
|
||||||
return displayed
|
return displayed;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -286,7 +286,7 @@ asyncTest("Get all TOC", 1, function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("Get TOC time by href", 1, function() {
|
asyncTest("Get TOC item by href", 1, function() {
|
||||||
|
|
||||||
var book = ePub("../books/moby-dick/OPS/package.opf");
|
var book = ePub("../books/moby-dick/OPS/package.opf");
|
||||||
book.loaded.navigation.then(function(){
|
book.loaded.navigation.then(function(){
|
||||||
|
@ -297,7 +297,7 @@ asyncTest("Get TOC time by href", 1, function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("Get TOC time by ID", 1, function() {
|
asyncTest("Get TOC item by ID", 1, function() {
|
||||||
|
|
||||||
var book = ePub("../books/moby-dick/OPS/package.opf");
|
var book = ePub("../books/moby-dick/OPS/package.opf");
|
||||||
book.loaded.navigation.then(function(){
|
book.loaded.navigation.then(function(){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue