mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Backbone example clean up
This commit is contained in:
parent
a2a179d98b
commit
2639fbd273
1 changed files with 33 additions and 48 deletions
|
@ -30,12 +30,11 @@
|
||||||
</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="test-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>
|
||||||
|
@ -104,70 +103,56 @@
|
||||||
BB.Views = {};
|
BB.Views = {};
|
||||||
|
|
||||||
EPUBJS.Hooks.register("beforeChapterDisplay").transculsions = function(callback, renderer){
|
EPUBJS.Hooks.register("beforeChapterDisplay").transculsions = function(callback, renderer){
|
||||||
console.log('test');
|
$(renderer.element).contents().find('body').bind('mouseup', function(){
|
||||||
|
|
||||||
|
var selection = $('iframe').contents()[0].getSelection().toString();
|
||||||
|
debugger;
|
||||||
|
});
|
||||||
callback();
|
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({
|
||||||
|
|
||||||
el: '#main',
|
el: '#main',
|
||||||
|
|
||||||
book: ePub("/reader/moby-dick.epub", { restore: true }),
|
model: Library,
|
||||||
|
|
||||||
model: Library,
|
book: null,
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click #next': 'nextPage',
|
'click #next': 'nextPage',
|
||||||
'click #prev': 'previousPage'
|
'click #prev': 'previousPage'
|
||||||
},
|
},
|
||||||
|
|
||||||
template: _.template( $('#abcdef').html() ),
|
template: _.template( $('#test-template').html() ),
|
||||||
|
|
||||||
initialize: function() {
|
//eventually pass book url as a param to initialize
|
||||||
this.area = $('<div></div>');
|
initialize: function() {
|
||||||
|
this.area = $('<div style="height:100%;"></div>');
|
||||||
|
|
||||||
this.book.renderTo(this.area[0]).then(function(){
|
this.book = ePub("/reader/moby-dick.epub", { restore: true });
|
||||||
// view.bindIframe();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
this.book.renderTo(this.area[0]);
|
||||||
|
},
|
||||||
|
|
||||||
},
|
render: function() {
|
||||||
|
this.$el.html(this.template());
|
||||||
render: function(done) {
|
|
||||||
var view = this;
|
|
||||||
|
|
||||||
this.$el.html(this.template());
|
this.$('#area').html(this.area);
|
||||||
|
|
||||||
this.$('#area').html(this.area);
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
this.bindIframe();
|
nextPage: function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
this.book.nextPage();
|
||||||
|
},
|
||||||
|
|
||||||
return this;
|
previousPage: function(e){
|
||||||
},
|
e.preventDefault();
|
||||||
|
this.book.prevPage();
|
||||||
bindIframe: function(){
|
}
|
||||||
$('#area iframe').contents().find('body').bind('mouseup', function(){
|
|
||||||
|
|
||||||
var selection = $('iframe').contents()[0].getSelection().toString();
|
|
||||||
debugger;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
nextPage: function(e){
|
|
||||||
var view = this;
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
this.book.nextPage().then(function(){
|
|
||||||
// view.bindIframe();
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
previousPage: function(e){
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
this.book.prevPage()
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var view = new BB.Views.Details();
|
var view = new BB.Views.Details();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue