mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Pass Book object to Search Example
This commit is contained in:
parent
7eb6622c8e
commit
2126099ccd
2 changed files with 13 additions and 8 deletions
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var Book;
|
||||||
|
|
||||||
document.onreadystatechange = function () {
|
document.onreadystatechange = function () {
|
||||||
if (document.readyState == "complete") {
|
if (document.readyState == "complete") {
|
||||||
|
@ -27,14 +28,16 @@
|
||||||
EPUBJS.cssPath = "css/";
|
EPUBJS.cssPath = "css/";
|
||||||
// fileStorage.filePath = EPUBJS.filePath;
|
// fileStorage.filePath = EPUBJS.filePath;
|
||||||
|
|
||||||
EPUBJSR.app.init("moby-dick/");
|
Book = EPUBJSR.app.init("moby-dick/");
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
EPUBJSR.search.View(Book);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function() {
|
|
||||||
EPUBJSR.search.View();
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="../build/epub.min.js"></script>
|
<script src="../build/epub.min.js"></script>
|
||||||
|
|
|
@ -18,7 +18,7 @@ EPUBJSR.search.request = function(q, callback) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJSR.search.View = function() {
|
EPUBJSR.search.View = function(Book) {
|
||||||
|
|
||||||
var $searchBox = $("#searchBox"),
|
var $searchBox = $("#searchBox"),
|
||||||
$searchResults = $("#searchResults"),
|
$searchResults = $("#searchResults"),
|
||||||
|
@ -75,7 +75,9 @@ EPUBJSR.search.View = function() {
|
||||||
$item.on("click", function(e) {
|
$item.on("click", function(e) {
|
||||||
var $this = $(this),
|
var $this = $(this),
|
||||||
cfi = $this.data("cfi");
|
cfi = $this.data("cfi");
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
Book.gotoCfi(cfi);
|
Book.gotoCfi(cfi);
|
||||||
|
|
||||||
Book.on("renderer:chapterDisplayed", function() {
|
Book.on("renderer:chapterDisplayed", function() {
|
||||||
|
@ -83,7 +85,7 @@ EPUBJSR.search.View = function() {
|
||||||
$(iframeDoc).find('body').highlight(q, { element: 'span' });
|
$(iframeDoc).find('body').highlight(q, { element: 'span' });
|
||||||
})
|
})
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
$li.append($item);
|
$li.append($item);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue