mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
adjust sizing of table of contents to better display nested items, fix bug with display of final item in list
This commit is contained in:
parent
4c5235162e
commit
44b7b35ba0
2 changed files with 28 additions and 9 deletions
20
css/main.css
20
css/main.css
|
@ -208,12 +208,12 @@ input:-moz-placeholder {
|
|||
#toc > ul{
|
||||
margin-top: 50px;
|
||||
margin-bottom: 50px;
|
||||
padding-left: 40px;
|
||||
padding-left: 20px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#toc li {
|
||||
margin-bottom: 10px;
|
||||
margin-bottom:10px;
|
||||
width: 225px;
|
||||
font-family: Georgia, "Times New Roman", Times, serif;
|
||||
list-style: none;
|
||||
|
@ -231,12 +231,27 @@ input:-moz-placeholder {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
#toc a.chapter {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
#toc a.section {
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
#toc li.currentChapter > a,
|
||||
#toc li a:hover {
|
||||
color: #f1f1f1
|
||||
}
|
||||
|
||||
#toc li.openChapter > a,
|
||||
#toc li a:hover {
|
||||
color: #E2E2E2;
|
||||
}
|
||||
|
||||
#toc li ul {
|
||||
padding-left:10px;
|
||||
margin-top: 8px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
@ -332,6 +347,7 @@ input:-moz-placeholder {
|
|||
|
||||
#toc > ul{
|
||||
padding-left: 10px;
|
||||
webkit-padding-start:;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ FPR.app.init = (function($){
|
|||
$toc.empty();
|
||||
|
||||
//-- Recursively generate TOC levels
|
||||
$items = generateTocItems(contents);
|
||||
$items = generateTocItems(contents, 1);
|
||||
|
||||
$toc.append($items);
|
||||
|
||||
|
@ -83,8 +83,10 @@ FPR.app.init = (function($){
|
|||
var $this = $(this),
|
||||
url = $this.data("url");
|
||||
|
||||
$(".openChapter").removeClass("openChapter");
|
||||
$this.parent().addClass("openChapter");
|
||||
|
||||
$(".openChapter").removeClass("openChapter");
|
||||
$this.parents('li').addClass("openChapter");
|
||||
|
||||
|
||||
//-- Provide the Book with the url to show
|
||||
// The Url must be found in the books manifest
|
||||
|
@ -98,19 +100,20 @@ FPR.app.init = (function($){
|
|||
|
||||
}
|
||||
|
||||
function generateTocItems(contents){
|
||||
function generateTocItems(contents, level){
|
||||
var $container = $("<ul>");
|
||||
|
||||
var type = (level == 1) ? "chapter" : "section";
|
||||
|
||||
contents.forEach(function(item){
|
||||
var $subitems,
|
||||
$wrapper = $("<li id='toc-"+item.id+"'>"),
|
||||
$item = $("<a class='toc_link' href='#/"+item.href+"' data-url='"+item.href+"'>"+item.label+"</a>");
|
||||
$item = $("<a class='toc_link " + type + "' href='#/"+item.href+"' data-url='"+item.href+"'>"+item.label+"</a>");
|
||||
|
||||
$wrapper.append($item);
|
||||
|
||||
if(item.subitems && item.subitems.length){
|
||||
$subitems = generateTocItems(item.subitems);
|
||||
level++;
|
||||
$subitems = generateTocItems(item.subitems, level);
|
||||
$wrapper.append($subitems);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue