/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: a11andoh
  • Date: 2013-05-27 11:25:41 UTC
  • mfrom: (105 lenasys_b)
  • mto: This revision was merged to the branch mainline in revision 106.
  • Revision ID: a11andoh@student.his.se-20130527112541-gut7vg5nu8mxvgmn
blurp

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/* Functions that run when the page loads */
4
4
$(document).ready(function() {
5
5
 
6
 
        /* Secures that the dropdownmenus are not shown on pageload */
7
 
        $('#bannerContentExample').hide();
8
 
        $('#dropdownCodeviewerMenu').hide();
9
 
        $('#dropdownUserMenu').hide();
10
 
        $('#popup').hide();
11
 
 
12
 
        /* TODO: ??? */
 
6
        /* Sets the click-function for the usermenubutton */
13
7
        $('#bannerUserMenuButton').click(function(e){
14
 
                $('#popup').load('ajax/popup/loginForm #loginForm');
15
 
                $('#popup').show();
16
8
                
17
 
 
18
 
                /*var target = $('#loginPopup');
19
 
                if(target.is(":hidden")){
20
 
                        target.fadeIn(300);
21
 
                        $('#username').focus();
22
 
                        e.stopPropagation();
23
 
                }
24
 
                else{
25
 
                        // make not visible
26
 
                        // remove from DOM
27
 
                        target.fadeOut(300);
28
 
                }*/
 
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
                });
29
38
                
30
39
        });
31
40
        
32
 
        /* Check courses in expanded menu */
33
 
        $('li.dropdownMenuCourseBlockNonActiveCourse').click(function(){
34
 
                $('li.dropdownMenuCourseBlockActiveCourse').addClass('dropdownMenuCourseBlockNonActiveCourse');
35
 
                $('li.dropdownMenuCourseBlockActiveCourse').removeClass('dropdownMenuCourseBlockActiveCourse');
 
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
                }
36
53
 
37
 
                $(this).removeClass('dropdownMenuCourseBlockNonActiveCourse');
38
 
                $(this).addClass("dropdownMenuCourseBlockActiveCourse");
39
 
                /*TA BORT DEN ENA KLASSEN OCH ANVĂ„ND TOGGLE*/
40
54
        });
41
55
        
42
56