-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathscripts.js
45 lines (36 loc) · 1.54 KB
/
scripts.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
$( document ).ready(function() {
init();
});
$( "button.nav-link.icon-button" ).on( "click", handleNavMobileNavLinkClick);
$( "h4.topic" ).on( "click", handleNavMobileNavLinkClick);
const headerMenu = document.getElementById("navbarSupportedContent");
function init() {
var activeTab = $(".navbar-nav .nav-item.active[data-role='nav-menu-tab']")[0];
var activeTabPanelId = activeTab && activeTab.dataset ? activeTab.dataset.targetTabPanelId : null;
if (activeTabPanelId) showMainPageTab(activeTabPanelId);
$(".navbar-nav .nav-item[data-role='nav-menu-tab']").on("click", handleTabChange);
$( "h4.topic" ).on( "click", handleTabChange);
$( "h6.trynow" ).on( "click", handleTabChange);
}
function handleTabChange(e) {
var { targetTabPanelId } = e.currentTarget.dataset;
$(".navbar-nav .nav-item[data-role='nav-menu-tab']").removeClass("active");
$(".navbar-nav .nav-item[data-target-tab-panel-id='" + targetTabPanelId + "']").addClass("active");
targetTabPanelId =="about" ? $("#alert-container").addClass("hide") : $("#alert-container").removeClass("hide")
if (targetTabPanelId) {
hideAllMainPageTabs();
showMainPageTab(targetTabPanelId);
}
window.scrollTo(0,0)
}
function hideAllMainPageTabs() {
$(".main-page-tab-panel").hide();
}
function showMainPageTab(tabPanelId) {
$(".main-page-tab-panel[data-tab-panel-id='" + tabPanelId + "']").fadeIn();
}
function handleNavMobileNavLinkClick() {
if ($(headerMenu).hasClass( "show" )) {
$(headerMenu).collapse('hide');
}
}