-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·59 lines (48 loc) · 1.63 KB
/
index.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
var currentGroup = null;
var firstGroup = null;
var currentGroupMenuItem = null;
var menuLookup = {};
function showGroup(groupId) {
if(!groupId || groupId.length == 0)
groupId = firstGroup;
if(currentGroupMenuItem != null)
currentGroupMenuItem.removeClass('active');
currentGroupMenuItem = menuLookup[groupId];
if(currentGroupMenuItem)
{
currentGroupMenuItem.addClass('active');
var group = currentGroupMenuItem.data('group');
if(group == currentGroup) return;
if(currentGroup != null) $(currentGroup).fadeOut();
$(group).fadeIn();
currentGroup = group;
$("html, body").animate({ scrollTop: 0 }, 400);
$('script[type="text/javascript-lazy"]', group).each(function() {
if(!$(this).data('run')) {
eval($(this).html());
$(this).data('run',true);
}
});
}
}
$(document).ready(function() {
var menu = $('#menu');
$('.group').each(function() {
var group = this;
var title = $('h1', group).text();
var menuItem = $(document.createElement('a'));
menuItem.addClass('button');
menuItem.text(title);
menuItem.data('group', group);
var groupId = '#' + group.id;
menuItem.attr('href', groupId);
menuLookup[groupId] = menuItem;
if(firstGroup == null)
firstGroup = groupId;
menu.append(menuItem);
});
$(window).on('hashchange', function() {
showGroup(window.location.hash);
});
showGroup(window.location.hash);
});