Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions src/javascripts/jquery.tocify.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@

// **highlightDefault**: Accepts a boolean: true or false
// Set's the first TOC item as active if no other TOC item is active.
highlightDefault: true
highlightDefault: true,

// **highlightSubheader**: Accepts a boolean: true or false
// Set's the subheader of the active TOC item as active.
highlightSubheader: true
},

// _Create
Expand Down Expand Up @@ -318,6 +321,11 @@
// Highlights the current list item that was clicked
elem.addClass(self.focusClass);

// If the `highlightSubheader` option is true
if(self.options.highlightSubheader) {
self._highlightSubheader(elem);
}

// If the showAndHide option is true
if(self.options.showAndHide) {

Expand Down Expand Up @@ -501,7 +509,7 @@

},

// _setEventHandlers
// _setEventHandlers
// ----------------
// Adds jQuery event handlers to the newly generated table of contents
_setEventHandlers: function() {
Expand Down Expand Up @@ -530,7 +538,12 @@
self.element.find("." + self.focusClass).removeClass(self.focusClass);

// Highlights the current list item that was clicked
$(this).addClass(self.focusClass);
var elem = $(this).addClass(self.focusClass);

// If the `highlightSubheader` option is true
if(self.options.highlightSubheader) {
self._highlightSubheader(elem);
}

// If the showAndHide option is true
if(self.options.showAndHide) {
Expand Down Expand Up @@ -683,6 +696,11 @@
// Highlights the corresponding list item
elem.addClass(self.focusClass);

// If the `highlightSubheader` option is true
if(self.options.highlightSubheader) {
self._highlightSubheader(elem);
}

}

if(self.options.scrollHistory) {
Expand Down Expand Up @@ -980,6 +998,23 @@
// Maintains chainability
return self;

},

// _highlightSubheader
// ---------
// Highlights the subheader of the active element
_highlightSubheader: function($elem) {

var self = this,
$subheader = $elem.parent(subheaderClass);

if(!!$subheader.length) {
$subheader.siblings(itemClass).addClass(this.focusClass);
}

// Maintains chainability
return self;

}

});
Expand Down
6 changes: 3 additions & 3 deletions src/javascripts/jquery.tocify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.