-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathmain.js
69 lines (58 loc) · 2.34 KB
/
main.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
$(function () {
// Search Items
$('#search').on('keyup', function (e) {
var value = $(this).val();
var $el = $('.navigation');
if (value) {
var regexp = new RegExp(value, 'i');
$el.find('li, .itemMembers').hide();
$el.find('li').each(function (i, v) {
var $item = $(v);
if ($item.data('name') && regexp.test($item.data('name'))) {
$item.show();
$item.closest('.itemMembers').show();
$item.closest('.item').show();
}
});
} else {
$el.find('.item, .itemMembers').show();
}
$el.find('.list').scrollTop(0);
});
// Toggle when click an item element
$('.navigation').on('click', '.title', function (e) {
$(this).parent().find('.itemMembers').toggle();
});
// Show an item related a current documentation automatically
var filename = $('.page-title').data('filename').replace(/\.[a-z]+$/, '').replace("-", ":");
var $currentItem = $('.navigation .item[data-name*="' + filename + '"]:eq(0)');
if ($currentItem.length) {
$currentItem
.remove()
.prependTo('.navigation .list')
.show()
.find('.itemMembers')
.show();
}
// Auto resizing on navigation
var _onResize = function () {
var height = $(window).height();
var $el = $('.navigation');
$el.height(height).find('.list').height(height - 133);
};
$(window).on('resize', _onResize);
_onResize();
// disqus code
if (config.disqus) {
$(window).on('load', function () {
var disqus_shortname = config.disqus; // required: replace example with your forum shortname
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
document.getElementsByTagName('BODY')[0].appendChild(s);
});
}
});