/
base.js
60 lines (43 loc) · 1.29 KB
/
base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
var EPUBJS = EPUBJS || {};
EPUBJS.VERSION = "0.2.12";
EPUBJS.plugins = EPUBJS.plugins || {};
EPUBJS.filePath = EPUBJS.filePath || "/epubjs/";
EPUBJS.Render = {};
(function(root) {
var previousEpub = root.ePub || {};
var ePub = root.ePub = function() {
var bookPath, options;
//-- var book = ePub("path/to/book.epub", { restore: true })
if(typeof(arguments[0]) != 'undefined' &&
(typeof arguments[0] === 'string' || arguments[0] instanceof ArrayBuffer)) {
bookPath = arguments[0];
if( arguments[1] && typeof arguments[1] === 'object' ) {
options = arguments[1];
options.bookPath = bookPath;
} else {
options = { 'bookPath' : bookPath };
}
}
/*
* var book = ePub({ bookPath: "path/to/book.epub", restore: true });
*
* - OR -
*
* var book = ePub({ restore: true });
* book.open("path/to/book.epub");
*/
if( arguments[0] && typeof arguments[0] === 'object' && !(arguments[0] instanceof ArrayBuffer)) {
options = arguments[0];
}
return new EPUBJS.Book(options);
};
//exports to multiple environments
if (typeof define === 'function' && define.amd) {
//AMD
define(['rsvp'], function(){ return ePub; });
} else if (typeof module != "undefined" && module.exports) {
//Node
module.exports = ePub;
}
})(window);