diff --git a/dist/bootstrap-toc.js b/dist/bootstrap-toc.js
index 2ce99ad..546688d 100644
--- a/dist/bootstrap-toc.js
+++ b/dist/bootstrap-toc.js
@@ -93,16 +93,17 @@
return this.generateNavEl(anchor, text);
},
- // Find the first heading level (`
`, then ``, etc.) that has more than one element. Defaults to 1 (for ``).
+ // Find the first heading level (``, then ``, etc.) that has more than one element. Defaults to 2 (for ``).
+ // Don't display h1 in the toc and allow displaying only one element.
getTopLevel: function($scope) {
- for (var i = 1; i <= 6; i++) {
+ for (var i = 2; i <= 6; i++) {
var $headings = this.findOrFilter($scope, "h" + i);
- if ($headings.length > 1) {
+ if ($headings.length >= 1) {
return i;
}
}
- return 1;
+ return 2;
},
// returns the elements for the top level, and the next below it
diff --git a/dist/bootstrap-toc.min.js b/dist/bootstrap-toc.min.js
index c628326..c5af8b1 100644
--- a/dist/bootstrap-toc.min.js
+++ b/dist/bootstrap-toc.min.js
@@ -2,4 +2,4 @@
* Bootstrap Table of Contents v1.0.1 (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(a){"use strict";window.Toc={helpers:{findOrFilter:function(e,t){var n=e.find(t);return e.filter(t).add(n).filter(":not([data-toc-skip])")},generateUniqueIdBase:function(e){return a(e).text().trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase()||e.tagName.toLowerCase()},generateUniqueId:function(e){for(var t=this.generateUniqueIdBase(e),n=0;;n++){var r=t;if(0')},createChildNavList:function(e){var t=this.createNavList();return e.append(t),t},generateNavEl:function(e,t){var n=a('');n.attr("href","#"+e),n.text(t);var r=a("");return r.append(n),r},generateNavItem:function(e){var t=this.generateAnchor(e),n=a(e),r=n.data("toc-text")||n.text();return this.generateNavEl(t,r)},getTopLevel:function(e){for(var t=1;t<=6;t++){if(1\]\.\/\(\)\*\\\n\t\b\v]/g,urlText;urlText=text.trim().replace(/\'/gi,"").replace(nonsafeChars,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase();return urlText||el.tagName.toLowerCase()},generateUniqueId:function(el){var anchorBase=this.generateUniqueIdBase(el);for(var i=0;;i++){var anchor=anchorBase;if(i>0){anchor+="-"+i}if(!document.getElementById(anchor)){return anchor}}},generateAnchor:function(el){if(el.id){return el.id}else{var anchor=this.generateUniqueId(el);el.id=anchor;return anchor}},createNavList:function(){return $('')},createChildNavList:function($parent){var $childList=this.createNavList();$parent.append($childList);return $childList},generateNavEl:function(anchor,text){var $a=$('');$a.attr("href","#"+anchor);$a.text(text);var $li=$("");$li.append($a);return $li},generateNavItem:function(headingEl){var anchor=this.generateAnchor(headingEl);var $heading=$(headingEl);var text=$heading.data("toc-text")||$heading.text();return this.generateNavEl(anchor,text)},getTopLevel:function($scope){for(var i=2;i<=6;i++){var $headings=this.findOrFilter($scope,"h"+i);if($headings.length>=1){return i}}return 2},getHeadings:function($scope,topLevel){var topSelector="h"+topLevel;var secondaryLevel=topLevel+1;var secondarySelector="h"+secondaryLevel;return this.findOrFilter($scope,topSelector+","+secondarySelector)},getNavLevel:function(el){return parseInt(el.tagName.charAt(1),10)},populateNav:function($topContext,topLevel,$headings){var $context=$topContext;var $prevNav;var helpers=this;$headings.each(function(i,el){var $newNav=helpers.generateNavItem(el);var navLevel=helpers.getNavLevel(el);if(navLevel===topLevel){$context=$topContext}else if($prevNav&&$context===$topContext){$context=helpers.createChildNavList($prevNav)}$context.append($newNav);$prevNav=$newNav})},parseOps:function(arg){var opts;if(arg.jquery){opts={$nav:arg}}else{opts=arg}opts.$scope=opts.$scope||$(document.body);return opts}},init:function(opts){opts=this.helpers.parseOps(opts);opts.$nav.attr("data-toggle","toc");var $topContext=this.helpers.createChildNavList(opts.$nav);var topLevel=this.helpers.getTopLevel(opts.$scope);var $headings=this.helpers.getHeadings(opts.$scope,topLevel);this.helpers.populateNav($topContext,topLevel,$headings)}};$(function(){$('nav[data-toggle="toc"]').each(function(i,el){var $nav=$(el);Toc.init($nav)})})})(jQuery);