mirror of
https://github.com/suk-ws/ph-Bookshelf.git
synced 2024-12-05 01:16:53 +08:00
实现了 Collections 和 章节 的折叠展开功能
This commit is contained in:
parent
7192f09c9a
commit
2d608b6f2d
29
assets/gitbook-fix.css
Normal file
29
assets/gitbook-fix.css
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
.fold > ul {
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition-duration: 0.5s;
|
||||
}
|
||||
|
||||
.fold.on > ul {
|
||||
max-height: unset;
|
||||
}
|
||||
|
||||
.book .book-summary ul.summary li a, .book .book-summary ul.summary li span {
|
||||
padding-left: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.book .book-summary .exc-trigger {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
top: 12px;
|
||||
}
|
||||
|
||||
.book .book-summary .on > a .exc-trigger:before {
|
||||
content: "\f078";
|
||||
}
|
||||
|
||||
.book .book-summary .exc-trigger:before {
|
||||
content: "\f054";
|
||||
}
|
@ -21,3 +21,11 @@ window.onload = function () {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
for (let node of document.getElementsByClassName("fold")) {
|
||||
node.childNodes[0].addEventListener("click", function () {
|
||||
if (node.classList.contains("on")) {
|
||||
node.classList.remove("on");
|
||||
} else node.classList.add("on");
|
||||
});
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ class SiteMeta {
|
||||
public static function getGitbookStylesheetsList (): array {
|
||||
return array(
|
||||
"/assets/gitbook/style.css",
|
||||
"/assets/gitbook-fix.css",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class BookCollection {
|
||||
|
||||
public function getHtml (): string {
|
||||
$str = "";
|
||||
if ($this->name != self::ROOT) $str .= "<li><a class='book-collection' href='#'>$this->name</a><ul class='book-collection summary'>";
|
||||
if ($this->name != self::ROOT) $str .= "<li class='book-collection fold'><a class='book-collection' href='#'>$this->name<i class='exc-trigger fa'></i></a><ul class='book-collection summary'>";
|
||||
foreach ($this->array as $node) {
|
||||
$str .= $node->getHtml();
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class Chapter {
|
||||
|
||||
public function getSummaryHtml (): string {
|
||||
$str = "";
|
||||
if ($this->parent != null) $str .= "<li class='chapter'><a class='page-chapter' href='#'>$this->name</a><ul class='page-chapter summary'>";
|
||||
if ($this->parent != null) $str .= "<li class='chapter fold'><a class='page-chapter' href='#'>$this->name<i class='exc-trigger fa'></i></a><ul class='page-chapter summary'>";
|
||||
foreach ($this->childs as $node) {
|
||||
$str .= $node->getSummaryHtml();
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class LinkCollection {
|
||||
|
||||
public function getHtml (): string {
|
||||
$str = "";
|
||||
if ($this->name != self::ROOT) $str .= "<li><a class='link-collection chapter' href='#'>$this->name</a><ul class='link-collection articles'>";
|
||||
if ($this->name != self::ROOT) $str .= "<li class='link-collection fold'><a class='link-collection chapter' href='#'>$this->name<i class='exc-trigger fa'></i></a><ul class='link-collection articles'>";
|
||||
foreach ($this->array as $node) {
|
||||
$str .= $node->getHtml();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user