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

« back to all changes in this revision

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

  • Committer: David Coles
  • Date: 2009-07-21 02:19:56 UTC
  • mto: (1281.1.8 aufsless)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: coles.david@gmail.com-20090721021956-c1jiwu7fhi2dna1g
Updated to work on bind mounts

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
    $(".new_project").submit(add_project);
4
4
    $('li').show();
5
5
    $('.add-project-link').click(show_add);
6
 
    $('.add-projectset-link').click(show_add);
7
6
});
8
7
 
9
8
function serializeForm(form){
18
17
};
19
18
 
20
19
function add_project(){
21
 
    var add_project_form = $(this);
 
20
 
 
21
    $(this).slideToggle('fast');
 
22
    
22
23
    function callback(xhr) {
23
 
        if (xhr.status == 200) {
24
 
            add_project_form.slideToggle('fast');
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();
31
 
        } else if (xhr.status == 400) {
32
 
            alert("Could not create project: " + xhr.getResponseHeader("X-IVLE-Error"));
33
 
        } else {
34
 
            alert("Project creation failed due to an internal server error.");
35
 
        }
 
24
        var response = JSON.parse(xhr.responseText);
 
25
        var projectlist = $('#projectslist_' + response.projectset_id);
 
26
        var new_element = response.html.split('\n').slice(1).join('\n');
 
27
        projectlist.children(".list_empty_indicator").remove()
 
28
        add_section = projectlist.children(".add-project");
 
29
        $(add_section).before(new_element).hide().slideDown();
36
30
    };
37
31
 
38
32
    var data = serializeForm($(this));
49
43
    function callback(xhr) {
50
44
        var response = JSON.parse(xhr.responseText);
51
45
        $('#projectset_list').append(response.html);
52
 
        var projectset_div = $('#projectset_' + response.projectset_id);
53
 
        projectset_div.hide();
54
 
        projectset_div.slideDown();
 
46
        $('#projectset_' + response.projectset_id).hide();
 
47
        $('#projectset_' + response.projectset_id).slideDown();
55
48
        $("#add_projectset").removeAttr('disabled');
56
 
        projectset_div.find(".new_project").submit(add_project);
57
 
        projectset_div.find(".add-project-link").click(show_add);
 
49
        $(".add-project-link").click(show_add);
58
50
    };
59
51
 
60
52
    var data = serializeForm($("#new_projectset_form"));