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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Scrollspy and affixed enhanced navigation for Twitter Bootstrap
* Modified and built for Yii Framework 2.0
*
* Based on affix sidenav examples available in Twitter Bootstrap
* documentation site at http://getbootstrap.com/
*
* Author: Kartik Visweswaran
* Year: 2014
* For more Yii related demos visit http://demos.krajee.com
*/
!function ($) {
$(function () {
var $window = $(window),
$body = $(document.body),
$sideBar = $('.kv-sidebar'),
navHeight = $('.navbar').outerHeight(true) + 10;
$body.scrollspy({
target: '.kv-sidebar',
offset: navHeight
})
$window.on('load', function () {
$body.scrollspy('refresh')
})
$('.kv-sidebar [href=#]').click(function (e) {
e.preventDefault()
})
// back to top
setTimeout(function () {
$sideBar.affix({
offset: {
top: function () {
var offsetTop = $sideBar.offset().top
var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10)
var navOuterHeight = $('.kv-header').height()
return (this.top = offsetTop - navOuterHeight - sideBarMargin)
},
bottom: function () {
return (this.bottom = $('.kv-footer').outerHeight(true))
}
}
})
}, 100)
$sideBar.width($sideBar.parent().width());
$window.resize(function () {
$sideBar.width($sideBar.parent().width());
});
})
}(window.jQuery)