Skip to content
This repository has been archived by the owner on May 14, 2023. It is now read-only.

Commit

Permalink
Expands the scope of top-level candidates to includes headings 4, 5, …
Browse files Browse the repository at this point in the history
…and 6
  • Loading branch information
dylon committed Jun 29, 2016
1 parent 0eca26a commit 3d2a2d4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_site/
node_modules/
Gemfile.lock
*.sw?
8 changes: 3 additions & 5 deletions bootstrap-toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,14 @@

// Find the first heading level (`<h1>`, then `<h2>`, etc.) that has more than one element. Defaults to 1 (for `<h1>`).
getTopLevel: function($scope) {
var topLevel;
for (var i = 1; i < 4; i++) {
for (var i = 1; i <= 6; i++) {
var $headings = this.findOrFilter($scope, 'h' + i);
if ($headings.length > 1) {
topLevel = i;
break;
return i;
}
}

return topLevel || 1;
return 1;
},

// returns the elements for the top level, and the next below it
Expand Down
2 changes: 1 addition & 1 deletion dist/bootstrap-toc.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Bootstrap Table of Contents v0.3.0 (http://afeld.github.io/bootstrap-toc/)
* Bootstrap Table of Contents v0.4.0 (http://afeld.github.io/bootstrap-toc/)
* Copyright 2015 Aidan Feldman
* Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */

Expand Down
10 changes: 4 additions & 6 deletions dist/bootstrap-toc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Bootstrap Table of Contents v0.3.0 (http://afeld.github.io/bootstrap-toc/)
* Bootstrap Table of Contents v0.4.0 (http://afeld.github.io/bootstrap-toc/)
* Copyright 2015 Aidan Feldman
* Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
(function() {
Expand Down Expand Up @@ -65,16 +65,14 @@

// Find the first heading level (`<h1>`, then `<h2>`, etc.) that has more than one element. Defaults to 1 (for `<h1>`).
getTopLevel: function($scope) {
var topLevel;
for (var i = 1; i < 4; i++) {
for (var i = 1; i <= 6; i++) {
var $headings = this.findOrFilter($scope, 'h' + i);
if ($headings.length > 1) {
topLevel = i;
break;
return i;
}
}

return topLevel || 1;
return 1;
},

// returns the elements for the top level, and the next below it
Expand Down
2 changes: 1 addition & 1 deletion dist/bootstrap-toc.min.css

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

4 changes: 2 additions & 2 deletions dist/bootstrap-toc.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-toc",
"version": "0.3.0",
"version": "0.4.0",
"private": true,
"scripts": {
"test": "gulp test"
Expand Down
7 changes: 5 additions & 2 deletions test/toc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ describe('Toc', function() {
'<h1></h1>' +
'<h2></h2>' +
'<h3></h3>' +
'<h3></h3>' +
'<h4></h4>' +
'<h5></h5>' +
'<h6></h6>' +
'<h6></h6>' +
'</div>'
);
var level = Toc.helpers.getTopLevel($scope);
expect(level).to.eql(3);
expect(level).to.eql(6);
});
});

Expand Down

0 comments on commit 3d2a2d4

Please sign in to comment.