/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
85.2.1 by a11emmjo
Combined bannermenu with startview to get correct start-page.
1
/* TODO: cHANGE THIS FILE ENTIRELY!!! CHANGE CALLED ID'S AND CLASSES */
67.1.6 by a11emmjo
Replaced bannermenu/topmenu/header... on login-page.
2
85.2.1 by a11emmjo
Combined bannermenu with startview to get correct start-page.
3
/* Functions that run when the page loads */
4
$(document).ready(function() {
90.1.2 by a11emmjo
Made a standard css-file to be used for the whole lenasys-page.
5
90.1.8 by a11emmjo
Fixed some redirect-links.
6
	/* Sets the click-function for the usermenubutton */
90.1.2 by a11emmjo
Made a standard css-file to be used for the whole lenasys-page.
7
	$('#bannerUserMenuButton').click(function(e){
90.1.8 by a11emmjo
Fixed some redirect-links.
8
		
9
		$.get('ajax/isLoggedIn', function(response) {
10
			if(response == 'yes') {
11
				// If the user is logged in and the usermenu-div is hidden it's shown.
12
				if($('#dropdownUserMenu').is(':hidden')) {
90.1.9 by a11emmjo
Updated branch.
13
					// Secure that the courseblock-div is hidden when the usermenu-div is oppened.
14
					if($('#dropdownMenuCourseBlock').is(':visible')) {
15
						$('#dropdownMenuCourseBlock').hide();
16
					}
17
					$('#dropdownUserMenu').load('bannermenu.php #dropdownUserMenu');
90.1.8 by a11emmjo
Fixed some redirect-links.
18
					$('#dropdownUserMenu').show();
19
				}
20
				// If the user is logged in and the usermenu-div is shown it's hidden.
21
				else {
22
					$('#dropdownUserMenu').hide();
23
				}
24
			}
25
			else {
26
				// If the user is not logged in and the popup-div is hidden it's filled and shown.
27
				if($('#popup').is(':hidden')) {
28
					$('#popup').load('ajax/popup/loginForm #loginForm', function(){
29
						$('#popup').show();
30
					});
31
				}
32
				// If the user is not logged in and the popup-div shows it's hidden.
33
				else {
34
					$('#popup').hide();
35
				}
36
			}
37
		});
90.1.2 by a11emmjo
Made a standard css-file to be used for the whole lenasys-page.
38
		
39
	});
90.1.5 by a11emmjo
Added popup-div to bannermenu.
40
	
90.1.9 by a11emmjo
Updated branch.
41
	// TODO: Refresh the div with it's php before show.
42
	/* Expand and collapse courses in dropdown menu */
43
	$('#dropdownMenuExpandCourses').click(function(){
44
	
45
		// If the course block is collapsed it's expanded.
46
		if($('#dropdownMenuCourseBlock').is(':hidden')) {
47
			$('#dropdownMenuCourseBlock').show();
48
		}
49
		// If the course block is expanded it's collapsed .
50
		else {
51
			$('#dropdownMenuCourseBlock').hide();
52
		}
90.1.5 by a11emmjo
Added popup-div to bannermenu.
53
54
	});
90.1.2 by a11emmjo
Made a standard css-file to be used for the whole lenasys-page.
55
	
56
	
57
	/* ROLLES KOD NEDAN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
58
	
67.1.6 by a11emmjo
Replaced bannermenu/topmenu/header... on login-page.
59
	/* TODO: SHOULD OPEN A POPUP VIA AJAX */
60
	/* Blurs body and opens password changer */
61
	$('li[name="changePwd"]').click(function(e){
62
		e.stopPropagation();
63
		$('#popoutMenu').stop(false, false).slideUp(300);
64
		popoutMenu=0;
65
	    $('body *').not('#passwordChanger, #passwordChanger *').animate({
66
		opacity:0.4}, 400);
67
		$('#passwordChanger').fadeIn(300);
68
		$('#passwordChanger').css('z-index', 3000);
69
	});
70
	
71
	$('body').click(function(e){
72
		$('#formContainer').fadeOut(300);
73
		$('#passwordChanger').fadeOut(300);
74
		$('body *').animate({
75
		opacity:1}, 400);
76
		$('#changePassword')[0].reset();
77
	});
78
	
79
	$('#passwordChanger').click(function(e){
80
		e.stopPropagation();
81
	});
82
	
83
	$('#formContainer').click(function(e){
84
		e.stopPropagation();
85
	});
86
	
87
	$('#popoutLink').click(function(e){
88
		if(popoutMenu==0){
89
			$('#popoutMenu').stop(false, true).slideDown(300);
90
			popoutMenu=1;
91
			e.stopPropagation();
92
		// FIXA SÅ MENYN INTE KOMMER UPP IGEN
93
		}
94
		else if(popoutMenu==1){
95
			$('#popoutMenu').stop(false, false).slideUp(300);	
96
			popoutMenu=0;
97
			e.stopPropagation();
98
		}
99
	});
100
	
90.1.2 by a11emmjo
Made a standard css-file to be used for the whole lenasys-page.
101
	
67.1.6 by a11emmjo
Replaced bannermenu/topmenu/header... on login-page.
102
});
103
90.1.2 by a11emmjo
Made a standard css-file to be used for the whole lenasys-page.
104
/* TODO: Do I need these? */
105
/* Global variables */
106
var popoutMenu=0;
107
var expandedCourses=0;
108
67.1.6 by a11emmjo
Replaced bannermenu/topmenu/header... on login-page.
109
window.onkeyup = function(event){
110
	if(event.keyCode==27){
111
		$('#formContainer').fadeOut(300);
112
		$('#passwordChanger').fadeOut(300);
113
		$('body *').animate({
114
		opacity:1}, 400);
115
		$('#changePassword')[0].reset();
116
	}
117
}
118
119
/* Closing password changer and reactivates body */
120
function cancelPasswordChange(){
121
	$('#passwordChanger').fadeOut(300);
122
	$('body *').animate({
123
	opacity:1}, 400);
124
	$('#changePassword')[0].reset();
125
}
126
127
128
/* Expand/Collapse courses in popout menu */
129
function expandCourses(){
130
	if(expandedCourses==0){
131
	$('#expandedCourses').stop(false, true).slideDown(300);
132
	expandedCourses=1;
133
	}
134
	else if(expandedCourses==1){
135
		$('#expandedCourses').stop(false, false).slideUp(300);	
136
		expandedCourses=0;
137
	}
138
}
139