index: add smoothscroll to front page
[bootswatch] / js / bootswatch.js
index 443f61b..5a9b300 100644 (file)
@@ -1,13 +1,43 @@
-$('.navbar .nav').first().append('<li class="dropdown"> \
-                <a class="dropdown-toggle" data-toggle="dropdown" href="#">Preview <b class="caret"></b></a> \
-                <ul class="dropdown-menu"> \
-                  <li><a href="../default">Default</a></li> \
-                  <li class="divider"></li> \
-                  <li><a href="../cerulean">Cerulean</a></li> \
-                  <li><a href="../cyborg">Cyborg</a></li> \
-                  <li><a href="../journal">Journal</a></li> \
-                  <li><a href="../simplex">Simplex</a></li> \
-                  <li><a href="../spacelab">Spacelab</a></li> \
-                  <li><a href="../united">United</a></li> \
-                </ul> \
-              </li>');
\ No newline at end of file
+$('a[rel=tooltip]').tooltip({
+       'placement': 'bottom'
+});
+
+
+$('.navbar a, .subnav a').smoothScroll();
+
+
+(function ($) {
+
+       $(function(){
+
+               // fix sub nav on scroll
+               var $win = $(window),
+                               $body = $('body'),
+                               $nav = $('.subnav'),
+                               navHeight = $('.navbar').first().height(),
+                               subnavHeight = $('.subnav').first().height(),
+                               subnavTop = $('.subnav').length && $('.subnav').offset().top - navHeight,
+                               marginTop = parseInt($body.css('margin-top'), 10);
+                               isFixed = 0;
+
+               processScroll();
+
+               $win.on('scroll', processScroll);
+
+               function processScroll() {
+                       var i, scrollTop = $win.scrollTop();
+
+                       if (scrollTop >= subnavTop && !isFixed) {
+                               isFixed = 1;
+                               $nav.addClass('subnav-fixed');
+                               $body.css('margin-top', marginTop + subnavHeight + 'px');
+                       } else if (scrollTop <= subnavTop && isFixed) {
+                               isFixed = 0;
+                               $nav.removeClass('subnav-fixed');
+                               $body.css('margin-top', marginTop + 'px');
+                       }
+               }
+
+       });
+
+})(window.jQuery);
\ No newline at end of file