1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

add cover to toc

This commit is contained in:
Fred Chasen 2013-01-23 11:54:36 -08:00
parent 65fbc6d034
commit 78e1c05ab0
5 changed files with 27 additions and 12 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -193,6 +193,7 @@ input:-moz-placeholder {
width: 225px;
font-family: Georgia, "Times New Roman", Times, serif;
list-style: none;
text-transform: capitalize;
}
#toc li:active,

View file

@ -146,7 +146,9 @@ FP.app.init = (function($){
$open.on("click", function(){
if($sidebar.hasClass("open")){
$sidebar.removeClass("open");
setTimeout(function(){
$sidebar.removeClass("open");
}, 500);
$main.removeClass("closed");
$icon.attr("src", "img/menu-icon.png");
}else{

View file

@ -285,23 +285,33 @@ FP.Book.prototype.parseTOC = function(path){
this.toc = [];
FP.core.loadXML(url, function(contents){
var navMap = contents.getElementsByTagName("navMap")[0];
var navMap = contents.querySelector("navMap"),
cover = contents.querySelector("meta[name='cover']"),
coverID;
//-- Add cover
if(cover){
coverID = cover.getAttribute("content");
that.toc.push({
"id": coverID,
"href": that.assets[coverID],
"label": coverID,
"spinePos": parseInt(that.spineIndex[coverID])
});
}
function getTOC(nodes, parent){
var list = [];
//-- Turn items into an array
items = Array.prototype.slice.call(nodes);
items.forEach(function(item){
var id = item.getAttribute('id'),
href = that.assets[id],
navLabel = item.getElementsByTagName("navLabel")[0], //-- TODO: replace with query
navLabel = item.querySelector("navLabel"),
text = navLabel.textContent ? navLabel.textContent : "",
subitems = item.getElementsByTagName("navPoint") || false,
subitems = item.querySelectorAll("navPoint") || false,
subs = false,
childof = (item.parentNode == parent);
@ -324,8 +334,10 @@ FP.Book.prototype.parseTOC = function(path){
return list;
}
that.toc = getTOC(navMap.getElementsByTagName("navPoint"), navMap);
that.toc = that.toc.concat( getTOC(navMap.querySelectorAll("navPoint"), navMap) );
localStorage.setItem("toc", JSON.stringify(that.toc));

View file

@ -42,7 +42,7 @@ FP.Chapter.prototype.setIframeSrc = function(url){
//that.bodyEl = that.iframe.contentDocument.documentElement.getElementsByTagName('body')[0];
//that.bodyEl = that.iframe.contentDocument.querySelector('body, html');
that.bodyEl = that.book.bodyEl = that.iframe.contentDocument.body;
//-- TODO: Choose between single and spread
that.formatSpread();