aboutsummaryrefslogtreecommitdiffstats
path: root/static/js/sidebar.js
blob: 4bfc7a743a318ba99146b1d9640c99ea76124314 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * js for sidebar
 */

$(document).ready(function() {
    $('#sidebar').affix({
        offset: {
            top: 235
        }
    });

    var $body = $(document.body);
    var navHeight = $('.navbar').outerHeight(true) + 10;

    $body.scrollspy({
        target: '#sidebar-col',
        offset: navHeight
    });

    /* smooth scrolling sections */
    $('a[href*=#]:not([href=#])').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var target = $(this.hash);
            target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
            if (target.length) {
                $('html,body').animate({
                    scrollTop: target.offset().top - 50
                }, 100);
                return false;
            }
        }
    });
});