/
application.js
104 lines (83 loc) · 2.7 KB
/
application.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*!
* Adapted from Bootstrap docs JavaScript
*/
!function ($) {
$(function () {
// IE10 viewport hack for Surface/desktop Windows 8 bug
//
// See Getting Started docs for more information
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement('style')
msViewportStyle.appendChild(
document.createTextNode(
'@-ms-viewport{width:auto!important}'
)
)
document.querySelector('head').appendChild(msViewportStyle)
}
var $window = $(window)
var $body = $(document.body)
//var navHeight = $('.navbar').outerHeight(true) + 10
$body.scrollspy({
target: '.sidebar'
//offset: navHeight
});
$window.on('load', function () {
$body.scrollspy('refresh')
});
$('.docs-container [href=#]').click(function (e) {
e.preventDefault()
});
$('.source-link').each(function () {
var id = $(this).data('content');
var content = $('<span>').append($('#' + id)).html();
$(this).attr('data-content', content);
// Keep popovers open when hovered
$(this).popover({
trigger: 'manual',
container: 'body',
placement: 'left',
template: '<div class="popover popover-source"> <div class="arrow"></div> <div class="popover-inner"> <h3 class="popover-title"></h3> <div class="popover-content"> <p></p> </div> </div> </div>',
html: true,
delay: {show: 50, hide: 750}
}).on('mouseenter', function () {
var self = this;
$(this).popover('show');
$(this).addClass('active');
$(this).addClass('popover-source');
$('.popover').on('mouseleave', function () {
$(self).popover('hide');
$(self).removeClass('active');
});
}).on('mouseleave', function () {
var self = this;
setTimeout(function () {
if (!$('.popover:hover').length) {
$(self).popover('hide');
$(self).removeClass('active');
}
}, 100);
});
});
// back to top
setTimeout(function () {
var $sideBar = $('.sidebar')
$sideBar.affix({
offset: {
top: function () {
var offsetTop = $sideBar.offset().top
var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10)
var navOuterHeight = $('.docs-nav').height()
return (this.top = offsetTop - navOuterHeight - sideBarMargin)
},
bottom: function () {
return (this.bottom = $('.bs-footer').outerHeight(true))
}
}
})
}, 100);
setTimeout(function () {
$('.top').affix()
}, 100);
})
}(jQuery)