-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbehavior.js
More file actions
22 lines (17 loc) · 720 Bytes
/
behavior.js
File metadata and controls
22 lines (17 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function switchTabs() {
var location = window.location.hash.split('#').join('');
if ($('.main section#' + location).length == 0) {
location = 'home';
}
// select the right tab in the tab bar
$('#navigation-tabs li.selected').removeClass('selected');
$('#navigation-tabs li:has(a[href$="#' + location + '"])').addClass('selected');
// display the right section in the main area
$('.main section.selected').removeClass('selected');
$('.main section#' + location).addClass('selected');
$('.main section').not('.selected').hide();
$('.main section.selected').show();
$(window).scrollTop(0);
}
$(window).load(switchTabs);
$(window).bind('hashchange', switchTabs);