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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
/* TODO: cHANGE THIS FILE ENTIRELY!!! CHANGE CALLED ID'S AND CLASSES */
/* Functions that run when the page loads */
$(document).ready(function() {
/* Sets the click-function for the usermenubutton */
$('#bannerUserMenuButton').click(function(e){
$.get('ajax/isLoggedIn', function(response) {
if(response == 'yes') {
// If the user is logged in and the usermenu-div is hidden it's shown.
if($('#dropdownUserMenu').is(':hidden')) {
// Secure that the courseblock-div is hidden when the usermenu-div is oppened.
if($('#dropdownMenuCourseBlock').is(':visible')) {
$('#dropdownMenuCourseBlock').hide();
}
$('#dropdownUserMenu').load('bannermenu.php #dropdownUserMenu');
$('#dropdownUserMenu').show();
}
// If the user is logged in and the usermenu-div is shown it's hidden.
else {
$('#dropdownUserMenu').hide();
}
}
else {
// If the user is not logged in and the popup-div is hidden it's filled and shown.
if($('#popup').is(':hidden')) {
$('#popup').load('ajax/popup/loginForm #loginForm', function(){
$('#popup').show();
});
}
// If the user is not logged in and the popup-div shows it's hidden.
else {
$('#popup').hide();
}
}
});
});
// TODO: Refresh the div with it's php before show.
/* Expand and collapse courses in dropdown menu */
$('#dropdownMenuExpandCourses').click(function(){
// If the course block is collapsed it's expanded.
if($('#dropdownMenuCourseBlock').is(':hidden')) {
$('#dropdownMenuCourseBlock').show();
}
// If the course block is expanded it's collapsed .
else {
$('#dropdownMenuCourseBlock').hide();
}
});
/* ROLLES KOD NEDAN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/* TODO: SHOULD OPEN A POPUP VIA AJAX */
/* Blurs body and opens password changer */
$('li[name="changePwd"]').click(function(e){
e.stopPropagation();
$('#popoutMenu').stop(false, false).slideUp(300);
popoutMenu=0;
$('body *').not('#passwordChanger, #passwordChanger *').animate({
opacity:0.4}, 400);
$('#passwordChanger').fadeIn(300);
$('#passwordChanger').css('z-index', 3000);
});
$('body').click(function(e){
$('#formContainer').fadeOut(300);
$('#passwordChanger').fadeOut(300);
$('body *').animate({
opacity:1}, 400);
$('#changePassword')[0].reset();
});
$('#passwordChanger').click(function(e){
e.stopPropagation();
});
$('#formContainer').click(function(e){
e.stopPropagation();
});
$('#popoutLink').click(function(e){
if(popoutMenu==0){
$('#popoutMenu').stop(false, true).slideDown(300);
popoutMenu=1;
e.stopPropagation();
// FIXA SÅ MENYN INTE KOMMER UPP IGEN
}
else if(popoutMenu==1){
$('#popoutMenu').stop(false, false).slideUp(300);
popoutMenu=0;
e.stopPropagation();
}
});
});
/* TODO: Do I need these? */
/* Global variables */
var popoutMenu=0;
var expandedCourses=0;
window.onkeyup = function(event){
if(event.keyCode==27){
$('#formContainer').fadeOut(300);
$('#passwordChanger').fadeOut(300);
$('body *').animate({
opacity:1}, 400);
$('#changePassword')[0].reset();
}
}
/* Closing password changer and reactivates body */
function cancelPasswordChange(){
$('#passwordChanger').fadeOut(300);
$('body *').animate({
opacity:1}, 400);
$('#changePassword')[0].reset();
}
/* Expand/Collapse courses in popout menu */
function expandCourses(){
if(expandedCourses==0){
$('#expandedCourses').stop(false, true).slideDown(300);
expandedCourses=1;
}
else if(expandedCourses==1){
$('#expandedCourses').stop(false, false).slideUp(300);
expandedCourses=0;
}
}
|