~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/subject-media/project.js

Modified the javascript for adding projects and projectsets, so that
they are now much prettier.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
    $("#new_projectset_form").submit(add_projectset);
3
3
    $(".new_project").submit(add_project);
4
4
    $('li').show('slow');
 
5
    $('.add-project-link').click(show_add);
5
6
});
6
7
 
7
8
function serializeForm(form){
16
17
};
17
18
 
18
19
function add_project(){
19
 
    $(this).attr('disabled', 'disabled');
20
20
 
 
21
    $(this).hide('normal');
 
22
    
21
23
    function callback(xhr) {
22
24
        var response = JSON.parse(xhr.responseText);
23
25
        var projectlist = $('#projectslist_' + response.projectset_id);
24
 
        projectlist.append(response.html).hide();
25
 
        projectlist.show('normal');
26
 
        $(this).removeAttr('disabled');
 
26
        var new_element = response.html.split('\n').slice(1).join('\n');
 
27
        if (projectlist.hasClass("emptylist")){
 
28
            projectlist.children().hide('normal');
 
29
            projectlist.removeClass("emptylist");
 
30
        }
 
31
        $(new_element).appendTo(projectlist).hide().show('normal');
27
32
    };
28
33
 
29
34
    var data = serializeForm($(this));
54
59
 
55
60
    return false;
56
61
};
 
62
 
 
63
function show_add(){
 
64
    $(this).next().toggle('normal');
 
65
    return false;
 
66
}