1
$(document).ready(function(){
2
$("#new_projectset_form").submit(add_projectset);
3
$(".new_project").submit(add_project);
5
$('.add-project-link').click(show_add);
6
$('.add-projectset-link').click(show_add);
9
function serializeForm(form){
11
mylist = form.serializeArray();
13
for (var i = 0; i < mylist.length; i++){
14
data[mylist[i].name] = mylist[i].value;
20
function add_project(){
22
$(this).slideToggle('fast');
24
function callback(xhr) {
25
var response = JSON.parse(xhr.responseText);
26
var projectlist = $('#projectslist_' + response.projectset_id);
27
var new_element = response.html.split('\n').slice(1).join('\n');
28
projectlist.children(".list_empty_indicator").remove()
29
add_section = projectlist.children(".add-project");
30
$(add_section).before(new_element).hide().slideDown();
33
var data = serializeForm($(this));
35
ajax_call(callback, $(this).attr("action"), "", data, 'POST');
40
function add_projectset(){
42
$("#add_projectset").attr('disabled', 'disabled');
44
function callback(xhr) {
45
var response = JSON.parse(xhr.responseText);
46
$('#projectset_list').append(response.html);
47
var projectset_div = $('#projectset_' + response.projectset_id);
48
projectset_div.hide();
49
projectset_div.slideDown();
50
$("#add_projectset").removeAttr('disabled');
51
projectset_div.find(".new_project").submit(add_project);
52
projectset_div.find(".add-project-link").click(show_add);
55
var data = serializeForm($("#new_projectset_form"));
57
data['ivle.op'] = 'add_projectset';
59
ajax_call(callback, $("#new_projectset_form").attr("action"), "", data,
66
$(this).next().slideToggle();