-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·53 lines (45 loc) · 1.76 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
/* jshint browser: true */
/* global console */
/* global $ */
var lastTab;
var app = {
// Application Constructor
initialize: function () {
console.log("Entering app.initialize()");
//===========================================
//define the onclick event for the menu
//===========================================
$(".menuLink").on('click', function (e) {
console.log("Entering click event");
//=========================================
//Set active menu item
//=========================================
//first remove active status for the currently selected menu item
// $(this).parent().parent().find('.active').removeClass('active');
$('.nav').find('.active').removeClass('active');
//Then set the current menu item to acive
$(this).parent().addClass('active');
//=========================================
//Show the right content
//=========================================
//Disable the link action, so nothing else happens when the menu
//is selected
e.preventDefault(); // stops link from loading
//Hide all existing page content
$('.content').hide();
//Then show the content for the current selected menu item
//get the href and use it find which div to show
$($(this).attr('href')).show();
});
//===========================================
//Do this so the menu collapses when you click an item
//http://stackoverflow.com/questions/21203111/bootstrap-3-collapsed-menu-doesnt-close-on-click
//===========================================
$(document).on('click', '.navbar-collapse.in', function (e) {
if ($(e.target).is('a') && $(e.target).attr('class') != 'dropdown-toggle') {
$(this).collapse('hide');
}
});
console.log("Leaving app.initialize()");
}
};