mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-02 14:49:16 +02:00
Update test, minify, build docs
This commit is contained in:
parent
165d8a4875
commit
d4641243a3
10 changed files with 263 additions and 74 deletions
153
dist/epub.js
vendored
153
dist/epub.js
vendored
|
@ -1034,6 +1034,9 @@ EpubCFI.prototype.toString = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
EpubCFI.prototype.compare = function(cfiOne, cfiTwo) {
|
EpubCFI.prototype.compare = function(cfiOne, cfiTwo) {
|
||||||
|
var stepsA, stepsB;
|
||||||
|
var terminalA, terminalB;
|
||||||
|
|
||||||
if(typeof cfiOne === 'string') {
|
if(typeof cfiOne === 'string') {
|
||||||
cfiOne = new EpubCFI(cfiOne);
|
cfiOne = new EpubCFI(cfiOne);
|
||||||
}
|
}
|
||||||
|
@ -1048,36 +1051,52 @@ EpubCFI.prototype.compare = function(cfiOne, cfiTwo) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfiOne.range) {
|
||||||
|
stepsA = cfiOne.path.steps.concat(cfiOne.start.steps);
|
||||||
|
terminalA = cfiOne.start.terminal;
|
||||||
|
} else {
|
||||||
|
stepsA = cfiOne.path.steps;
|
||||||
|
terminalA = cfiOne.path.terminal;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfiTwo.range) {
|
||||||
|
stepsB = cfiTwo.path.steps.concat(cfiTwo.start.steps);
|
||||||
|
terminalB = cfiTwo.start.terminal;
|
||||||
|
} else {
|
||||||
|
stepsB = cfiTwo.path.steps;
|
||||||
|
terminalB = cfiTwo.path.terminal;
|
||||||
|
}
|
||||||
|
|
||||||
// Compare Each Step in the First item
|
// Compare Each Step in the First item
|
||||||
for (var i = 0; i < cfiOne.path.steps.length; i++) {
|
for (var i = 0; i < stepsA.length; i++) {
|
||||||
if(!cfiTwo.path.steps[i]) {
|
if(!stepsA[i]) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!stepsB[i]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(cfiOne.path.steps[i].index > cfiTwo.path.steps[i].index) {
|
if(stepsA[i].index > stepsB[i].index) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(cfiOne.path.steps[i].index < cfiTwo.path.steps[i].index) {
|
if(stepsA[i].index < stepsB[i].index) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Otherwise continue checking
|
// Otherwise continue checking
|
||||||
}
|
}
|
||||||
|
|
||||||
// All steps in First equal to Second and First is Less Specific
|
// All steps in First equal to Second and First is Less Specific
|
||||||
if(cfiOne.path.steps.length < cfiTwo.path.steps.length) {
|
if(stepsA.length < stepsB.length) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare the charecter offset of the text node
|
// Compare the charecter offset of the text node
|
||||||
if(cfiOne.path.terminal.offset > cfiTwo.path.terminal.offset) {
|
if(terminalA.offset > terminalB.offset) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(cfiOne.path.terminal.offset < cfiTwo.path.terminal.offset) {
|
if(terminalA.offset < terminalB.offset) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: compare ranges
|
|
||||||
|
|
||||||
// CFI's are equal
|
// CFI's are equal
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
@ -1215,7 +1234,6 @@ EpubCFI.prototype.fromRange = function(range, base, ignoreClass) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cfi.start = this.pathTo(start, startOffset, ignoreClass);
|
cfi.start = this.pathTo(start, startOffset, ignoreClass);
|
||||||
|
|
||||||
if (needsIgnoring) {
|
if (needsIgnoring) {
|
||||||
endOffset = this.patchOffset(end, endOffset, ignoreClass);
|
endOffset = this.patchOffset(end, endOffset, ignoreClass);
|
||||||
}
|
}
|
||||||
|
@ -1234,7 +1252,7 @@ EpubCFI.prototype.fromRange = function(range, base, ignoreClass) {
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (this.equalStep(cfi.start.steps[i], cfi.end.steps[i])) {
|
if (this.equalStep(cfi.start.steps[i], cfi.end.steps[i])) {
|
||||||
if(i == len-1) {
|
if(i === len-1) {
|
||||||
// Last step is equal, check terminals
|
// Last step is equal, check terminals
|
||||||
if(cfi.start.terminal === cfi.end.terminal) {
|
if(cfi.start.terminal === cfi.end.terminal) {
|
||||||
// CFI's are equal
|
// CFI's are equal
|
||||||
|
@ -4270,6 +4288,15 @@ DefaultViewManager.prototype.display = function(section, target){
|
||||||
this.views.clear();
|
this.views.clear();
|
||||||
|
|
||||||
this.add(section)
|
this.add(section)
|
||||||
|
.then(function(view){
|
||||||
|
|
||||||
|
// Move to correct place within the section, if needed
|
||||||
|
if(target) {
|
||||||
|
offset = view.locationOf(target);
|
||||||
|
this.moveTo(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
}.bind(this))
|
||||||
.then(function(){
|
.then(function(){
|
||||||
var next;
|
var next;
|
||||||
if (this.layout.name === "pre-paginated" &&
|
if (this.layout.name === "pre-paginated" &&
|
||||||
|
@ -4280,13 +4307,7 @@ DefaultViewManager.prototype.display = function(section, target){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
.then(function(view){
|
.then(function(){
|
||||||
|
|
||||||
// Move to correct place within the section, if needed
|
|
||||||
if(target) {
|
|
||||||
offset = view.locationOf(target);
|
|
||||||
this.moveTo(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.views.show();
|
this.views.show();
|
||||||
|
|
||||||
|
@ -4473,15 +4494,34 @@ DefaultViewManager.prototype.current = function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
DefaultViewManager.prototype.currentLocation = function(){
|
DefaultViewManager.prototype.currentLocation = function(){
|
||||||
|
|
||||||
|
if (this.settings.axis === "vertical") {
|
||||||
|
this.location = this.scrolledLocation();
|
||||||
|
} else {
|
||||||
|
this.location = this.paginatedLocation();
|
||||||
|
}
|
||||||
|
return this.location;
|
||||||
|
};
|
||||||
|
|
||||||
|
DefaultViewManager.prototype.scrolledLocation = function(){
|
||||||
|
var view;
|
||||||
|
|
||||||
|
if(this.views.length) {
|
||||||
|
view = this.views.first();
|
||||||
|
return this.mapping.page(view, view.section.cfiBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
DefaultViewManager.prototype.paginatedLocation = function(){
|
||||||
var view;
|
var view;
|
||||||
var start, end;
|
var start, end;
|
||||||
|
|
||||||
if(this.views.length) {
|
if(this.views.length) {
|
||||||
view = this.views.first();
|
view = this.views.first();
|
||||||
start = container.left - view.position().left;
|
start = this._bounds.left - view.position().left;
|
||||||
end = start + this.layout.spread;
|
end = start + this.layout.spreadWidth;
|
||||||
|
return this.mapping.page(view, view.section.cfiBase, start, end);
|
||||||
return this.mapping.page(view, view.section.cfiBase);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -4975,7 +5015,7 @@ Rendition.prototype.afterDisplayed = function(view){
|
||||||
* Report resize events and display the last seen location
|
* Report resize events and display the last seen location
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Rendition.prototype.onResized = function(){
|
Rendition.prototype.onResized = function(size){
|
||||||
|
|
||||||
if(this.location) {
|
if(this.location) {
|
||||||
this.display(this.location.start);
|
this.display(this.location.start);
|
||||||
|
@ -5114,6 +5154,7 @@ Rendition.prototype.spread = function(spread, min){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report the current location
|
* Report the current location
|
||||||
|
* @private
|
||||||
*/
|
*/
|
||||||
Rendition.prototype.reportLocation = function(){
|
Rendition.prototype.reportLocation = function(){
|
||||||
return this.q.enqueue(function(){
|
return this.q.enqueue(function(){
|
||||||
|
@ -5121,16 +5162,50 @@ Rendition.prototype.reportLocation = function(){
|
||||||
if (location && location.then && typeof location.then === 'function') {
|
if (location && location.then && typeof location.then === 'function') {
|
||||||
location.then(function(result) {
|
location.then(function(result) {
|
||||||
this.location = result;
|
this.location = result;
|
||||||
|
|
||||||
|
this.percentage = this.book.locations.percentageFromCfi(result);
|
||||||
|
if (this.percentage != null) {
|
||||||
|
this.location.percentage = this.percentage;
|
||||||
|
}
|
||||||
|
|
||||||
this.emit("locationChanged", this.location);
|
this.emit("locationChanged", this.location);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
} else if (location) {
|
} else if (location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
this.percentage = this.book.locations.percentageFromCfi(location);
|
||||||
|
if (this.percentage != null) {
|
||||||
|
this.location.percentage = this.percentage;
|
||||||
|
}
|
||||||
|
|
||||||
this.emit("locationChanged", this.location);
|
this.emit("locationChanged", this.location);
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Current Location CFI
|
||||||
|
* @return {EpubCFI} location (may be a promise)
|
||||||
|
*/
|
||||||
|
Rendition.prototype.currentLocation = function(){
|
||||||
|
var location = this.manager.currentLocation();
|
||||||
|
if (location && location.then && typeof location.then === 'function') {
|
||||||
|
location.then(function(result) {
|
||||||
|
var percentage = this.book.locations.percentageFromCfi(result);
|
||||||
|
if (percentage != null) {
|
||||||
|
result.percentage = percentage;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}.bind(this));
|
||||||
|
} else if (location) {
|
||||||
|
var percentage = this.book.locations.percentageFromCfi(location);
|
||||||
|
if (percentage != null) {
|
||||||
|
location.percentage = percentage;
|
||||||
|
}
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove and Clean Up the Rendition
|
* Remove and Clean Up the Rendition
|
||||||
*/
|
*/
|
||||||
|
@ -5341,7 +5416,7 @@ function Book(url, options){
|
||||||
/**
|
/**
|
||||||
* @property {Locations} locations
|
* @property {Locations} locations
|
||||||
*/
|
*/
|
||||||
this.locations = new Locations(this.spine, this.load);
|
this.locations = new Locations(this.spine, this.load.bind(this));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Navigation} navigation
|
* @property {Navigation} navigation
|
||||||
|
@ -5403,7 +5478,7 @@ Book.prototype.open = function(input, what){
|
||||||
.then(this.openEpub.bind(this));
|
.then(this.openEpub.bind(this));
|
||||||
} else if(type == "opf") {
|
} else if(type == "opf") {
|
||||||
this.url = new Url(input);
|
this.url = new Url(input);
|
||||||
opening = this.openPackaging(input);
|
opening = this.openPackaging(this.url.Path.toString());
|
||||||
} else {
|
} else {
|
||||||
this.url = new Url(input);
|
this.url = new Url(input);
|
||||||
opening = this.openContainer(CONTAINER_PATH)
|
opening = this.openContainer(CONTAINER_PATH)
|
||||||
|
@ -5453,7 +5528,6 @@ Book.prototype.openContainer = function(url){
|
||||||
Book.prototype.openPackaging = function(url){
|
Book.prototype.openPackaging = function(url){
|
||||||
var packageUrl;
|
var packageUrl;
|
||||||
this.path = new Path(url);
|
this.path = new Path(url);
|
||||||
|
|
||||||
return this.load(url)
|
return this.load(url)
|
||||||
.then(function(xml) {
|
.then(function(xml) {
|
||||||
this.packaging = new Packaging(xml);
|
this.packaging = new Packaging(xml);
|
||||||
|
@ -5704,6 +5778,16 @@ Book.prototype.range = function(cfiRange) {
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the Book Key using the identifer in the manifest or other string provided
|
||||||
|
* @param {[string]} identifier to use instead of metadata identifier
|
||||||
|
* @return {string} key
|
||||||
|
*/
|
||||||
|
Book.prototype.key = function(identifier){
|
||||||
|
var ident = identifier || this.package.metadata.identifier || this.url.filename;
|
||||||
|
return "epubjs:" + ePub.VERSION + ":" + ident;
|
||||||
|
};
|
||||||
|
|
||||||
//-- Enable binding events to book
|
//-- Enable binding events to book
|
||||||
EventEmitter(Book.prototype);
|
EventEmitter(Book.prototype);
|
||||||
|
|
||||||
|
@ -8061,7 +8145,7 @@ Locations.prototype.generate = function(chars) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._locations;
|
return this._locations;
|
||||||
// console.log(this.precentage(this.book.rendition.location.start), this.precentage(this.book.rendition.location.end));
|
// console.log(this.percentage(this.book.rendition.location.start), this.percentage(this.book.rendition.location.end));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -8073,9 +8157,10 @@ Locations.prototype.process = function(section) {
|
||||||
|
|
||||||
var range;
|
var range;
|
||||||
var doc = contents.ownerDocument;
|
var doc = contents.ownerDocument;
|
||||||
|
var body = core.qs(doc, 'body');
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
|
|
||||||
this.sprint(contents, function(node) {
|
this.sprint(body, function(node) {
|
||||||
var len = node.length;
|
var len = node.length;
|
||||||
var dist;
|
var dist;
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
|
@ -8148,15 +8233,17 @@ Locations.prototype.locationFromCfi = function(cfi){
|
||||||
if(this._locations.length === 0) {
|
if(this._locations.length === 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
return core.locationOf(cfi.start, this._locations, this.epubcfi.compare);
|
||||||
return core.locationOf(cfi, this._locations, this.epubcfi.compare);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Locations.prototype.precentageFromCfi = function(cfi) {
|
Locations.prototype.percentageFromCfi = function(cfi) {
|
||||||
|
if(this._locations.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// Find closest cfi
|
// Find closest cfi
|
||||||
var loc = this.locationFromCfi(cfi);
|
var loc = this.locationFromCfi(cfi);
|
||||||
// Get percentage in total
|
// Get percentage in total
|
||||||
return this.precentageFromLocation(loc);
|
return this.percentageFromLocation(loc);
|
||||||
};
|
};
|
||||||
|
|
||||||
Locations.prototype.percentageFromLocation = function(loc) {
|
Locations.prototype.percentageFromLocation = function(loc) {
|
||||||
|
@ -8224,7 +8311,7 @@ Locations.prototype.setCurrent = function(curr){
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit("changed", {
|
this.emit("changed", {
|
||||||
percentage: this.precentageFromLocation(loc)
|
percentage: this.percentageFromLocation(loc)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
dist/epub.js.map
vendored
2
dist/epub.js.map
vendored
File diff suppressed because one or more lines are too long
8
dist/epub.min.js
vendored
8
dist/epub.min.js
vendored
File diff suppressed because one or more lines are too long
33
dist/polyfills.js
vendored
33
dist/polyfills.js
vendored
|
@ -77,13 +77,24 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
/******/ ({
|
/******/ ({
|
||||||
|
|
||||||
/***/ 14:
|
/***/ 14:
|
||||||
/***/ function(module, exports) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
"use strict";
|
||||||
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* Any copyright is dedicated to the Public Domain.
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
'use strict';
|
||||||
(function(scope) {
|
(function (root, factory) {
|
||||||
'use strict';
|
if (true) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
||||||
|
} else if (typeof module === 'object' && module.exports) {
|
||||||
|
// Node
|
||||||
|
module.exports = factory(global);
|
||||||
|
} else {
|
||||||
|
// Browser globals (root is window)
|
||||||
|
root.URL = factory(root);
|
||||||
|
}
|
||||||
|
}(this, function (scope) {
|
||||||
|
|
||||||
// feature detect for URL constructor
|
// feature detect for URL constructor
|
||||||
var hasWorkingUrl = false;
|
var hasWorkingUrl = false;
|
||||||
|
@ -96,7 +107,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasWorkingUrl)
|
if (hasWorkingUrl)
|
||||||
return;
|
return scope.URL;
|
||||||
|
|
||||||
var relative = Object.create(null);
|
var relative = Object.create(null);
|
||||||
relative['ftp'] = 21;
|
relative['ftp'] = 21;
|
||||||
|
@ -692,14 +703,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.URL = jURL;
|
return jURL;
|
||||||
|
}));
|
||||||
// Export for CommonJS
|
|
||||||
if (typeof module === 'object' && module.exports) {
|
|
||||||
module.exports = jURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
})(this);
|
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
|
|
2
dist/polyfills.js.map
vendored
2
dist/polyfills.js.map
vendored
File diff suppressed because one or more lines are too long
6
dist/polyfills.min.js
vendored
6
dist/polyfills.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -148,6 +148,12 @@
|
||||||
#range
|
#range
|
||||||
</a></li>
|
</a></li>
|
||||||
|
|
||||||
|
<li><a
|
||||||
|
href='#Book#key'
|
||||||
|
class='regular pre-open'>
|
||||||
|
#key
|
||||||
|
</a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
@ -671,9 +677,9 @@
|
||||||
</a></li>
|
</a></li>
|
||||||
|
|
||||||
<li><a
|
<li><a
|
||||||
href='#Rendition#reportLocation'
|
href='#Rendition#currentLocation'
|
||||||
class='regular pre-open'>
|
class='regular pre-open'>
|
||||||
#reportLocation
|
#currentLocation
|
||||||
</a></li>
|
</a></li>
|
||||||
|
|
||||||
<li><a
|
<li><a
|
||||||
|
@ -1176,7 +1182,7 @@
|
||||||
|
|
||||||
(default <code>base64</code>)
|
(default <code>base64</code>)
|
||||||
</td>
|
</td>
|
||||||
<td class='break-word'><span>use base64, blobs, or none for replacing assets in archived Epubs
|
<td class='break-word'><span>use base64, blobUrl, or none for replacing assets in archived Epubs
|
||||||
</span></td>
|
</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -1208,6 +1214,9 @@
|
||||||
|
|
||||||
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">new</span> Book(<span class="hljs-string">"/path/to/book.epub"</span>, {})</pre>
|
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">new</span> Book(<span class="hljs-string">"/path/to/book.epub"</span>, {})</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">new</span> Book({ <span class="hljs-attr">replacements</span>: <span class="hljs-string">"blobUrl"</span> })</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2069,6 +2078,72 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='border-bottom' id='Book#key'>
|
||||||
|
<div class="clearfix small pointer toggle-sibling">
|
||||||
|
<div class="py1 contain">
|
||||||
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
||||||
|
<span class='code strong strong truncate'>key(identifier)</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="clearfix display-none toggle-target">
|
||||||
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p>Generates the Book Key using the identifer in the manifest or other string provided</p>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='pre p1 fill-light mt0'>key(identifier: [<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>]): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
||||||
|
<div class='prose'>
|
||||||
|
|
||||||
|
<div class='space-bottom0'>
|
||||||
|
<div>
|
||||||
|
<span class='code bold'>identifier</span> <code class='quiet'>([<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>])</code> to use instead of metadata identifier
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
||||||
|
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>:
|
||||||
|
key
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -6067,11 +6142,11 @@ Usually you would be better off calling display()</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='border-bottom' id='Rendition#reportLocation'>
|
<div class='border-bottom' id='Rendition#currentLocation'>
|
||||||
<div class="clearfix small pointer toggle-sibling">
|
<div class="clearfix small pointer toggle-sibling">
|
||||||
<div class="py1 contain">
|
<div class="py1 contain">
|
||||||
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
||||||
<span class='code strong strong truncate'>reportLocation()</span>
|
<span class='code strong strong truncate'>currentLocation()</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix display-none toggle-target">
|
<div class="clearfix display-none toggle-target">
|
||||||
|
@ -6079,10 +6154,10 @@ Usually you would be better off calling display()</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<p>Report the current location</p>
|
<p>Get the Current Location CFI</p>
|
||||||
|
|
||||||
|
|
||||||
<div class='pre p1 fill-light mt0'>reportLocation()</div>
|
<div class='pre p1 fill-light mt0'>currentLocation(): <a href="#epubcfi">EpubCFI</a></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6097,6 +6172,14 @@ Usually you would be better off calling display()</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
||||||
|
<code><a href="#epubcfi">EpubCFI</a></code>:
|
||||||
|
location (may be a promise)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ Creates a new Book
|
||||||
- `options.requestCredentials` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** send the xhr request withCredentials (optional, default `undefined`)
|
- `options.requestCredentials` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** send the xhr request withCredentials (optional, default `undefined`)
|
||||||
- `options.requestHeaders` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** send the xhr request headers (optional, default `undefined`)
|
- `options.requestHeaders` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** send the xhr request headers (optional, default `undefined`)
|
||||||
- `options.encoding` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** optional to pass 'binary' or base64' for archived Epubs (optional, default `binary`)
|
- `options.encoding` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** optional to pass 'binary' or base64' for archived Epubs (optional, default `binary`)
|
||||||
- `options.replacements` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** use base64, blobs, or none for replacing assets in archived Epubs (optional, default `base64`)
|
- `options.replacements` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** use base64, blobUrl, or none for replacing assets in archived Epubs (optional, default `base64`)
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
|
@ -49,6 +49,10 @@ Creates a new Book
|
||||||
new Book("/path/to/book.epub", {})
|
new Book("/path/to/book.epub", {})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
new Book({ replacements: "blobUrl" })
|
||||||
|
```
|
||||||
|
|
||||||
Returns **[Book](#book)**
|
Returns **[Book](#book)**
|
||||||
|
|
||||||
## opened
|
## opened
|
||||||
|
@ -170,6 +174,16 @@ Find a DOM Range for a given CFI Range
|
||||||
|
|
||||||
Returns **[Range](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input)**
|
Returns **[Range](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input)**
|
||||||
|
|
||||||
|
## key
|
||||||
|
|
||||||
|
Generates the Book Key using the identifer in the manifest or other string provided
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `identifier` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** to use instead of metadata identifier
|
||||||
|
|
||||||
|
Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** key
|
||||||
|
|
||||||
# Url
|
# Url
|
||||||
|
|
||||||
creates a uri object
|
creates a uri object
|
||||||
|
@ -765,9 +779,11 @@ Adjust if the rendition uses spreads
|
||||||
- `spread` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** none | auto (TODO: implement landscape, portrait, both)
|
- `spread` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** none | auto (TODO: implement landscape, portrait, both)
|
||||||
- `min` **int** min width to use spreads at
|
- `min` **int** min width to use spreads at
|
||||||
|
|
||||||
## reportLocation
|
## currentLocation
|
||||||
|
|
||||||
Report the current location
|
Get the Current Location CFI
|
||||||
|
|
||||||
|
Returns **[EpubCFI](#epubcfi)** location (may be a promise)
|
||||||
|
|
||||||
## destroy
|
## destroy
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ describe('ePub', function() {
|
||||||
/*
|
/*
|
||||||
// var packageContents = fs.readFileSync(__dirname + '/../books/moby-dick/OPS/package.opf', 'utf8');
|
// var packageContents = fs.readFileSync(__dirname + '/../books/moby-dick/OPS/package.opf', 'utf8');
|
||||||
// var tocContents = fs.readFileSync(__dirname + '/../books/moby-dick/OPS/toc.xhtml', 'utf8');
|
// var tocContents = fs.readFileSync(__dirname + '/../books/moby-dick/OPS/toc.xhtml', 'utf8');
|
||||||
var packageContents = require('raw!./fixtures/moby-dick/OPS/package.opf');
|
var packageContents = require('raw-loader!./fixtures/moby-dick/OPS/package.opf');
|
||||||
var tocContents = require('raw!./fixtures/moby-dick/OPS/toc.xhtml');
|
var tocContents = require('raw-loader!./fixtures/moby-dick/OPS/toc.xhtml');
|
||||||
|
|
||||||
server = sinon.fakeServer.create();
|
server = sinon.fakeServer.create();
|
||||||
server.autoRespond = true;
|
server.autoRespond = true;
|
||||||
|
|
|
@ -137,7 +137,7 @@ describe('EpubCFI', function() {
|
||||||
describe('#fromNode()', function() {
|
describe('#fromNode()', function() {
|
||||||
var base = "/6/4[chap01ref]";
|
var base = "/6/4[chap01ref]";
|
||||||
// var contents = fs.readFileSync(__dirname + '/fixtures/chapter1-highlights.xhtml', 'utf8');
|
// var contents = fs.readFileSync(__dirname + '/fixtures/chapter1-highlights.xhtml', 'utf8');
|
||||||
var contents = require('raw!./fixtures/chapter1-highlights.xhtml');
|
var contents = require('raw-loader!./fixtures/chapter1-highlights.xhtml');
|
||||||
|
|
||||||
// var serializer = new XMLSerializer();
|
// var serializer = new XMLSerializer();
|
||||||
// var doc = serializer.serializeToString(contents);
|
// var doc = serializer.serializeToString(contents);
|
||||||
|
@ -186,16 +186,16 @@ describe('EpubCFI', function() {
|
||||||
var base = "/6/4[chap01ref]";
|
var base = "/6/4[chap01ref]";
|
||||||
|
|
||||||
// var contentsClean = fs.readFileSync(__dirname + '/fixtures/chapter1.xhtml', 'utf8');
|
// var contentsClean = fs.readFileSync(__dirname + '/fixtures/chapter1.xhtml', 'utf8');
|
||||||
var contentsClean = require('raw!./fixtures/chapter1.xhtml');
|
var contentsClean = require('raw-loader!./fixtures/chapter1.xhtml');
|
||||||
|
|
||||||
var doc = new DOMParser().parseFromString(contentsClean, "application/xhtml+xml");
|
var doc = new DOMParser().parseFromString(contentsClean, "application/xhtml+xml");
|
||||||
|
|
||||||
// var contentsHighlights = fs.readFileSync(__dirname + '/fixtures/chapter1-highlights.xhtml', 'utf8');
|
// var contentsHighlights = fs.readFileSync(__dirname + '/fixtures/chapter1-highlights.xhtml', 'utf8');
|
||||||
var contentsHighlights = require('raw!./fixtures/chapter1-highlights.xhtml');
|
var contentsHighlights = require('raw-loader!./fixtures/chapter1-highlights.xhtml');
|
||||||
var docHighlights = new DOMParser().parseFromString(contentsHighlights, "application/xhtml+xml");
|
var docHighlights = new DOMParser().parseFromString(contentsHighlights, "application/xhtml+xml");
|
||||||
|
|
||||||
// var highlightContents = fs.readFileSync(__dirname + '/fixtures/highlight.xhtml', 'utf8');
|
// var highlightContents = fs.readFileSync(__dirname + '/fixtures/highlight.xhtml', 'utf8');
|
||||||
var highlightContents = require('raw!./fixtures/highlight.xhtml');
|
var highlightContents = require('raw-loader!./fixtures/highlight.xhtml');
|
||||||
var docHighlightsAlice = new DOMParser().parseFromString(highlightContents, "application/xhtml+xml");
|
var docHighlightsAlice = new DOMParser().parseFromString(highlightContents, "application/xhtml+xml");
|
||||||
|
|
||||||
it('get a cfi from a collapsed range', function() {
|
it('get a cfi from a collapsed range', function() {
|
||||||
|
@ -302,7 +302,7 @@ describe('EpubCFI', function() {
|
||||||
describe('#toRange()', function() {
|
describe('#toRange()', function() {
|
||||||
var base = "/6/4[chap01ref]";
|
var base = "/6/4[chap01ref]";
|
||||||
// var contents = fs.readFileSync(__dirname + '/fixtures/chapter1-highlights.xhtml', 'utf8');
|
// var contents = fs.readFileSync(__dirname + '/fixtures/chapter1-highlights.xhtml', 'utf8');
|
||||||
var contents = require('raw!./fixtures/chapter1-highlights.xhtml');
|
var contents = require('raw-loader!./fixtures/chapter1-highlights.xhtml');
|
||||||
var doc = new DOMParser().parseFromString(contents, "application/xhtml+xml");
|
var doc = new DOMParser().parseFromString(contents, "application/xhtml+xml");
|
||||||
|
|
||||||
// var serializer = new XMLSerializer();
|
// var serializer = new XMLSerializer();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue