-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the unused chapter-fold, add expandable-chapter plugin.
Resolves #112. Signed-off-by: Tao He <[email protected]>
- Loading branch information
1 parent
c00e400
commit 703c478
Showing
8 changed files
with
309 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
assets/gitbook/gitbook-plugin-chapter-fold/chapter-fold.js
This file was deleted.
Oops, something went wrong.
67 changes: 39 additions & 28 deletions
67
...book-plugin-chapter-fold/chapter-fold.css → ...ters-small2/expandable-chapters-small.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
.book .book-summary .chapter > .articles { | ||
overflow: hidden; | ||
max-height: 0px; | ||
} | ||
|
||
.book .book-summary .chapter.expanded > .articles { | ||
max-height: 9999px; | ||
} | ||
|
||
.book .book-summary .exc-trigger { | ||
position: absolute; | ||
left: 12px; | ||
top: 12px; | ||
} | ||
|
||
.book .book-summary ul.summary li a, | ||
.book .book-summary ul.summary li span { | ||
padding-left: 30px; | ||
} | ||
|
||
.book .book-summary .exc-trigger:before { | ||
content: "\f105"; | ||
} | ||
|
||
.book .book-summary .expanded > a .exc-trigger:before, | ||
.book .book-summary .expanded > span .exc-trigger:before { | ||
content: "\f107"; | ||
} | ||
/* .book .book-summary .chapter > .articles { */ | ||
.book .book-summary .chapter ul { | ||
overflow: hidden; | ||
max-height: 0px; | ||
} | ||
|
||
.book .book-summary .chapter li ul { | ||
overflow: hidden; | ||
max-height: 0px !important; | ||
} | ||
|
||
/* .book .book-summary .chapter.expanded > .articles { */ | ||
.book .book-summary .chapter.expanded ul { | ||
max-height: 9999px; | ||
} | ||
|
||
.book .book-summary .chapter.expanded li.expanded ul { | ||
max-height: 9999px !important; | ||
} | ||
|
||
.book .book-summary .exc-trigger { | ||
position: absolute; | ||
left: 12px; | ||
top: 12px; | ||
} | ||
|
||
.book .book-summary ul.summary li a, | ||
.book .book-summary ul.summary li span { | ||
padding-left: 30px; | ||
} | ||
|
||
.book .book-summary .exc-trigger:before { | ||
content: "\f105"; | ||
} | ||
|
||
.book .book-summary .expanded > a .exc-trigger:before, | ||
.book .book-summary .expanded > span .exc-trigger:before { | ||
content: "\f107"; | ||
} |
102 changes: 102 additions & 0 deletions
102
assets/gitbook/gitbook-plugin-expandable-chapters-small2/expandable-chapters-small.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
require(['gitbook', 'jQuery'], function (gitbook, $) { | ||
var PLUGIN = 'expandable-chapter-small2', | ||
TOGGLE_CLASSNAME = 'expanded', | ||
CHAPTER = '.chapter', | ||
// ARTICLES = '.articles', | ||
ARTICLES = '.chapter ul', | ||
FOLDABLE = '.chapter, .chapter li', | ||
ARTICLE_CHILDREN = 'ul', | ||
TRIGGER_TEMPLATE = '<i class="exc-trigger fa"></i>', | ||
LS_NAMESPACE = 'expChapters'; | ||
|
||
var init = function () { | ||
// adding the trigger element to each ARTICLES parent and binding the event | ||
var config = gitbook.state.config.pluginsConfig || {}; | ||
var articlesExpand = false; | ||
if (config && config[PLUGIN]) { | ||
articlesExpand = config[PLUGIN].articlesExpand || false; | ||
} | ||
if (articlesExpand) { | ||
$(ARTICLES) | ||
.parent(CHAPTER) | ||
.find(ARTICLE_CHILDREN) | ||
.prev() | ||
.css('cursor', 'pointer') | ||
.on('click', function (e) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
toggle($(e.target).closest(FOLDABLE)); | ||
}) | ||
.append(TRIGGER_TEMPLATE); | ||
} else { | ||
$(ARTICLES) | ||
.parent(CHAPTER) | ||
.find(ARTICLE_CHILDREN) | ||
.prev() | ||
.append( | ||
$(TRIGGER_TEMPLATE) | ||
.on('click', function (e) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
toggle($(e.target).closest(FOLDABLE)); | ||
}) | ||
); | ||
} | ||
expand(lsItem()); | ||
|
||
// expand current selected chapter with it's parents | ||
var activeChapter = $(CHAPTER + '.active'); | ||
expand(activeChapter); | ||
|
||
// expand current selected chapter's children | ||
// expand(activeChapter.parents(CHAPTER)); | ||
activeChapter.find(ARTICLE_CHILDREN).closest(FOLDABLE).each(function () { | ||
expand($(this)); | ||
}); | ||
} | ||
|
||
var toggle = function ($chapter) { | ||
if ($chapter.hasClass('expanded')) { | ||
collapse($chapter); | ||
} else { | ||
expand($chapter); | ||
} | ||
} | ||
|
||
var collapse = function ($chapter) { | ||
if ($chapter.length && $chapter.hasClass(TOGGLE_CLASSNAME)) { | ||
$chapter.removeClass(TOGGLE_CLASSNAME); | ||
lsItem($chapter); | ||
} | ||
} | ||
|
||
var expand = function ($chapter) { | ||
if ($chapter.length && !$chapter.hasClass(TOGGLE_CLASSNAME)) { | ||
$chapter.addClass(TOGGLE_CLASSNAME); | ||
lsItem($chapter); | ||
} | ||
} | ||
|
||
var lsItem = function () { | ||
var map = JSON.parse(localStorage.getItem(LS_NAMESPACE)) || {} | ||
if (arguments.length) { | ||
var $chapters = arguments[0]; | ||
$chapters.each(function (index, element) { | ||
var level = $(this).data('level'); | ||
var value = $(this).hasClass(TOGGLE_CLASSNAME); | ||
map[level] = value; | ||
}) | ||
localStorage.setItem(LS_NAMESPACE, JSON.stringify(map)); | ||
} else { | ||
return $(CHAPTER).map(function (index, element) { | ||
if (map[$(this).data('level')]) { | ||
return this; | ||
} | ||
}) | ||
} | ||
} | ||
|
||
gitbook.events.bind('page.change', function () { | ||
init() | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.divider-content-summary { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
height: 100%; | ||
width: 5px; | ||
display: table; | ||
cursor: col-resize; | ||
color: #ccc; | ||
-webkit-transition: color 350ms ease; | ||
-moz-transition: color 350ms ease; | ||
-o-transition: color 350ms ease; | ||
transition: color 350ms ease | ||
} | ||
|
||
.divider-content-summary:hover { | ||
color: #444; | ||
} | ||
|
||
.divider-content-summary__icon { | ||
display: table-cell; | ||
vertical-align: middle; | ||
text-align: center; | ||
} |
Oops, something went wrong.