/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/js/bannermenu.js

  • Committer: elof.bigestans at gmail
  • Date: 2013-05-27 14:08:19 UTC
  • mto: This revision was merged to the branch mainline in revision 108.
  • Revision ID: elof.bigestans@gmail.com-20130527140819-p6j84f9l71zxofyp
* Started work on the viewStudents functionality... So far, displaying users works and it outputs correct and standardized html. 
* Still plenty to do though.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* TODO: cHANGE THIS FILE ENTIRELY!!! CHANGE CALLED ID'S AND CLASSES */
 
2
 
 
3
/* Functions that run when the page loads */
 
4
$(document).ready(function() {
 
5
 
 
6
        /* Sets the click-function for the usermenubutton */
 
7
        $('#bannerUserMenuButton').click(function(e){
 
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')) {
 
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');
 
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
                });
 
38
                
 
39
        });
 
40
        
 
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
                }
 
53
 
 
54
        });
 
55
        
 
56
        
 
57
        /* ROLLES KOD NEDAN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
 
58
        
 
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
        
 
101
        
 
102
});
 
103
 
 
104
/* TODO: Do I need these? */
 
105
/* Global variables */
 
106
var popoutMenu=0;
 
107
var expandedCourses=0;
 
108
 
 
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