Skip to content
Merged
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
9 changes: 8 additions & 1 deletion demos/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ <h3>Options</h3>
<td>"body"</td>
<td>Any valid jQuery selector</td>
</tr>
<tr>
<td class="optionName" title="ignoreSelector" data-content="A selector to any element that would be matched by selectors that you wish to be ignored"><a href="#">ignoreSelector</a></td>
<td>String</td>
<td>null</td>
<td>Any valid jQuery selector</td>
</tr>
<tr>
<td class="optionName" title="selectors" data-content="The element's used to generate the table of contents. The order is very important since it will determine the table of content's nesting structure."><a href="#">selectors</a></td>
<td>String</td>
<td>"h1,h2,h3"</td>
Expand Down Expand Up @@ -438,4 +445,4 @@ <h2>Donation</h2>
</script>

</body>
</html>
</html>
24 changes: 23 additions & 1 deletion src/javascripts/jquery.tocify.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
// The container element that holds all of the elements used to generate the table of contents
context: "body",

// **ignoreSelector**: Accepts String: Any jQuery selector
// A selector to any element that would be matched by selectors that you wish to be ignored
ignoreSelector: null,

// **selectors**: Accepts an Array of Strings: Any jQuery selectors
// The element's used to generate the table of contents. The order is very important since it will determine the table of content's nesting structure
selectors: "h1, h2, h3",
Expand Down Expand Up @@ -208,6 +212,12 @@
// Loops through each top level selector
firstElem.each(function(index) {

//If the element matches the ignoreSelector then we skip it
if($(this).is(self.options.ignoreSelector))
{
return;
}

// Creates an unordered list HTML element and adds a dynamic ID and standard class name
ul = $("<ul/>", {
"id": "Header" + index,
Expand All @@ -229,6 +239,12 @@
// Loops through all of the subheader elements
$(this).filter(self.options.selectors).each(function() {

//If the element matches the ignoreSelector then we skip it
if($(this).is(self.options.ignoreSelector))
{
return;
}

self._appendSubheaders.call(this, self, ul);

});
Expand All @@ -241,6 +257,12 @@
// Loops through all of the subheader elements
$(this).find(self.options.selectors).each(function() {

//If the element matches the ignoreSelector then we skip it
if($(this).is(self.options.ignoreSelector))
{
return;
}

self._appendSubheaders.call(this, self, ul);

});
Expand Down Expand Up @@ -911,4 +933,4 @@

});

})); //end of plugin
})); //end of plugin