epubjs
Version:
Render ePub documents in the browser, across many devices
113 lines (87 loc) • 3.18 kB
HTML
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Polymer custom-elements ePubJS Example</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<!-- <script src="../libs/polymer/custom-elements.min.js"></script> -->
<!-- EPUBJS Renderer -->
<script src="../build/epub.min.js"></script>
<link rel="stylesheet" href="basic.css">
<style type="text/css">
body {
overflow: auto;
background: #eee;
}
#wrapper {
width: 480px;
height: 640px;
overflow: hidden;
border: 1px solid #ccc;
margin: 50px auto;
background: #fff;
border-radius: 0 5px 5px 0;
-moz-box-shadow: 0px 5px 10px rgba(0,0,0,.1);
-webkit-box-shadow: 0px 5px 10px rgba(0,0,0,.1);
box-shadow: 0px 5px 10px rgba(0,0,0,.1);
}
epub-reader {
border: none;
padding: 40px 40px;
}
iframe {
border: none;
}
.arrow {
color: #777;
}
</style>
<script>;
var epubPrototype = Object.create(HTMLElement.prototype);
epubPrototype.readyCallback = function() {
this.create();
this.Book.renderTo(this);
};
epubPrototype.create = function() {
var src = this.getAttribute("src"),
width = this.getAttribute("width") || false,
height = this.getAttribute("height") || false,
spreads = this.getAttribute("spreads") != null ? true : false,
restore = this.getAttribute("restore") != null ? true : false;
this.Book = new EPUBJS.Book({
width: width,
height: height,
spreads : spreads,
restore : restore
});
this.Book.open(src);
};
epubPrototype.prevPage = function() {
this.Book.prevPage();
}
epubPrototype.nextPage = function() {
this.Book.nextPage();
}
document.register('epub-reader', {
prototype: epubPrototype
});
</script>
</head>
<body>
<div id="main">
<div id="prev" onclick="Book.prevPage();" class="arrow">‹</div>
<div id="wrapper">
<epub-reader id="book" src="../reader/moby-dick/" width="400" height="600" restore></epub-reader>
</div>
<div id="next" onclick="Book.nextPage();" class="arrow">›</div>
</div>
<script>
Book = document.getElementById("book");
</script>
</body>
</html>