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:
parent
65fbc6d034
commit
78e1c05ab0
5 changed files with 27 additions and 12 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
|
@ -193,6 +193,7 @@ input:-moz-placeholder {
|
||||||
width: 225px;
|
width: 225px;
|
||||||
font-family: Georgia, "Times New Roman", Times, serif;
|
font-family: Georgia, "Times New Roman", Times, serif;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#toc li:active,
|
#toc li:active,
|
||||||
|
|
|
@ -146,7 +146,9 @@ FP.app.init = (function($){
|
||||||
|
|
||||||
$open.on("click", function(){
|
$open.on("click", function(){
|
||||||
if($sidebar.hasClass("open")){
|
if($sidebar.hasClass("open")){
|
||||||
|
setTimeout(function(){
|
||||||
$sidebar.removeClass("open");
|
$sidebar.removeClass("open");
|
||||||
|
}, 500);
|
||||||
$main.removeClass("closed");
|
$main.removeClass("closed");
|
||||||
$icon.attr("src", "img/menu-icon.png");
|
$icon.attr("src", "img/menu-icon.png");
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -285,10 +285,20 @@ FP.Book.prototype.parseTOC = function(path){
|
||||||
this.toc = [];
|
this.toc = [];
|
||||||
|
|
||||||
FP.core.loadXML(url, function(contents){
|
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){
|
function getTOC(nodes, parent){
|
||||||
var list = [];
|
var list = [];
|
||||||
|
@ -299,9 +309,9 @@ FP.Book.prototype.parseTOC = function(path){
|
||||||
items.forEach(function(item){
|
items.forEach(function(item){
|
||||||
var id = item.getAttribute('id'),
|
var id = item.getAttribute('id'),
|
||||||
href = that.assets[id],
|
href = that.assets[id],
|
||||||
navLabel = item.getElementsByTagName("navLabel")[0], //-- TODO: replace with query
|
navLabel = item.querySelector("navLabel"),
|
||||||
text = navLabel.textContent ? navLabel.textContent : "",
|
text = navLabel.textContent ? navLabel.textContent : "",
|
||||||
subitems = item.getElementsByTagName("navPoint") || false,
|
subitems = item.querySelectorAll("navPoint") || false,
|
||||||
subs = false,
|
subs = false,
|
||||||
childof = (item.parentNode == parent);
|
childof = (item.parentNode == parent);
|
||||||
|
|
||||||
|
@ -325,7 +335,9 @@ FP.Book.prototype.parseTOC = function(path){
|
||||||
return list;
|
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));
|
localStorage.setItem("toc", JSON.stringify(that.toc));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue