mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Working backbone example
This commit is contained in:
parent
a2a179d98b
commit
28288dd121
1 changed files with 5 additions and 73 deletions
|
@ -18,68 +18,20 @@
|
||||||
|
|
||||||
<!-- EPUBJS Renderer -->
|
<!-- EPUBJS Renderer -->
|
||||||
<script src="/build/epub.min.js"></script>
|
<script src="/build/epub.min.js"></script>
|
||||||
<!--<script src="/build/hooks.js"></script>-->
|
|
||||||
|
|
||||||
<script>
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//var Book = ePub("/reader/moby-dick/", { restore: true });
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
|
|
||||||
<div id="loader"><img src="../reader/img/loader.gif"></div>
|
<div id="loader"><img src="../reader/img/loader.gif"></div>
|
||||||
<select id="toc"></select>
|
<select id="toc"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/template" id="abcdef">
|
<script type="text/template" id="template">
|
||||||
<div id="prev" class="arrow">‹</div>
|
<div id="prev" class="arrow">‹</div>
|
||||||
<div id="area"></div>
|
<div id="area"></div>
|
||||||
<div id="next" class="arrow">›</div>
|
<div id="next" class="arrow">›</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
// Book.getMetadata().then(function(meta){
|
|
||||||
|
|
||||||
// document.title = meta.bookTitle+" – "+meta.creator;
|
|
||||||
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Book.getToc().then(function(toc){
|
|
||||||
|
|
||||||
// var $select = document.getElementById("toc"),
|
|
||||||
// docfrag = document.createDocumentFragment();
|
|
||||||
|
|
||||||
// toc.forEach(function(chapter) {
|
|
||||||
// var option = document.createElement("option");
|
|
||||||
// option.textContent = chapter.label;
|
|
||||||
// option.ref = chapter.href;
|
|
||||||
|
|
||||||
// docfrag.appendChild(option);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// $select.appendChild(docfrag);
|
|
||||||
|
|
||||||
// $select.onchange = function(){
|
|
||||||
// var index = $select.selectedIndex,
|
|
||||||
// url = $select.options[index].ref;
|
|
||||||
|
|
||||||
// Book.goto(url);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Book.ready.all.then(function(){
|
|
||||||
// document.getElementById("loader").style.display = "none";
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Book.renderTo("area");
|
|
||||||
|
|
||||||
var BB = {};
|
var BB = {};
|
||||||
|
|
||||||
var Library = new Backbone.Model();
|
var Library = new Backbone.Model();
|
||||||
|
@ -103,11 +55,6 @@
|
||||||
|
|
||||||
BB.Views = {};
|
BB.Views = {};
|
||||||
|
|
||||||
EPUBJS.Hooks.register("beforeChapterDisplay").transculsions = function(callback, renderer){
|
|
||||||
console.log('test');
|
|
||||||
callback();
|
|
||||||
};
|
|
||||||
|
|
||||||
// This will fetch the book template and render it.
|
// This will fetch the book template and render it.
|
||||||
BB.Views.Details = Backbone.View.extend({
|
BB.Views.Details = Backbone.View.extend({
|
||||||
|
|
||||||
|
@ -122,16 +69,12 @@
|
||||||
'click #prev': 'previousPage'
|
'click #prev': 'previousPage'
|
||||||
},
|
},
|
||||||
|
|
||||||
template: _.template( $('#abcdef').html() ),
|
template: _.template( $('#template').html() ),
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.area = $('<div></div>');
|
this.area = $('<div></div>');
|
||||||
|
|
||||||
this.book.renderTo(this.area[0]).then(function(){
|
this.book.renderTo(this.area[0]);
|
||||||
// view.bindIframe();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function(done) {
|
render: function(done) {
|
||||||
|
@ -146,21 +89,10 @@
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
bindIframe: function(){
|
|
||||||
$('#area iframe').contents().find('body').bind('mouseup', function(){
|
|
||||||
|
|
||||||
var selection = $('iframe').contents()[0].getSelection().toString();
|
|
||||||
debugger;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
nextPage: function(e){
|
nextPage: function(e){
|
||||||
var view = this;
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
this.book.nextPage().then(function(){
|
this.book.nextPage();
|
||||||
// view.bindIframe();
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
previousPage: function(e){
|
previousPage: function(e){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue