|
@@ -9,10 +9,44 @@ $(function() {
|
|
|
document.documentElement.scrollTop = 0;
|
|
document.documentElement.scrollTop = 0;
|
|
|
return false;
|
|
return false;
|
|
|
});
|
|
});
|
|
|
|
|
+ initScrollspy();
|
|
|
showGotoTop();
|
|
showGotoTop();
|
|
|
showBaiduShare();
|
|
showBaiduShare();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function initScrollspy() {
|
|
|
|
|
+ var $window = $(window);
|
|
|
|
|
+ var $body = $(document.body);
|
|
|
|
|
+
|
|
|
|
|
+ var navHeight = $('.navbar').outerHeight(true) + 10;
|
|
|
|
|
+
|
|
|
|
|
+ $body.scrollspy({
|
|
|
|
|
+ target: '.bs-sidebar',
|
|
|
|
|
+ offset: navHeight
|
|
|
|
|
+ });
|
|
|
|
|
+ $body.scrollspy('refresh');
|
|
|
|
|
+
|
|
|
|
|
+ // affix
|
|
|
|
|
+ setTimeout(function () {
|
|
|
|
|
+ var $sideBar = $('.bs-sidebar');
|
|
|
|
|
+
|
|
|
|
|
+ $sideBar.affix({
|
|
|
|
|
+ offset: {
|
|
|
|
|
+ top: function () {
|
|
|
|
|
+ var offsetTop = $sideBar.offset().top;
|
|
|
|
|
+ var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10);
|
|
|
|
|
+ var navOuterHeight = $('.bs-docs-nav').height();
|
|
|
|
|
+
|
|
|
|
|
+ return (this.top = offsetTop - navOuterHeight - sideBarMargin);
|
|
|
|
|
+ },
|
|
|
|
|
+ bottom: function () {
|
|
|
|
|
+ return (this.bottom = $('.bs-footer').outerHeight(true));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }, 100);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function showGotoTop() {
|
|
function showGotoTop() {
|
|
|
var $gotoTop = $('.goto-top'),
|
|
var $gotoTop = $('.goto-top'),
|
|
|
$bdshare = $('#bdshare');
|
|
$bdshare = $('#bdshare');
|