mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Updated examples
This commit is contained in:
parent
89387f1ef2
commit
e408a822e0
20 changed files with 468 additions and 699 deletions
|
@ -1,123 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>EPUB.js Single Example</title>
|
||||
|
||||
<script src="../dist/epub.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
background: #fafafa;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#viewer {
|
||||
|
||||
overflow: hidden;
|
||||
width: 800px;
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#viewer .epub-container {
|
||||
background: white;
|
||||
box-shadow: 0 0 4px #ccc;
|
||||
margin: 10px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
margin: 14px;
|
||||
display: block;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.arrow:hover {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.arrow:active {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#toc {
|
||||
display: block;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a id="prev" href="#prev" class="arrow">...</a>
|
||||
<div id="viewer"></div>
|
||||
<a id="next" href="#next" class="arrow">...</a>
|
||||
|
||||
<script>
|
||||
var currentSectionIndex = 8;
|
||||
// Load the opf
|
||||
var book = ePub("https://s3.amazonaws.com/epubjs/books/alice/OPS/package.opf");
|
||||
var rendition = book.renderTo("viewer", {
|
||||
flow: "scrolled-doc",
|
||||
});
|
||||
|
||||
rendition.display("chapter_008.xhtml");
|
||||
|
||||
|
||||
var next = document.getElementById("next");
|
||||
next.addEventListener("click", function(e){
|
||||
rendition.next();
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
|
||||
var prev = document.getElementById("prev");
|
||||
prev.addEventListener("click", function(e){
|
||||
rendition.prev();
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
|
||||
|
||||
|
||||
rendition.on("rendered", function(section){
|
||||
var nextSection = section.next();
|
||||
var prevSection = section.prev();
|
||||
|
||||
if(nextSection) {
|
||||
nextNav = book.navigation.get(nextSection.href);
|
||||
|
||||
if(nextNav) {
|
||||
nextLabel = nextNav.label;
|
||||
} else {
|
||||
nextLabel = "next";
|
||||
}
|
||||
|
||||
next.textContent = nextLabel + " »";
|
||||
} else {
|
||||
next.textContent = "";
|
||||
}
|
||||
|
||||
if(prevSection) {
|
||||
prevNav = book.navigation.get(prevSection.href);
|
||||
|
||||
if(prevNav) {
|
||||
prevLabel = prevNav.label;
|
||||
} else {
|
||||
prevLabel = "previous";
|
||||
}
|
||||
|
||||
prev.textContent = "« " + prevLabel;
|
||||
} else {
|
||||
prev.textContent = "";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue