To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / plugins / redmine_bibliography / assets / javascripts / authors.js @ 1281:e9bfba17e791

History | View | Annotate | Download (2.29 KB)

1 1278:f8bb7ccc6fac luis
function add_author_fields(link, association, content, action) {
2
    var new_id = new Date().getTime();
3
    var regexp = new RegExp("new_" + association, "g");
4
5
    $(link).before(content.replace(regexp, new_id));
6
7
    if(action != "new"){
8
        toggle_save_author(new_id, $(link));
9
    }
10 469:ae87ae455cfb luis
}
11
12 1278:f8bb7ccc6fac luis
function remove_fields(link) {
13
  $(link).prev("input[type=hidden]").val("1");
14
  $(link).closest(".fields").hide();
15 481:dd242ea99fd3 luis
}
16
17 1281:e9bfba17e791 luis
$(".author_search").live('keyup.autocomplete', function(){
18
    $this = $(this);
19
20
    $.ajax({
21
        type: "POST",
22
        url: "/publications/autocomplete_for_author",
23
        dataType: "json",
24
        data: {
25
            q: $this.val()
26
        },
27
28
        success: function(data, type) {
29
            console.log("OK: " + data);
30
            items = data;
31
            response(items);
32
        },
33
34
        error: function(data, type){
35
            console.log("ERROR: " + type);
36
        }
37
    });
38
});
39
40
41 600:c3c1091639ad luis
function identify_author_status(status, object_id) {
42 623:a434a588f16c chris
    $('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) {
43
        if(status == "no"){
44
            s.value = "";
45
            s.readOnly = false;
46
        };
47 1277:99fe7b784587 luis
48 623:a434a588f16c chris
        if(status == "correct"){s.readOnly = false;};
49
        if(status == "yes"){s.readOnly = true;};
50
    });
51 600:c3c1091639ad luis
}
52 603:7b39f35803f3 luis
53 1277:99fe7b784587 luis
function toggle_div(div_id){
54 623:a434a588f16c chris
    Effect.toggle(div_id, "appear", {duration:0.3});
55 603:7b39f35803f3 luis
}
56
57 1277:99fe7b784587 luis
function toggle_input_field(field){
58 623:a434a588f16c chris
    if (field.classNames().inspect().include("readonly") == false){
59 1277:99fe7b784587 luis
                        field.readOnly = true;
60 675:fccacd8505e3 luis
                        field.addClassName('readonly');
61 623:a434a588f16c chris
    } else {
62 675:fccacd8505e3 luis
                        field.readOnly = false;
63
                        field.removeClassName('readonly');
64 1277:99fe7b784587 luis
    };
65 603:7b39f35803f3 luis
}
66
67 605:8fc59e8ddd63 luis
function toggle_edit_save_button(object_id){
68 623:a434a588f16c chris
    $button = $('publication_authorships_attributes_' + object_id + '_edit_save_button');
69
    if ($button.value == "Edit author"){
70
        $button.value = "Save author";
71
    } else {
72
        $button.value = "Edit author";
73
    };
74 605:8fc59e8ddd63 luis
}
75
76
function toggle_save_author(form_object_id, $this){
77 623:a434a588f16c chris
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) {
78
        toggle_input_field(s, $this);
79
    });
80 624:11c8e189f8fc chris
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('p.description').each(function(s) {
81 623:a434a588f16c chris
        s.toggle();
82
    });
83
    toggle_edit_save_button(form_object_id);
84
    toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
85 1277:99fe7b784587 luis
}