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 @ 1288:7e89ba7fac48

History | View | Annotate | Download (3.45 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 1284:3ce07a57ce68 luis
     $this = $(this);
19
20
     $this.autocomplete({
21 1282:8d30e7644b75 luis
        source: '/publications/autocomplete_for_author',
22 1283:006057cf8f16 luis
        minLength: 2,
23 1288:7e89ba7fac48 luis
        focus: function(event, ui) {
24
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value);
25
            $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
26
            $this.closest('div').next().find("input[id$='email']").val(ui.item.email);
27
            $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
28
            $this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id);
29
30
            return false;
31
        },
32 1283:006057cf8f16 luis
        select: function(event, ui){
33 1284:3ce07a57ce68 luis
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value);
34
            $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
35
            $this.closest('div').next().find("input[id$='email']").val(ui.item.email);
36 1286:d0d6bbe9f2e0 luis
            $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
37
            $this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id);
38 1283:006057cf8f16 luis
        }
39 1288:7e89ba7fac48 luis
        })
40
        .data( "autocomplete" )._renderItem = function( ul, item ) {
41
            return $( "<li></li>" )
42
                .data( "item.autocomplete", item )
43
                .append( "<a>" + item.institution + "</a>" )
44
                .appendTo( ul );
45
            };
46
        });
47 1281:e9bfba17e791 luis
48 1284:3ce07a57ce68 luis
49
50
51 600:c3c1091639ad luis
function identify_author_status(status, object_id) {
52 623:a434a588f16c chris
    $('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) {
53 1277:99fe7b784587 luis
54 1284:3ce07a57ce68 luis
        if(status == "no"){
55
            s.value = "";
56
            s.readOnly = false;
57
        }
58
59
        if(status == "correct"){
60
            s.readOnly = false;
61
        }
62
        if(status == "yes"){
63
            s.readOnly = true;
64
        }
65 623:a434a588f16c chris
    });
66 600:c3c1091639ad luis
}
67 603:7b39f35803f3 luis
68 1277:99fe7b784587 luis
function toggle_div(div_id){
69 1284:3ce07a57ce68 luis
    $("#" + div_id).toggle(0.3);
70 603:7b39f35803f3 luis
}
71
72 1277:99fe7b784587 luis
function toggle_input_field(field){
73 1284:3ce07a57ce68 luis
    if (field.classNames().inspect().include("readonly") === false){
74 1277:99fe7b784587 luis
                        field.readOnly = true;
75 675:fccacd8505e3 luis
                        field.addClassName('readonly');
76 623:a434a588f16c chris
    } else {
77 675:fccacd8505e3 luis
                        field.readOnly = false;
78
                        field.removeClassName('readonly');
79 1284:3ce07a57ce68 luis
    }
80 603:7b39f35803f3 luis
}
81
82 605:8fc59e8ddd63 luis
function toggle_edit_save_button(object_id){
83 623:a434a588f16c chris
    $button = $('publication_authorships_attributes_' + object_id + '_edit_save_button');
84
    if ($button.value == "Edit author"){
85 1286:d0d6bbe9f2e0 luis
        $button.value = "Save author";
86 623:a434a588f16c chris
    } else {
87 1286:d0d6bbe9f2e0 luis
        $button.value = "Edit author";
88
    }
89 605:8fc59e8ddd63 luis
}
90
91
function toggle_save_author(form_object_id, $this){
92 623:a434a588f16c chris
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) {
93
        toggle_input_field(s, $this);
94
    });
95 624:11c8e189f8fc chris
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('p.description').each(function(s) {
96 623:a434a588f16c chris
        s.toggle();
97
    });
98
    toggle_edit_save_button(form_object_id);
99
    toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
100 1277:99fe7b784587 luis
}