From 2d608b6f2d56159c5bfa0dfc23dfe96ccdba53a2 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Wed, 28 Apr 2021 14:11:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=86=20Collections=20?= =?UTF-8?q?=E5=92=8C=20=E7=AB=A0=E8=8A=82=20=E7=9A=84=E6=8A=98=E5=8F=A0?= =?UTF-8?q?=E5=B1=95=E5=BC=80=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/gitbook-fix.css | 29 +++++++++++++++++++++++++++++ assets/gitbook-fix.js | 8 ++++++++ src/Data/SiteMeta.php | 1 + src/Element/BookCollection.php | 2 +- src/Element/BookContent/Chapter.php | 2 +- src/Element/LinkCollection.php | 2 +- 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 assets/gitbook-fix.css diff --git a/assets/gitbook-fix.css b/assets/gitbook-fix.css new file mode 100644 index 0000000..2fbfbf1 --- /dev/null +++ b/assets/gitbook-fix.css @@ -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"; +} diff --git a/assets/gitbook-fix.js b/assets/gitbook-fix.js index b64674b..860e492 100644 --- a/assets/gitbook-fix.js +++ b/assets/gitbook-fix.js @@ -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"); + }); +} diff --git a/src/Data/SiteMeta.php b/src/Data/SiteMeta.php index ca01ecb..8e498be 100644 --- a/src/Data/SiteMeta.php +++ b/src/Data/SiteMeta.php @@ -24,6 +24,7 @@ class SiteMeta { public static function getGitbookStylesheetsList (): array { return array( "/assets/gitbook/style.css", + "/assets/gitbook-fix.css", ); } diff --git a/src/Element/BookCollection.php b/src/Element/BookCollection.php index 7c3a2be..774487e 100644 --- a/src/Element/BookCollection.php +++ b/src/Element/BookCollection.php @@ -72,7 +72,7 @@ class BookCollection { public function getHtml (): string { $str = ""; - if ($this->name != self::ROOT) $str .= "
  • $this->name