1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
1 |
$(document).ready(function(){ |
2 |
$("#new_projectset_form").submit(add_projectset); |
|
3 |
$(".new_project").submit(add_project); |
|
1165.3.63
by Nick Chadwick
Removed non-functional links to delete projects and grant extensions. |
4 |
$('li').show(); |
1165.3.6
by Nick Chadwick
Modified the javascript for adding projects and projectsets, so that |
5 |
$('.add-project-link').click(show_add); |
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
6 |
});
|
7 |
||
8 |
function serializeForm(form){ |
|
9 |
||
10 |
mylist = form.serializeArray(); |
|
11 |
var data = {}; |
|
12 |
for (var i = 0; i < mylist.length; i++){ |
|
13 |
data[mylist[i].name] = mylist[i].value; |
|
14 |
}
|
|
15 |
return data; |
|
16 |
||
17 |
};
|
|
18 |
||
19 |
function add_project(){ |
|
20 |
||
1249
by William Grant
Fix and prettify the transition when adding a new project. |
21 |
$(this).slideToggle('fast'); |
1165.3.6
by Nick Chadwick
Modified the javascript for adding projects and projectsets, so that |
22 |
|
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
23 |
function callback(xhr) { |
24 |
var response = JSON.parse(xhr.responseText); |
|
25 |
var projectlist = $('#projectslist_' + response.projectset_id); |
|
1165.3.6
by Nick Chadwick
Modified the javascript for adding projects and projectsets, so that |
26 |
var new_element = response.html.split('\n').slice(1).join('\n'); |
1165.3.32
by William Grant
Fix project addition JS. |
27 |
projectlist.children(".list_empty_indicator").remove() |
1249
by William Grant
Fix and prettify the transition when adding a new project. |
28 |
add_section = projectlist.children(".add-project"); |
29 |
$(add_section).before(new_element).hide().slideDown(); |
|
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
30 |
};
|
31 |
||
32 |
var data = serializeForm($(this)); |
|
33 |
||
34 |
ajax_call(callback, $(this).attr("action"), "", data, 'POST'); |
|
35 |
||
36 |
return false; |
|
37 |
};
|
|
38 |
||
39 |
function add_projectset(){ |
|
40 |
||
41 |
$("#add_projectset").attr('disabled', 'disabled'); |
|
42 |
||
43 |
function callback(xhr) { |
|
44 |
var response = JSON.parse(xhr.responseText); |
|
45 |
$('#projectset_list').append(response.html); |
|
46 |
$('#projectset_' + response.projectset_id).hide(); |
|
1165.3.10
by Nick Chadwick
Modified project.js to use the jquery slide instead of show/hide, which |
47 |
$('#projectset_' + response.projectset_id).slideDown(); |
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
48 |
$("#add_projectset").removeAttr('disabled'); |
1165.3.31
by William Grant
Reassign the 'Add a New Project' JS when a new instance appears. |
49 |
$(".add-project-link").click(show_add); |
1165.3.2
by Nick Chadwick
Created a new view for IVLE, allowing lecturers and tutors to |
50 |
};
|
51 |
||
52 |
var data = serializeForm($("#new_projectset_form")); |
|
53 |
||
54 |
data['ivle.op'] = 'add_projectset'; |
|
55 |
||
56 |
ajax_call(callback, $("#new_projectset_form").attr("action"), "", data, |
|
57 |
'POST'); |
|
58 |
||
59 |
return false; |
|
60 |
};
|
|
1165.3.6
by Nick Chadwick
Modified the javascript for adding projects and projectsets, so that |
61 |
|
62 |
function show_add(){ |
|
1165.3.10
by Nick Chadwick
Modified project.js to use the jquery slide instead of show/hide, which |
63 |
$(this).next().slideToggle(); |
1165.3.6
by Nick Chadwick
Modified the javascript for adding projects and projectsets, so that |
64 |
return false; |
65 |
}
|