update epub.js
This commit is contained in:
parent
335eac0f6b
commit
883f240365
51 changed files with 21526 additions and 18226 deletions
16780
epub.js/js/epub.js
Normal file
16780
epub.js/js/epub.js
Normal file
File diff suppressed because it is too large
Load diff
1
epub.js/js/epub.min.map
Normal file
1
epub.js/js/epub.min.map
Normal file
File diff suppressed because one or more lines are too long
1
epub.js/js/hooks.min.map
Normal file
1
epub.js/js/hooks.min.map
Normal file
File diff suppressed because one or more lines are too long
14
epub.js/js/hooks/extensions/highlight.js
Normal file
14
epub.js/js/hooks/extensions/highlight.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
EPUBJS.Hooks.register("beforeChapterDisplay").highlight = function(callback, renderer){
|
||||
|
||||
// EPUBJS.core.addScript("js/libs/jquery.highlight.js", null, renderer.doc.head);
|
||||
|
||||
var s = document.createElement("style");
|
||||
s.innerHTML =".highlight { background: yellow; font-weight: normal; }";
|
||||
|
||||
renderer.render.document.head.appendChild(s);
|
||||
|
||||
if(callback) callback();
|
||||
|
||||
}
|
||||
|
||||
|
||||
145
epub.js/js/libs/screenfull.js
Normal file
145
epub.js/js/libs/screenfull.js
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/*!
|
||||
* screenfull
|
||||
* v2.0.0 - 2014-12-22
|
||||
* (c) Sindre Sorhus; MIT License
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var isCommonjs = typeof module !== 'undefined' && module.exports;
|
||||
var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element;
|
||||
|
||||
var fn = (function () {
|
||||
var val;
|
||||
var valLength;
|
||||
|
||||
var fnMap = [
|
||||
[
|
||||
'requestFullscreen',
|
||||
'exitFullscreen',
|
||||
'fullscreenElement',
|
||||
'fullscreenEnabled',
|
||||
'fullscreenchange',
|
||||
'fullscreenerror'
|
||||
],
|
||||
// new WebKit
|
||||
[
|
||||
'webkitRequestFullscreen',
|
||||
'webkitExitFullscreen',
|
||||
'webkitFullscreenElement',
|
||||
'webkitFullscreenEnabled',
|
||||
'webkitfullscreenchange',
|
||||
'webkitfullscreenerror'
|
||||
|
||||
],
|
||||
// old WebKit (Safari 5.1)
|
||||
[
|
||||
'webkitRequestFullScreen',
|
||||
'webkitCancelFullScreen',
|
||||
'webkitCurrentFullScreenElement',
|
||||
'webkitCancelFullScreen',
|
||||
'webkitfullscreenchange',
|
||||
'webkitfullscreenerror'
|
||||
|
||||
],
|
||||
[
|
||||
'mozRequestFullScreen',
|
||||
'mozCancelFullScreen',
|
||||
'mozFullScreenElement',
|
||||
'mozFullScreenEnabled',
|
||||
'mozfullscreenchange',
|
||||
'mozfullscreenerror'
|
||||
],
|
||||
[
|
||||
'msRequestFullscreen',
|
||||
'msExitFullscreen',
|
||||
'msFullscreenElement',
|
||||
'msFullscreenEnabled',
|
||||
'MSFullscreenChange',
|
||||
'MSFullscreenError'
|
||||
]
|
||||
];
|
||||
|
||||
var i = 0;
|
||||
var l = fnMap.length;
|
||||
var ret = {};
|
||||
|
||||
for (; i < l; i++) {
|
||||
val = fnMap[i];
|
||||
if (val && val[1] in document) {
|
||||
for (i = 0, valLength = val.length; i < valLength; i++) {
|
||||
ret[fnMap[0][i]] = val[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
})();
|
||||
|
||||
var screenfull = {
|
||||
request: function (elem) {
|
||||
var request = fn.requestFullscreen;
|
||||
|
||||
elem = elem || document.documentElement;
|
||||
|
||||
// Work around Safari 5.1 bug: reports support for
|
||||
// keyboard in fullscreen even though it doesn't.
|
||||
// Browser sniffing, since the alternative with
|
||||
// setTimeout is even worse.
|
||||
if (/5\.1[\.\d]* Safari/.test(navigator.userAgent)) {
|
||||
elem[request]();
|
||||
} else {
|
||||
elem[request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT);
|
||||
}
|
||||
},
|
||||
exit: function () {
|
||||
document[fn.exitFullscreen]();
|
||||
},
|
||||
toggle: function (elem) {
|
||||
if (this.isFullscreen) {
|
||||
this.exit();
|
||||
} else {
|
||||
this.request(elem);
|
||||
}
|
||||
},
|
||||
raw: fn
|
||||
};
|
||||
|
||||
if (!fn) {
|
||||
if (isCommonjs) {
|
||||
module.exports = false;
|
||||
} else {
|
||||
window.screenfull = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Object.defineProperties(screenfull, {
|
||||
isFullscreen: {
|
||||
get: function () {
|
||||
return !!document[fn.fullscreenElement];
|
||||
}
|
||||
},
|
||||
element: {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return document[fn.fullscreenElement];
|
||||
}
|
||||
},
|
||||
enabled: {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
// Coerce to boolean in case of old WebKit
|
||||
return !!document[fn.fullscreenEnabled];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (isCommonjs) {
|
||||
module.exports = screenfull;
|
||||
} else {
|
||||
window.screenfull = screenfull;
|
||||
}
|
||||
})();
|
||||
80
epub.js/js/plugins/hypothesis.js
Normal file
80
epub.js/js/plugins/hypothesis.js
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// Hypothesis Customized embedding
|
||||
// This hypothesis config function returns a new constructor which modifies
|
||||
// annotator for a better integration. Below we create our own EpubAnnotationSidebar
|
||||
// Constructor, customizing the show and hide function to take acount for the reader UI.
|
||||
|
||||
window.hypothesisConfig = function() {
|
||||
var Annotator = window.Annotator;
|
||||
var $main = $("#main");
|
||||
|
||||
function EpubAnnotationSidebar(elem, options) {
|
||||
options = {
|
||||
server: true,
|
||||
origin: true,
|
||||
showHighlights: true,
|
||||
Toolbar: {container: '#annotation-controls'}
|
||||
}
|
||||
|
||||
Annotator.Host.call(this, elem, options);
|
||||
}
|
||||
|
||||
EpubAnnotationSidebar.prototype = Object.create(Annotator.Host.prototype);
|
||||
|
||||
EpubAnnotationSidebar.prototype.show = function() {
|
||||
this.frame.css({
|
||||
'margin-left': (-1 * this.frame.width()) + "px"
|
||||
});
|
||||
this.frame.removeClass('annotator-collapsed');
|
||||
if (!$main.hasClass('single')) {
|
||||
$main.addClass("single");
|
||||
this.toolbar.find('[name=sidebar-toggle]').removeClass('h-icon-chevron-left').addClass('h-icon-chevron-right');
|
||||
this.setVisibleHighlights(true);
|
||||
}
|
||||
};
|
||||
|
||||
EpubAnnotationSidebar.prototype.hide = function() {
|
||||
this.frame.css({
|
||||
'margin-left': ''
|
||||
});
|
||||
this.frame.addClass('annotator-collapsed');
|
||||
if ($main.hasClass('single')) {
|
||||
$main.removeClass("single");
|
||||
this.toolbar.find('[name=sidebar-toggle]').removeClass('h-icon-chevron-right').addClass('h-icon-chevron-left');
|
||||
this.setVisibleHighlights(false);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
constructor: EpubAnnotationSidebar,
|
||||
}
|
||||
};
|
||||
|
||||
// This is the Epub.js plugin. Annotations are updated on location change.
|
||||
EPUBJS.reader.plugins.HypothesisController = function (Book) {
|
||||
var reader = this;
|
||||
var $main = $("#main");
|
||||
|
||||
var updateAnnotations = function () {
|
||||
var annotator = Book.renderer.render.window.annotator;
|
||||
if (annotator && annotator.constructor.$) {
|
||||
var annotations = getVisibleAnnotations(annotator.constructor.$);
|
||||
annotator.showAnnotations(annotations)
|
||||
}
|
||||
};
|
||||
|
||||
var getVisibleAnnotations = function ($) {
|
||||
var width = Book.renderer.render.iframe.clientWidth;
|
||||
return $('.annotator-hl').map(function() {
|
||||
var $this = $(this),
|
||||
left = this.getBoundingClientRect().left;
|
||||
|
||||
if (left >= 0 && left <= width) {
|
||||
return $this.data('annotation');
|
||||
}
|
||||
}).get();
|
||||
};
|
||||
|
||||
Book.on("renderer:locationChanged", updateAnnotations);
|
||||
|
||||
return {}
|
||||
};
|
||||
125
epub.js/js/plugins/search.js
Normal file
125
epub.js/js/plugins/search.js
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
EPUBJS.reader.search = {};
|
||||
|
||||
// Search Server -- https://github.com/futurepress/epubjs-search
|
||||
EPUBJS.reader.search.SERVER = "https://pacific-cliffs-3579.herokuapp.com";
|
||||
|
||||
EPUBJS.reader.search.request = function(q, callback) {
|
||||
var fetch = $.ajax({
|
||||
dataType: "json",
|
||||
url: EPUBJS.reader.search.SERVER + "/search?q=" + encodeURIComponent(q)
|
||||
});
|
||||
|
||||
fetch.fail(function(err) {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
fetch.done(function(results) {
|
||||
callback(results);
|
||||
});
|
||||
};
|
||||
|
||||
EPUBJS.reader.plugins.SearchController = function(Book) {
|
||||
var reader = this;
|
||||
|
||||
var $searchBox = $("#searchBox"),
|
||||
$searchResults = $("#searchResults"),
|
||||
$searchView = $("#searchView"),
|
||||
iframeDoc;
|
||||
|
||||
var searchShown = false;
|
||||
|
||||
var onShow = function() {
|
||||
query();
|
||||
searchShown = true;
|
||||
$searchView.addClass("shown");
|
||||
};
|
||||
|
||||
var onHide = function() {
|
||||
searchShown = false;
|
||||
$searchView.removeClass("shown");
|
||||
};
|
||||
|
||||
var query = function() {
|
||||
var q = $searchBox.val();
|
||||
|
||||
if(q == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$searchResults.empty();
|
||||
$searchResults.append("<li><p>Searching...</p></li>");
|
||||
|
||||
|
||||
|
||||
EPUBJS.reader.search.request(q, function(data) {
|
||||
var results = data.results;
|
||||
|
||||
$searchResults.empty();
|
||||
|
||||
if(iframeDoc) {
|
||||
$(iframeDoc).find('body').unhighlight();
|
||||
}
|
||||
|
||||
if(results.length == 0) {
|
||||
$searchResults.append("<li><p>No Results Found</p></li>");
|
||||
return;
|
||||
}
|
||||
|
||||
iframeDoc = $("#viewer iframe")[0].contentDocument;
|
||||
$(iframeDoc).find('body').highlight(q, { element: 'span' });
|
||||
|
||||
results.forEach(function(result) {
|
||||
var $li = $("<li></li>");
|
||||
var $item = $("<a href='"+result.href+"' data-cfi='"+result.cfi+"'><span>"+result.title+"</span><p>"+result.highlight+"</p></a>");
|
||||
|
||||
$item.on("click", function(e) {
|
||||
var $this = $(this),
|
||||
cfi = $this.data("cfi");
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
Book.gotoCfi(cfi+"/1:0");
|
||||
|
||||
Book.on("renderer:chapterDisplayed", function() {
|
||||
iframeDoc = $("#viewer iframe")[0].contentDocument;
|
||||
$(iframeDoc).find('body').highlight(q, { element: 'span' });
|
||||
})
|
||||
|
||||
|
||||
|
||||
});
|
||||
$li.append($item);
|
||||
$searchResults.append($li);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$searchBox.on("search", function(e) {
|
||||
var q = $searchBox.val();
|
||||
|
||||
//-- SearchBox is empty or cleared
|
||||
if(q == '') {
|
||||
$searchResults.empty();
|
||||
if(reader.SidebarController.getActivePanel() == "Search") {
|
||||
reader.SidebarController.changePanelTo("Toc");
|
||||
}
|
||||
|
||||
$(iframeDoc).find('body').unhighlight();
|
||||
iframeDoc = false;
|
||||
return;
|
||||
}
|
||||
|
||||
reader.SidebarController.changePanelTo("Search");
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
|
||||
return {
|
||||
"show" : onShow,
|
||||
"hide" : onHide
|
||||
};
|
||||
};
|
||||
4372
epub.js/js/reader.js
Normal file
4372
epub.js/js/reader.js
Normal file
File diff suppressed because it is too large
Load diff
89
epub.js/js/reader.js.map
Normal file
89
epub.js/js/reader.js.map
Normal file
File diff suppressed because one or more lines are too long
1
epub.js/js/reader.min.map
Normal file
1
epub.js/js/reader.min.map
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue