1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
$(document).ready(function(){
$("#new_projectset_form").submit(add_projectset);
$(".new_project").submit(add_project);
$('li').show();
$('.add-project-link').click(show_add);
$('.add-projectset-link').click(show_add);
});
function serializeForm(form){
mylist = form.serializeArray();
var data = {};
for (var i = 0; i < mylist.length; i++){
data[mylist[i].name] = mylist[i].value;
}
return data;
};
function add_project(){
$(this).slideToggle('fast');
function callback(xhr) {
var response = JSON.parse(xhr.responseText);
var projectlist = $('#projectslist_' + response.projectset_id);
var new_element = response.html.split('\n').slice(1).join('\n');
projectlist.children(".list_empty_indicator").remove()
add_section = projectlist.children(".add-project");
$(add_section).before(new_element).hide().slideDown();
};
var data = serializeForm($(this));
ajax_call(callback, $(this).attr("action"), "", data, 'POST');
return false;
};
function add_projectset(){
$("#add_projectset").attr('disabled', 'disabled');
function callback(xhr) {
var response = JSON.parse(xhr.responseText);
$('#projectset_list').append(response.html);
var projectset_div = $('#projectset_' + response.projectset_id);
projectset_div.hide();
projectset_div.slideDown();
$("#add_projectset").removeAttr('disabled');
projectset_div.find(".new_project").submit(add_project);
projectset_div.find(".add-project-link").click(show_add);
};
var data = serializeForm($("#new_projectset_form"));
data['ivle.op'] = 'add_projectset';
ajax_call(callback, $("#new_projectset_form").attr("action"), "", data,
'POST');
return false;
};
function show_add(){
$(this).next().slideToggle();
return false;
}
|