1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-05 15:32:55 +02:00

added Endnotes pop up and image resizing

This commit is contained in:
Fred Chasen 2013-03-26 17:26:47 -07:00
parent d69e12dc7e
commit 7f41f00775
18 changed files with 335 additions and 25 deletions

View file

@ -0,0 +1,78 @@
FP.Hooks.register("beforeChapterDisplay").annotate = function(callback, chapter){
var chap = chapter.bodyEl,
server = 'http://127.0.0.1:5000/';
files = [
FP.filePath + "libs/jquery-1.9.0.js",
FP.filePath + "libs/jquery-migrate-1.1.1.js",
FP.filePath + "libs/annotator-full.js"
];
//FP.core.loadScripts(files, annotate, chapter.doc.head);
$(chapter.doc.body).annotator().annotator('setupPlugins', {}, {
Filter:false,
Store: {
annotationData: {
'uri': chapter.path
},
loadFromSearch: {
'limit': 100,
'uri': chapter.path
}
}
});
FP.core.addCss("css/annotator.css", false, chapter.doc.head);
if(callback) callback();
function annotate(){
FP.core.addCss("css/annotator.css", false, chapter.doc.head);
var s = document.createElement("script");
s.type = 'text/javascript';
var a = "jQuery.migrateTrace = false;";
//a += "console.log(document.getElementById('c001p0002').getBoundingClientRect());";
a += "var content = $('body').annotator().annotator('setupPlugins', {}, {Filter:false});";
//-- Use Local Server:
// a += "var content = $('body').annotator(),";
// a += " server = '" + server + "';";
// a += " path = '" + chapter.path + "';";
//
// a += " content.annotator('addPlugin', 'Store', {";
// // The endpoint of the store on your server.
// a += " prefix: server,";
//
// // Attach the uri of the current page to all annotations to allow search.
// a += " annotationData: {";
// a += " 'uri': path";
// a += " }";
// This will perform a search action rather than read when the plugin
// loads. Will request the last 20 annotations for the current url.
// eg. /store/endpoint/search?limit=20&uri=http://this/document/only
// a += ","
// a += " loadFromSearch: {";
// a += " 'limit': 20,";
// a += " 'uri': path";
// a += " }";
//a += "});";
s.innerHTML = a;
chapter.doc.body.appendChild(s);
if(callback) callback();
}
}

View file

@ -0,0 +1,68 @@
FP.Hooks.register("beforeChapterDisplay").music = function(callback, chapter){
var trans = chapter.doc.querySelectorAll('audio'),
items = Array.prototype.slice.call(trans),
playing = false;
items.forEach(function(item){
var onSpread = 0;
function getPage() {
left = item.getBoundingClientRect().left;
onSpread = Math.floor(left / chapter.spreadWidth) + 1; //-- pages start at 1
//console.log("left", left, onPage)
// width = orginal_width;
// height = orginal_height;
//
// if(width > chapter.colWidth){
// ratio = chapter.colWidth / width;
//
// width = chapter.colWidth;
// height = height * ratio;
// }
//
// iframe.width = width;
// iframe.height = height;
}
function shouldPlay(e) {
page = 1;
if(e) page = e.msg;
if(page != onSpread) return;
if(playing) playing.pause();
item.play();
playing = item;
console.log("start", item.src)
}
//-- resize event
chapter.book.listenUntil("book:resized", "book:chapterDestroy", getPage);
chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", shouldPlay);
item.removeAttribute("controls");
getPage();
shouldPlay();
});
if(callback) callback();
}