mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
white space cleanup
This commit is contained in:
parent
b9cb79e30d
commit
6fce08bc7d
13 changed files with 1263 additions and 1273 deletions
28
Gruntfile.js
28
Gruntfile.js
|
@ -2,12 +2,12 @@ module.exports = function(grunt) {
|
||||||
|
|
||||||
// Project configuration.
|
// Project configuration.
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
pkg: '<json:package.json>',
|
pkg: '<json:package.json>',
|
||||||
meta: {
|
meta: {
|
||||||
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
|
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
|
||||||
'<%= grunt.template.today("yyyy-mm-dd") %> */'
|
'<%= grunt.template.today("yyyy-mm-dd") %> */'
|
||||||
},
|
},
|
||||||
concat : {
|
concat : {
|
||||||
'build/epub.js': ['<banner>', 'libs/rsvp/rsvp.js', 'src/*.js'],
|
'build/epub.js': ['<banner>', 'libs/rsvp/rsvp.js', 'src/*.js'],
|
||||||
'build/reader.js': ['<banner>', 'reader/*.js'],
|
'build/reader.js': ['<banner>', 'reader/*.js'],
|
||||||
'build/hooks.js': ['<banner>', 'hooks/default/*.js'],
|
'build/hooks.js': ['<banner>', 'hooks/default/*.js'],
|
||||||
|
@ -15,13 +15,13 @@ module.exports = function(grunt) {
|
||||||
'demo/js/libs/loader_filesystem.min.js': 'libs/fileStorage/workers/loader_filesystem.min.js',
|
'demo/js/libs/loader_filesystem.min.js': 'libs/fileStorage/workers/loader_filesystem.min.js',
|
||||||
'demo/js/libs/jquery-1.9.0.min.js': 'libs/jquery/jquery-1.9.0.min.js',
|
'demo/js/libs/jquery-1.9.0.min.js': 'libs/jquery/jquery-1.9.0.min.js',
|
||||||
'demo/js/libs/inflate.js': 'libs/zip/inflate.js'
|
'demo/js/libs/inflate.js': 'libs/zip/inflate.js'
|
||||||
},
|
},
|
||||||
uglify: {
|
uglify: {
|
||||||
options: {
|
options: {
|
||||||
preserveComments: 'some'
|
preserveComments: 'some'
|
||||||
},
|
},
|
||||||
my_target: {
|
my_target: {
|
||||||
files: {
|
files: {
|
||||||
'demo/js/epub.min.js': ['libs/underscore/underscore-min.js', 'build/epub.js'],
|
'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'],
|
'build/epub.min.js': ['libs/underscore/underscore-min.js', 'build/epub.js'],
|
||||||
'demo/js/reader.min.js': ['build/reader.js'],
|
'demo/js/reader.min.js': ['build/reader.js'],
|
||||||
|
@ -32,8 +32,8 @@ module.exports = function(grunt) {
|
||||||
'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/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']
|
'build/libs/inflate.js': ['libs/zip/inflate.js']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||||
|
|
1239
build/epub.js
1239
build/epub.js
File diff suppressed because it is too large
Load diff
32
server.js
32
server.js
|
@ -8,34 +8,34 @@ var port = argv.p,
|
||||||
log = console.log;
|
log = console.log;
|
||||||
|
|
||||||
if (!argv.p) {
|
if (!argv.p) {
|
||||||
portfinder.basePort = 8080;
|
portfinder.basePort = 8080;
|
||||||
portfinder.getPort(function (err, port) {
|
portfinder.getPort(function (err, port) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
listen(port);
|
listen(port);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
listen(port);
|
listen(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function listen(port) {
|
function listen(port) {
|
||||||
var server = connect();
|
var server = connect();
|
||||||
server.use(connect.static(__dirname))
|
server.use(connect.static(__dirname))
|
||||||
|
|
||||||
if(!logger) server.use(connect.logger(logger))
|
if(!logger) server.use(connect.logger(logger))
|
||||||
|
|
||||||
server.listen(port);
|
server.listen(port);
|
||||||
|
|
||||||
log('Starting up Server, serving '.yellow
|
log('Starting up Server, serving '.yellow
|
||||||
+ __dirname.green
|
+ __dirname.green
|
||||||
+ ' on port: '.yellow
|
+ ' on port: '.yellow
|
||||||
+ port.toString().cyan);
|
+ port.toString().cyan);
|
||||||
log('Hit CTRL-C to stop the server');
|
log('Hit CTRL-C to stop the server');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
process.on('SIGINT', function () {
|
process.on('SIGINT', function () {
|
||||||
log('http-server stopped.'.red);
|
log('http-server stopped.'.red);
|
||||||
|
|
16
src/base.js
16
src/base.js
|
@ -30,8 +30,8 @@ EPUBJS.filePath = EPUBJS.filePath || "/epubjs/";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* var book = ePub({ bookPath: "path/to/book.epub", restore: true });
|
* var book = ePub({ bookPath: "path/to/book.epub", restore: true });
|
||||||
*
|
*
|
||||||
* - OR -
|
* - OR -
|
||||||
*
|
*
|
||||||
* var book = ePub({ restore: true });
|
* var book = ePub({ restore: true });
|
||||||
* book.open("path/to/book.epub");
|
* book.open("path/to/book.epub");
|
||||||
|
@ -53,11 +53,11 @@ EPUBJS.filePath = EPUBJS.filePath || "/epubjs/";
|
||||||
});
|
});
|
||||||
|
|
||||||
//exports to multiple environments
|
//exports to multiple environments
|
||||||
if (typeof define === 'function' && define.amd)
|
if (typeof define === 'function' && define.amd)
|
||||||
//AMD
|
//AMD
|
||||||
define(function(){ return ePub; });
|
define(function(){ return ePub; });
|
||||||
else if (typeof module != "undefined" && module.exports)
|
else if (typeof module != "undefined" && module.exports)
|
||||||
//Node
|
//Node
|
||||||
module.exports = ePub;
|
module.exports = ePub;
|
||||||
|
|
||||||
})();
|
})();
|
126
src/book.js
126
src/book.js
|
@ -3,22 +3,22 @@ EPUBJS.Book = function(options){
|
||||||
var book = this;
|
var book = this;
|
||||||
|
|
||||||
this.settings = _.defaults(options || {}, {
|
this.settings = _.defaults(options || {}, {
|
||||||
bookPath : null,
|
bookPath : null,
|
||||||
storage: false, //-- true (auto) or false (none) | override: 'ram', 'websqldatabase', 'indexeddb', 'filesystem'
|
storage: false, //-- true (auto) or false (none) | override: 'ram', 'websqldatabase', 'indexeddb', 'filesystem'
|
||||||
fromStorage : false,
|
fromStorage : false,
|
||||||
saved : false,
|
saved : false,
|
||||||
online : true,
|
online : true,
|
||||||
contained : false,
|
contained : false,
|
||||||
width : false,
|
width : false,
|
||||||
height: false,
|
height: false,
|
||||||
spreads: true,
|
spreads: true,
|
||||||
fixedLayout : false,
|
fixedLayout : false,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
version: 1,
|
version: 1,
|
||||||
restore: false,
|
restore: false,
|
||||||
reload : false,
|
reload : false,
|
||||||
goto : false,
|
goto : false,
|
||||||
styles : {}
|
styles : {}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.settings.EPUBJSVERSION = EPUBJS.VERSION;
|
this.settings.EPUBJSVERSION = EPUBJS.VERSION;
|
||||||
|
@ -132,7 +132,7 @@ EPUBJS.Book.prototype.open = function(bookPath, forceReload){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(saved && this.settings.restore && !forceReload){
|
if(saved && this.settings.restore && !forceReload){
|
||||||
//-- Will load previous package json, or re-unpack if error
|
//-- Will load previous package json, or re-unpack if error
|
||||||
|
@ -167,56 +167,56 @@ EPUBJS.Book.prototype.unpack = function(containerPath){
|
||||||
|
|
||||||
//-- Return chain of promises
|
//-- Return chain of promises
|
||||||
return book.loadXml(book.bookUrl + containerPath).
|
return book.loadXml(book.bookUrl + containerPath).
|
||||||
then(function(containerXml){
|
then(function(containerXml){
|
||||||
return parse.container(containerXml); // Container has path to content
|
return parse.container(containerXml); // Container has path to content
|
||||||
}).
|
}).
|
||||||
then(function(paths){
|
then(function(paths){
|
||||||
book.settings.contentsPath = book.bookUrl + paths.basePath;
|
book.settings.contentsPath = book.bookUrl + paths.basePath;
|
||||||
book.settings.packageUrl = book.bookUrl + paths.packagePath;
|
book.settings.packageUrl = book.bookUrl + paths.packagePath;
|
||||||
return book.loadXml(book.settings.packageUrl); // Containes manifest, spine and metadata
|
return book.loadXml(book.settings.packageUrl); // Containes manifest, spine and metadata
|
||||||
}).
|
}).
|
||||||
then(function(packageXml){
|
then(function(packageXml){
|
||||||
return parse.package(packageXml, book.settings.contentsPath); // Extract info from contents
|
return parse.package(packageXml, book.settings.contentsPath); // Extract info from contents
|
||||||
}).
|
}).
|
||||||
then(function(contents){
|
then(function(contents){
|
||||||
|
|
||||||
book.contents = contents;
|
book.contents = contents;
|
||||||
book.manifest = book.contents.manifest;
|
book.manifest = book.contents.manifest;
|
||||||
book.spine = book.contents.spine;
|
book.spine = book.contents.spine;
|
||||||
book.spineIndexByURL = book.contents.spineIndexByURL;
|
book.spineIndexByURL = book.contents.spineIndexByURL;
|
||||||
book.metadata = book.contents.metadata;
|
book.metadata = book.contents.metadata;
|
||||||
|
|
||||||
book.cover = book.contents.cover = book.settings.contentsPath + contents.coverPath;
|
book.cover = book.contents.cover = book.settings.contentsPath + contents.coverPath;
|
||||||
|
|
||||||
book.spineNodeIndex = book.contents.spineNodeIndex = contents.spineNodeIndex;
|
book.spineNodeIndex = book.contents.spineNodeIndex = contents.spineNodeIndex;
|
||||||
|
|
||||||
book.ready.manifest.resolve(book.contents.manifest);
|
book.ready.manifest.resolve(book.contents.manifest);
|
||||||
book.ready.spine.resolve(book.contents.spine);
|
book.ready.spine.resolve(book.contents.spine);
|
||||||
book.ready.metadata.resolve(book.contents.metadata);
|
book.ready.metadata.resolve(book.contents.metadata);
|
||||||
book.ready.cover.resolve(book.contents.cover);
|
book.ready.cover.resolve(book.contents.cover);
|
||||||
|
|
||||||
//-- Adjust setting based on metadata
|
//-- Adjust setting based on metadata
|
||||||
|
|
||||||
//-- Load the TOC, optional
|
//-- Load the TOC, optional
|
||||||
if(contents.tocPath) {
|
if(contents.tocPath) {
|
||||||
|
|
||||||
book.settings.tocUrl = book.settings.contentsPath + contents.tocPath;
|
book.settings.tocUrl = book.settings.contentsPath + contents.tocPath;
|
||||||
|
|
||||||
book.loadXml(book.settings.tocUrl).
|
book.loadXml(book.settings.tocUrl).
|
||||||
then(function(tocXml){
|
then(function(tocXml){
|
||||||
return parse.toc(tocXml); // Grab Table of Contents
|
return parse.toc(tocXml); // Grab Table of Contents
|
||||||
}).then(function(toc){
|
}).then(function(toc){
|
||||||
book.toc = book.contents.toc = toc;
|
book.toc = book.contents.toc = toc;
|
||||||
book.ready.toc.resolve(book.contents.toc);
|
book.ready.toc.resolve(book.contents.toc);
|
||||||
// book.saveSettings();
|
// book.saveSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}).
|
}).
|
||||||
fail(function(error) {
|
fail(function(error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -236,13 +236,13 @@ EPUBJS.Book.prototype.networkListeners = function(){
|
||||||
var book = this;
|
var book = this;
|
||||||
|
|
||||||
window.addEventListener("offline", function(e) {
|
window.addEventListener("offline", function(e) {
|
||||||
book.online = false;
|
book.online = false;
|
||||||
book.trigger("book:offline");
|
book.trigger("book:offline");
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
window.addEventListener("online", function(e) {
|
window.addEventListener("online", function(e) {
|
||||||
book.online = true;
|
book.online = true;
|
||||||
book.trigger("book:online");
|
book.trigger("book:online");
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ EPUBJS.Book.prototype.displayChapter = function(chap, end){
|
||||||
|
|
||||||
|
|
||||||
if(!this.settings.fromStorage &&
|
if(!this.settings.fromStorage &&
|
||||||
!this.settings.contained) {
|
!this.settings.contained) {
|
||||||
render.then(function(){
|
render.then(function(){
|
||||||
book.preloadNextChapter();
|
book.preloadNextChapter();
|
||||||
});
|
});
|
||||||
|
@ -698,7 +698,7 @@ EPUBJS.Book.prototype.removeStyle = function(style) {
|
||||||
EPUBJS.Book.prototype.unload = function(){
|
EPUBJS.Book.prototype.unload = function(){
|
||||||
|
|
||||||
if(this.settings.restore) {
|
if(this.settings.restore) {
|
||||||
this.saveSettings();
|
this.saveSettings();
|
||||||
this.saveContents();
|
this.saveContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,7 +762,7 @@ EPUBJS.Book.prototype.getHooks = function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
//-- Hooks allow for injecting async functions that must all complete before continuing
|
//-- Hooks allow for injecting async functions that must all complete before continuing
|
||||||
// Functions must have a callback as their first argument.
|
// Functions must have a callback as their first argument.
|
||||||
EPUBJS.Book.prototype.registerHook = function(type, toAdd, toFront){
|
EPUBJS.Book.prototype.registerHook = function(type, toAdd, toFront){
|
||||||
var book = this;
|
var book = this;
|
||||||
|
|
||||||
|
|
123
src/core.js
123
src/core.js
|
@ -3,12 +3,12 @@ EPUBJS.core = {}
|
||||||
|
|
||||||
//-- Get a element for an id
|
//-- Get a element for an id
|
||||||
EPUBJS.core.getEl = function(elem) {
|
EPUBJS.core.getEl = function(elem) {
|
||||||
return document.getElementById(elem);
|
return document.getElementById(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-- Get all elements for a class
|
//-- Get all elements for a class
|
||||||
EPUBJS.core.getEls = function(classes) {
|
EPUBJS.core.getEls = function(classes) {
|
||||||
return document.getElementsByClassName(classes);
|
return document.getElementsByClassName(classes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ EPUBJS.core.request = function(url, type) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
//-- Check from PDF.js:
|
//-- Check from PDF.js:
|
||||||
// https://github.com/mozilla/pdf.js/blob/master/web/compatibility.js
|
// https://github.com/mozilla/pdf.js/blob/master/web/compatibility.js
|
||||||
var xhrPrototype = XMLHttpRequest.prototype;
|
var xhrPrototype = XMLHttpRequest.prototype;
|
||||||
|
|
||||||
if (!('overrideMimeType' in xhrPrototype)) {
|
if (!('overrideMimeType' in xhrPrototype)) {
|
||||||
|
@ -49,7 +49,7 @@ EPUBJS.core.request = function(url, type) {
|
||||||
xhr.send();
|
xhr.send();
|
||||||
|
|
||||||
function handler() {
|
function handler() {
|
||||||
if (this.readyState === this.DONE) {
|
if (this.readyState === this.DONE) {
|
||||||
if (this.status === 200 || this.responseXML ) { //-- Firefox is reporting 0 for blob urls
|
if (this.status === 200 || this.responseXML ) { //-- Firefox is reporting 0 for blob urls
|
||||||
var r;
|
var r;
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ EPUBJS.core.request = function(url, type) {
|
||||||
deferred.resolve(r);
|
deferred.resolve(r);
|
||||||
}
|
}
|
||||||
else { deferred.reject(this); }
|
else { deferred.reject(this); }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
// EPUBJS.core.loadXML = function(url, callback){
|
// EPUBJS.core.loadXML = function(url, callback){
|
||||||
|
@ -176,18 +176,18 @@ EPUBJS.core.request = function(url, type) {
|
||||||
|
|
||||||
|
|
||||||
EPUBJS.core.toArray = function(obj) {
|
EPUBJS.core.toArray = function(obj) {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
|
|
||||||
for (member in obj) {
|
for (member in obj) {
|
||||||
var newitm;
|
var newitm;
|
||||||
if ( obj.hasOwnProperty(member) ) {
|
if ( obj.hasOwnProperty(member) ) {
|
||||||
newitm = obj[member];
|
newitm = obj[member];
|
||||||
newitm.ident = member;
|
newitm.ident = member;
|
||||||
arr.push(newitm);
|
arr.push(newitm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-- Parse out the folder
|
//-- Parse out the folder
|
||||||
|
@ -206,11 +206,11 @@ EPUBJS.core.folder = function(url){
|
||||||
EPUBJS.core.dataURLToBlob = function(dataURL) {
|
EPUBJS.core.dataURLToBlob = function(dataURL) {
|
||||||
var BASE64_MARKER = ';base64,';
|
var BASE64_MARKER = ';base64,';
|
||||||
if (dataURL.indexOf(BASE64_MARKER) == -1) {
|
if (dataURL.indexOf(BASE64_MARKER) == -1) {
|
||||||
var parts = dataURL.split(',');
|
var parts = dataURL.split(',');
|
||||||
var contentType = parts[0].split(':')[1];
|
var contentType = parts[0].split(':')[1];
|
||||||
var raw = parts[1];
|
var raw = parts[1];
|
||||||
|
|
||||||
return new Blob([raw], {type: contentType});
|
return new Blob([raw], {type: contentType});
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = dataURL.split(BASE64_MARKER);
|
var parts = dataURL.split(BASE64_MARKER);
|
||||||
|
@ -221,7 +221,7 @@ EPUBJS.core.dataURLToBlob = function(dataURL) {
|
||||||
var uInt8Array = new Uint8Array(rawLength);
|
var uInt8Array = new Uint8Array(rawLength);
|
||||||
|
|
||||||
for (var i = 0; i < rawLength; ++i) {
|
for (var i = 0; i < rawLength; ++i) {
|
||||||
uInt8Array[i] = raw.charCodeAt(i);
|
uInt8Array[i] = raw.charCodeAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Blob([uInt8Array], {type: contentType});
|
return new Blob([uInt8Array], {type: contentType});
|
||||||
|
@ -229,22 +229,20 @@ EPUBJS.core.dataURLToBlob = function(dataURL) {
|
||||||
|
|
||||||
//-- Load scripts async: http://stackoverflow.com/questions/7718935/load-scripts-asynchronously
|
//-- Load scripts async: http://stackoverflow.com/questions/7718935/load-scripts-asynchronously
|
||||||
EPUBJS.core.addScript = function(src, callback, target) {
|
EPUBJS.core.addScript = function(src, callback, target) {
|
||||||
var s, r;
|
var s, r;
|
||||||
r = false;
|
r = false;
|
||||||
s = document.createElement('script');
|
s = document.createElement('script');
|
||||||
s.type = 'text/javascript';
|
s.type = 'text/javascript';
|
||||||
s.async = false;
|
s.async = false;
|
||||||
s.src = src;
|
s.src = src;
|
||||||
s.onload = s.onreadystatechange = function() {
|
s.onload = s.onreadystatechange = function() {
|
||||||
|
if ( !r && (!this.readyState || this.readyState == 'complete') ) {
|
||||||
if ( !r && (!this.readyState || this.readyState == 'complete') )
|
r = true;
|
||||||
{
|
if(callback) callback();
|
||||||
r = true;
|
}
|
||||||
if(callback) callback();
|
};
|
||||||
}
|
target = target || document.body;
|
||||||
},
|
target.appendChild(s);
|
||||||
target = target || document.body;
|
|
||||||
target.appendChild(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EPUBJS.core.addScripts = function(srcArr, callback, target) {
|
EPUBJS.core.addScripts = function(srcArr, callback, target) {
|
||||||
|
@ -261,27 +259,26 @@ EPUBJS.core.addScript = function(src, callback, target) {
|
||||||
|
|
||||||
|
|
||||||
EPUBJS.core.addScript(srcArr[curr], cb, target);
|
EPUBJS.core.addScript(srcArr[curr], cb, target);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EPUBJS.core.addCss = function(src, callback, target) {
|
EPUBJS.core.addCss = function(src, callback, target) {
|
||||||
var s, r;
|
var s, r;
|
||||||
r = false;
|
r = false;
|
||||||
s = document.createElement('link');
|
s = document.createElement('link');
|
||||||
s.type = 'text/css';
|
s.type = 'text/css';
|
||||||
s.rel = "stylesheet";
|
s.rel = "stylesheet";
|
||||||
s.href = src;
|
s.href = src;
|
||||||
s.onload = s.onreadystatechange = function() {
|
s.onload = s.onreadystatechange = function() {
|
||||||
if ( !r && (!this.readyState || this.readyState == 'complete') )
|
if ( !r && (!this.readyState || this.readyState == 'complete') ) {
|
||||||
{
|
r = true;
|
||||||
r = true;
|
if(callback) callback();
|
||||||
if(callback) callback();
|
}
|
||||||
}
|
};
|
||||||
},
|
target = target || document.body;
|
||||||
target = target || document.body;
|
target.appendChild(s);
|
||||||
target.appendChild(s);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
EPUBJS.core.prefixed = function(unprefixed) {
|
EPUBJS.core.prefixed = function(unprefixed) {
|
||||||
var vendors = ["Webkit", "Moz", "O", "ms" ],
|
var vendors = ["Webkit", "Moz", "O", "ms" ],
|
||||||
prefixes = ['-Webkit-', '-moz-', '-o-', '-ms-'],
|
prefixes = ['-Webkit-', '-moz-', '-o-', '-ms-'],
|
||||||
|
@ -306,22 +303,22 @@ EPUBJS.core.addScript = function(src, callback, target) {
|
||||||
|
|
||||||
EPUBJS.core.resolveUrl = function(base, path) {
|
EPUBJS.core.resolveUrl = function(base, path) {
|
||||||
var url,
|
var url,
|
||||||
segments = [],
|
segments = [],
|
||||||
folders = base.split("/"),
|
folders = base.split("/"),
|
||||||
paths;
|
paths;
|
||||||
|
|
||||||
folders.pop();
|
folders.pop();
|
||||||
|
|
||||||
paths = path.split("/");
|
paths = path.split("/");
|
||||||
paths.forEach(function(p){
|
paths.forEach(function(p){
|
||||||
if(p === ".."){
|
if(p === ".."){
|
||||||
folders.pop();
|
folders.pop();
|
||||||
}else{
|
}else{
|
||||||
segments.push(p);
|
segments.push(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
url = folders.concat(segments);
|
url = folders.concat(segments);
|
||||||
|
|
||||||
return url.join("/");
|
return url.join("/");
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ EPUBJS.EpubCFI.prototype.generateFragment = function(element, chapter) {
|
||||||
segment += (part.index + 1) * 2;
|
segment += (part.index + 1) * 2;
|
||||||
|
|
||||||
if(part.id &&
|
if(part.id &&
|
||||||
part.id.slice(0, 6) != "EPUBJS") { //-- ignore internal @EPUBJS ids
|
part.id.slice(0, 6) != "EPUBJS") { //-- ignore internal @EPUBJS ids
|
||||||
|
|
||||||
segment += "[" + part.id + "]";
|
segment += "[" + part.id + "]";
|
||||||
|
|
||||||
|
@ -150,23 +150,23 @@ EPUBJS.EpubCFI.prototype.getElement = function(cfi, doc) {
|
||||||
|
|
||||||
while(sections.length > 0) {
|
while(sections.length > 0) {
|
||||||
|
|
||||||
part = sections.shift();
|
part = sections.shift();
|
||||||
|
|
||||||
if(part.id){
|
if(part.id){
|
||||||
|
|
||||||
element = doc.getElementById(part.id);
|
element = doc.getElementById(part.id);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
element = children[part.index];
|
element = children[part.index];
|
||||||
|
|
||||||
if(!children) console.error("No Kids", element);
|
if(!children) console.error("No Kids", element);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!element) console.error("No Element For", part);
|
if(!element) console.error("No Element For", part);
|
||||||
children = Array.prototype.slice.call(element.children);
|
children = Array.prototype.slice.call(element.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
|
|
|
@ -27,7 +27,7 @@ EPUBJS.Events.prototype.tell = function(evt, msg){
|
||||||
var e;
|
var e;
|
||||||
|
|
||||||
if(!this.events[evt]){
|
if(!this.events[evt]){
|
||||||
console.warn("No event:", evt, "defined yet, creating.");
|
console.warn("No event:", evt, "defined yet, creating.");
|
||||||
e = this.createEvent(evt)
|
e = this.createEvent(evt)
|
||||||
}else{
|
}else{
|
||||||
e = this.events[evt];
|
e = this.events[evt];
|
||||||
|
@ -40,7 +40,7 @@ EPUBJS.Events.prototype.tell = function(evt, msg){
|
||||||
|
|
||||||
EPUBJS.Events.prototype.listen = function(evt, func, bindto){
|
EPUBJS.Events.prototype.listen = function(evt, func, bindto){
|
||||||
if(!this.events[evt]){
|
if(!this.events[evt]){
|
||||||
console.warn("No event:", evt, "defined yet, creating.");
|
console.warn("No event:", evt, "defined yet, creating.");
|
||||||
this.createEvent(evt);
|
this.createEvent(evt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
12
src/hooks.js
12
src/hooks.js
|
@ -1,11 +1,11 @@
|
||||||
EPUBJS.Hooks = (function(){
|
EPUBJS.Hooks = (function(){
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
return {
|
return {
|
||||||
register: function(name) {
|
register: function(name) {
|
||||||
if(this[name] === undefined) { this[name] = {}; }
|
if(this[name] === undefined) { this[name] = {}; }
|
||||||
if(typeof this[name] !== 'object') { throw "Already registered: "+name; }
|
if(typeof this[name] !== 'object') { throw "Already registered: "+name; }
|
||||||
return this[name];
|
return this[name];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
|
@ -45,7 +45,7 @@ EPUBJS.Parser.prototype.package = function(packageXml, baseUrl){
|
||||||
'tocPath' : tocPath,
|
'tocPath' : tocPath,
|
||||||
'coverPath': coverPath,
|
'coverPath': coverPath,
|
||||||
'spineNodeIndex' : spineNodeIndex,
|
'spineNodeIndex' : spineNodeIndex,
|
||||||
'spineIndexByURL' : spineIndexByURL
|
'spineIndexByURL': spineIndexByURL
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,9 +185,9 @@ EPUBJS.Parser.prototype.toc = function(tocXml){
|
||||||
|
|
||||||
while(iter--){
|
while(iter--){
|
||||||
node = nodesArray[iter];
|
node = nodesArray[iter];
|
||||||
if(node.nodeName === "navPoint") {
|
if(node.nodeName === "navPoint") {
|
||||||
items.push(node);
|
items.push(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items.forEach(function(item){
|
items.forEach(function(item){
|
||||||
|
|
932
src/renderer.js
932
src/renderer.js
File diff suppressed because it is too large
Load diff
|
@ -12,7 +12,6 @@ EPUBJS.replace.head = function(callback, renderer) {
|
||||||
EPUBJS.replace.resources = function(callback, renderer){
|
EPUBJS.replace.resources = function(callback, renderer){
|
||||||
//srcs = this.doc.querySelectorAll('[src]');
|
//srcs = this.doc.querySelectorAll('[src]');
|
||||||
renderer.replaceWithStored("[src]", "src", EPUBJS.replace.srcs, callback);
|
renderer.replaceWithStored("[src]", "src", EPUBJS.replace.srcs, callback);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
EPUBJS.Unarchiver = function(url){
|
EPUBJS.Unarchiver = function(url){
|
||||||
|
|
||||||
|
|
||||||
this.libPath = EPUBJS.filePath;
|
this.libPath = EPUBJS.filePath;
|
||||||
this.zipUrl = url;
|
this.zipUrl = url;
|
||||||
this.loadLib()
|
this.loadLib()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue