mirror of
https://github.com/kata0510/Lily58.git
synced 2025-04-29 02:02:59 +00:00
21 lines
573 B
JavaScript
21 lines
573 B
JavaScript
require(['gitbook', 'jQuery'], function(gitbook, $) {
|
|
var EXPANDED_CLASSNAME = 'expanded',
|
|
CHAPTER = '.chapter';
|
|
var init = function () {
|
|
collapseAll();
|
|
expandUntil($(CHAPTER + '.active'));
|
|
};
|
|
|
|
var collapseAll = function(){
|
|
$(CHAPTER + '.' + EXPANDED_CLASSNAME).removeClass(EXPANDED_CLASSNAME);
|
|
};
|
|
|
|
var expandUntil = function($chapter){
|
|
var $chapters_to_expand = $chapter.parents(CHAPTER).add($chapter);
|
|
$chapters_to_expand.addClass(EXPANDED_CLASSNAME);
|
|
};
|
|
|
|
gitbook.events.bind('page.change', function() {
|
|
init();
|
|
});
|
|
});
|