5a9b3002743202b64796d3f19658fb7193a1acd5
[bootswatch] / js / bootswatch.js
1 $('a[rel=tooltip]').tooltip({
2         'placement': 'bottom'
3 });
4
5
6 $('.navbar a, .subnav a').smoothScroll();
7
8
9 (function ($) {
10
11         $(function(){
12
13                 // fix sub nav on scroll
14                 var $win = $(window),
15                                 $body = $('body'),
16                                 $nav = $('.subnav'),
17                                 navHeight = $('.navbar').first().height(),
18                                 subnavHeight = $('.subnav').first().height(),
19                                 subnavTop = $('.subnav').length && $('.subnav').offset().top - navHeight,
20                                 marginTop = parseInt($body.css('margin-top'), 10);
21                                 isFixed = 0;
22
23                 processScroll();
24
25                 $win.on('scroll', processScroll);
26
27                 function processScroll() {
28                         var i, scrollTop = $win.scrollTop();
29
30                         if (scrollTop >= subnavTop && !isFixed) {
31                                 isFixed = 1;
32                                 $nav.addClass('subnav-fixed');
33                                 $body.css('margin-top', marginTop + subnavHeight + 'px');
34                         } else if (scrollTop <= subnavTop && isFixed) {
35                                 isFixed = 0;
36                                 $nav.removeClass('subnav-fixed');
37                                 $body.css('margin-top', marginTop + 'px');
38                         }
39                 }
40
41         });
42
43 })(window.jQuery);