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")){
setTimeout(function(){
$sidebar.removeClass("open");
}, 500);
$main.removeClass("closed");
$icon.attr("src", "img/menu-icon.png");
}else{

View file

@ -285,10 +285,20 @@ 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 = [];
@ -299,9 +309,9 @@ FP.Book.prototype.parseTOC = function(path){
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);
@ -325,7 +335,9 @@ 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));