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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-12-08 23:45:39 UTC
  • mto: This revision was merged to the branch mainline in revision 1384.
  • Revision ID: grantw@unimelb.edu.au-20091208234539-rtge6krc4uab0ccc
Remove ProjectRESTView, which did nothing and was unused.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
$(document).ready(function(){
 
2
    $("#new_projectset_form").submit(add_projectset);
 
3
    $(".new_project").submit(add_project);
 
4
    $('li').show();
 
5
    $('.add-project-link').click(show_add);
 
6
    $('.add-projectset-link').click(show_add);
 
7
});
 
8
 
 
9
function serializeForm(form){
 
10
 
 
11
    mylist = form.serializeArray();
 
12
    var data = {};
 
13
    for (var i = 0; i < mylist.length; i++){
 
14
        data[mylist[i].name] = mylist[i].value;
 
15
    }
 
16
    return data;
 
17
 
 
18
};
 
19
 
 
20
function add_project(){
 
21
 
 
22
    $(this).slideToggle('fast');
 
23
    
 
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();
 
31
    };
 
32
 
 
33
    var data = serializeForm($(this));
 
34
 
 
35
    ajax_call(callback, $(this).attr("action"), "", data, 'POST');
 
36
 
 
37
    return false;
 
38
};
 
39
 
 
40
function add_projectset(){
 
41
 
 
42
    $("#add_projectset").attr('disabled', 'disabled');
 
43
 
 
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);
 
53
    };
 
54
 
 
55
    var data = serializeForm($("#new_projectset_form"));
 
56
 
 
57
    data['ivle.op'] = 'add_projectset';
 
58
 
 
59
    ajax_call(callback, $("#new_projectset_form").attr("action"), "", data, 
 
60
            'POST');
 
61
 
 
62
    return false;
 
63
};
 
64
 
 
65
function show_add(){
 
66
    $(this).next().slideToggle();
 
67
    return false;
 
68
}