1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00
epub.js/examples/custom-elements.html

112 lines
3.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE 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>
"use strict";
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>