From 7ba3812f918983a47cda678c31d12e0cd089677a Mon Sep 17 00:00:00 2001 From: Weitian LI Date: Mon, 28 Apr 2014 13:39:23 +0800 Subject: * moved 'introduction.js' -> 'sidebar.js' * moved 'introduction.css' -> 'sidebar.css' * updated page introduction.html * updated index.html and navbar.html --- static/js/sidebar.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 static/js/sidebar.js (limited to 'static/js') diff --git a/static/js/sidebar.js b/static/js/sidebar.js new file mode 100644 index 0000000..4bfc7a7 --- /dev/null +++ b/static/js/sidebar.js @@ -0,0 +1,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; + } + } + }); +}); + -- cgit v1.2.2