diff --git a/_layouts/default.html b/_layouts/default.html index ab5a8b5ea..fc6003260 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -5,7 +5,7 @@ {% include header.html %} -
+ {% include nav-main.html %} diff --git a/assets/js/application.js b/assets/js/application.js index 0435726c9..99ba1413d 100644 --- a/assets/js/application.js +++ b/assets/js/application.js @@ -8,11 +8,28 @@ var $window = $(window) + var navHeight = $('.navbar').outerHeight(true) + 10 + + $(document.body).scrollspy({ + target: '.bs-sidebar', + offset: navHeight + }) + // Disable certain links in docs $('.bs-docs-container [href=#]').click(function (e) { e.preventDefault() }) + $(document.body).on('click', '[href^=#]', function (e) { + + var $target = $(this.getAttribute('href')) + + e.preventDefault() // prevent browser scroll + + document.body.scrollTop = + $target.offset().top - + navHeight + 5 // offset scroll by nav + }) // back to top setTimeout(function () { diff --git a/javascript.html b/javascript.html index 51ce7f95f..e0ddae0a1 100644 --- a/javascript.html +++ b/javascript.html @@ -8,9 +8,9 @@ lead: "Bring Bootstrap's components to life with over a dozen custom jQuery plug -For simple transition effects, include transition.js once alongside the other JS files. If you're using the compiled (or minified) bootstrap.js, there is no need to include this—it's already there.
To easily add scrollspy behavior to your topbar navigation, add data-spy="scroll" to the element you want to spy on (most typically this would be the <body>. Then add the data-target attribute with the ID or class of the parent element of any Bootstrap .nav component.
Enable tabbable tabs via JavaScript (each tab needs to be activated individually):
{% highlight js %} $('#myTab a').click(function (e) { @@ -732,9 +732,9 @@ $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { -Trigger the tooltip via JavaScript:
{% highlight js %} $('#example').tooltip(options) @@ -873,9 +873,9 @@ $('#example').tooltip(options) -Enable popovers via JavaScript:
{% highlight js %}$('#example').popover(options){% endhighlight %} @@ -1058,9 +1058,9 @@ $('#example').tooltip(options) -Enable dismissal of an alert via JavaScript:
{% highlight js %}$(".alert").alert(){% endhighlight %} @@ -1137,9 +1137,9 @@ $('#my-alert').bind('closed.bs.alert', function () { -Enable buttons via JavaScript:
{% highlight js %} $('.nav-tabs').button() @@ -1282,9 +1282,9 @@ $('.nav-tabs').button() -Just add data-toggle="collapse" and a data-target to element to automatically assign control of a collapsible element. The data-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you'd like it to default open, add the additional class in.
Use data attributes to easily control the position of the carousel. data-slide accepts the keywords prev or next, which alters the slide position relative to its current position. Alternatively, use data-slide-to to pass a raw slide index to the carousel data-slide-to="2", which shifts the slide position to a particular index beginning with 0.
To easily add affix behavior to any element, just add data-spy="affix" to the element you want to spy on. Then use offsets to define when to toggle the pinning of an element on and off.