/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
82.1.1 by a10rolch
- Added manageCoursesBody.css
1
/* Functions */
2
$(document).ready(function(){
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
3
83.2.1 by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function
4
	$('#addCourseButton').click(function(e){
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
5
		$("#popup").load("ajax/popup/addCourse", function() {
6
			$("#addCourse").fadeIn(300);
7
			$("#addCourse .cancelButton").click(cancelButtonHandler);
8
		});
82.1.1 by a10rolch
- Added manageCoursesBody.css
9
	});
10
	
11
	$('.manageCourseButton').click(function(e){
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
12
		var courseID = $(this).parent().prevAll(".courseID").html();
13
		var courseName = $(this).parent().prevAll(".courseName").html();
14
		var courseData = $(this).parent().prevAll(".courseData").html();
15
16
		$("#popup").load("ajax/popup/editCourseDetails", function() {
17
			$("#editCourse #editCourseName").attr("value", courseName);
18
			$("#editCourse span").html(courseID);
19
			$("#editCourse #editCourseID").attr("value", courseID)
20
			$("#editCourse #editCourseData").attr("value", courseData);
21
22
			$("#editCourse").fadeIn(300);
23
			$("#editCourse .cancelButton").click(cancelButtonHandler);
24
		});
25
	});
26
27
	$(".cancelButton").click(cancelButtonHandler);
83.2.1 by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function
28
29
	$("#manageCourses table tr:odd").addClass("odd");
30
	$("#manageCourses table tr:even").addClass("even");
31
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
32
	/* When you click published/unpublished, the course should be toggled to the opposite state */
33
	$(".publishButton").click(publishButtonHandler);
34
83.2.6 by elof.bigestans at gmail
Solved some bugs in ManageCourses and related files (CSS, JS, View, Controller)
35
	$("html").click(function() {
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
36
		$(".manageCoursePopup").fadeOut(300, function() {
37
			$(this).remove();
38
		});
39
	});
40
41
	$("#popup").click(function(e) {
42
		e.stopPropagation();
43
	});
82.1.1 by a10rolch
- Added manageCoursesBody.css
44
});
45
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
46
function publishButtonHandler(evt) {
47
	evt.preventDefault();
48
	evt.stopPropagation();
49
50
	// $(this) = the <a> being clicked. Fetch the a's href value. 
51
	var href = $(this).attr("href");
52
	var a = $(this);
53
	$.get(href, function() {
54
		var currentURL = window.location.pathname;
55
		var courseID = a.parent().parent().attr("data-course");
56
		a.parent().load(currentURL + " [data-course="+courseID+"] .coursePublishButton a", function(){
57
			$(this).find("a").click(publishButtonHandler);
58
		});
59
	});
60
}
61
62
function cancelButtonHandler(e) {
63
	$(this).closest(".manageCoursePopup").fadeOut(300, function(){
64
		$(this).remove();
65
	});
66
	e.preventDefault();
67
	e.stopPropagation();
83.2.1 by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function
68
}
69
82.1.1 by a10rolch
- Added manageCoursesBody.css
70
window.onkeyup = function(event){
71
	if(event.keyCode==27){
72
		$('#addCourse').fadeOut(300);
73
	}
74
}