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.12
by a11emmjo
Fixed so the bannermenu is scrollable horizontally but not vertically. |
6 |
/* Makes the bannermenu scrollable horizontally but not vertically */ |
7 |
$('#bannerBody').scrollToFixed(); |
|
8 |
||
83.2.21
by elof.bigestans at gmail
* Working on the dropdown menu and login popup |
9 |
$("#dropdownUserMenu").click(function(e) { |
10 |
e.stopPropagation(); |
|
11 |
}); |
|
12 |
||
90.1.8
by a11emmjo
Fixed some redirect-links. |
13 |
/* 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. |
14 |
$('#bannerUserMenuButton').click(function(e){ |
83.2.21
by elof.bigestans at gmail
* Working on the dropdown menu and login popup |
15 |
e.stopPropagation(); |
90.1.8
by a11emmjo
Fixed some redirect-links. |
16 |
$.get('ajax/isLoggedIn', function(response) { |
17 |
if(response == 'yes') { |
|
18 |
// If the user is logged in and the usermenu-div is hidden it's shown. |
|
90.1.12
by a11emmjo
Fixed so the bannermenu is scrollable horizontally but not vertically. |
19 |
// TODO: Secure that the courseblock-div is hidden when the usermenu-div is oppened. |
20 |
/* |
|
90.1.9
by a11emmjo
Updated branch. |
21 |
if($('#dropdownMenuCourseBlock').is(':visible')) {
|
22 |
$('#dropdownMenuCourseBlock').hide();
|
|
23 |
}
|
|
24 |
$('#dropdownUserMenu').load('bannermenu.php #dropdownUserMenu');
|
|
90.1.12
by a11emmjo
Fixed so the bannermenu is scrollable horizontally but not vertically. |
25 |
*/
|
83.2.21
by elof.bigestans at gmail
* Working on the dropdown menu and login popup |
26 |
//$("#dropdownMenuCourseBlock").hide(); |
90.1.8
by a11emmjo
Fixed some redirect-links. |
27 |
// If the user is logged in and the usermenu-div is shown it's hidden. |
83.2.21
by elof.bigestans at gmail
* Working on the dropdown menu and login popup |
28 |
$('#dropdownMenuCourseBlock').hide(); |
29 |
$('#dropdownUserMenu').toggle(); |
|
90.1.8
by a11emmjo
Fixed some redirect-links. |
30 |
} |
83.2.21
by elof.bigestans at gmail
* Working on the dropdown menu and login popup |
31 |
|
90.1.8
by a11emmjo
Fixed some redirect-links. |
32 |
else { |
33 |
// If the user is not logged in and the popup-div is hidden it's filled and shown. |
|
34 |
if($('#popup').is(':hidden')) { |
|
83.2.16
by elof.bigestans at gmail
* Merged trunk AND |
35 |
$('#popup').load('ajax/popup/login', function(){ |
83.2.20
by elof.bigestans at gmail
Working on Bannermenu |
36 |
$('#popup').show().click(function(e){e.stopPropagation();}); |
83.2.16
by elof.bigestans at gmail
* Merged trunk AND |
37 |
$("#popup .hint").click(loginHint); |
83.2.22
by elof.bigestans at gmail
* Moved login JS to bannermenu.js and removed login.js |
38 |
$("#popup #username").focus().keydown(function() { |
39 |
$("#popup .hint").addClass("available"); |
|
40 |
}); |
|
41 |
$("#popup form").submit(loginSubmit); |
|
90.1.8
by a11emmjo
Fixed some redirect-links. |
42 |
}); |
43 |
} |
|
44 |
// If the user is not logged in and the popup-div shows it's hidden. |
|
45 |
else { |
|
46 |
$('#popup').hide(); |
|
47 |
} |
|
48 |
} |
|
49 |
}); |
|
90.1.2
by a11emmjo
Made a standard css-file to be used for the whole lenasys-page. |
50 |
|
51 |
}); |
|
90.1.5
by a11emmjo
Added popup-div to bannermenu. |
52 |
|
90.1.9
by a11emmjo
Updated branch. |
53 |
// TODO: Refresh the div with it's php before show. |
54 |
/* Expand and collapse courses in dropdown menu */ |
|
55 |
$('#dropdownMenuExpandCourses').click(function(){ |
|
56 |
|
|
57 |
// If the course block is collapsed it's expanded. |
|
58 |
if($('#dropdownMenuCourseBlock').is(':hidden')) { |
|
59 |
$('#dropdownMenuCourseBlock').show(); |
|
60 |
} |
|
61 |
// If the course block is expanded it's collapsed . |
|
62 |
else { |
|
63 |
$('#dropdownMenuCourseBlock').hide(); |
|
64 |
} |
|
90.1.5
by a11emmjo
Added popup-div to bannermenu. |
65 |
|
66 |
}); |
|
83.2.20
by elof.bigestans at gmail
Working on Bannermenu |
67 |
|
68 |
$("#dropdownMenuLogout").click(function(e) { |
|
69 |
e.stopPropagation(); |
|
70 |
window.location.href = "./start/logout"; |
|
71 |
}); |
|
72 |
||
73 |
$("html").click(function(e) { |
|
74 |
e.stopPropagation(); |
|
83.2.21
by elof.bigestans at gmail
* Working on the dropdown menu and login popup |
75 |
$("#dropdownUserMenu").hide(); |
83.2.20
by elof.bigestans at gmail
Working on Bannermenu |
76 |
$("#popup").hide(); |
77 |
}); |
|
83.2.22
by elof.bigestans at gmail
* Moved login JS to bannermenu.js and removed login.js |
78 |
});
|
79 |
||
80 |
function loginSubmit(e) { |
|
81 |
e.stopPropagation(); |
|
82 |
e.preventDefault(); |
|
83 |
||
84 |
var un = $(this).find("#username").val(); |
|
85 |
var pw = $(this).find("#password").val(); |
|
86 |
||
87 |
$.post( |
|
88 |
"start/login", |
|
89 |
{ username: un, password: pw}, |
|
90 |
function(data) { |
|
91 |
if(data == "true") { |
|
92 |
window.location.href ="./cms"; |
|
93 |
} else { |
|
94 |
if($("#popup .popup").hasClass("error")) { |
|
95 |
$("#popup .popup form .errorContainer").html('Error! '+data+' Please try again.'); |
|
96 |
} else { |
|
97 |
$("#popup .popup").addClass("error"); |
|
98 |
$("#popup .popup form").prepend('<div class="errorContainer">Error! '+data+' Please try again. </div>'); |
|
99 |
} |
|
100 |
} |
|
101 |
} |
|
102 |
); |
|
103 |
}
|
|
104 |
||
105 |
function loginHint(e) { |
|
106 |
e.preventDefault(); |
|
107 |
e.stopPropagation(); |
|
108 |
||
109 |
// If username field is empty, inform user and exit function |
|
110 |
var uname = $("#login #username").val(); |
|
111 |
if(uname == "") { |
|
112 |
return; |
|
113 |
} |
|
114 |
||
115 |
// POST username to the function /ajax/pwdhint which returns a json object with password hint |
|
116 |
$.post( |
|
117 |
// Replace with final production URL!!! |
|
118 |
||
119 |
"ajax/pwdhint", |
|
120 |
// Data sent through POST |
|
121 |
{ username: uname }, |
|
122 |
||
123 |
// Callback function |
|
124 |
function(data) { |
|
125 |
var result = $.parseJSON(data)["hint"]; |
|
126 |
||
127 |
// result["hint"] is either a boolean false or a string containing the hint |
|
128 |
if(result === false) { |
|
129 |
$("#hinttext").html('<p class="error">No password hint available</p>'); |
|
130 |
} else { |
|
131 |
$("#hinttext").html('<p>Hint: ' + result + '</p>'); |
|
132 |
} |
|
133 |
||
134 |
$("#login").toggleClass("expanded"); |
|
135 |
$("#hinttext").toggle(); |
|
136 |
||
137 |
} |
|
138 |
); // End $.post {} |
|
139 |
||
140 |
} // End loginHint() |