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 @ 1313:17f075c7fd41

History | View | Annotate | Download (2.96 KB)

1
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
}
11

    
12
function remove_fields(link) {
13
  $(link).prev("input[type=hidden]").val("1");
14
  $(link).closest(".fields").hide();
15
}
16

    
17
$(".author_search").live('keyup.autocomplete', function(){
18
     $this = $(this);
19

    
20
     $this.autocomplete({
21
        source: '/publications/autocomplete_for_author',
22
        minLength: 2,
23
        focus: function(event, ui) {
24
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
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
        select: function(event, ui){
33
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
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
            $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
        }
39
        })
40
        .data( "autocomplete" )._renderItem = function( ul, item ) {
41
            return $( "<li></li>" )
42
                .data( "item.autocomplete", item )
43
                .append( "<a>" + item.label + "</a>" )
44
                .appendTo( ul );
45
            };
46
        });
47

    
48

    
49
$("input[id$='identify_author_yes']").live("click", function() {
50
    console.log("aaaa");
51
});
52

    
53
$("input[id$='identify_author_no']").live("click", function() {
54
    $this.closest('div').next().find("input[id$='name_on_paper']").val('');
55
    $this.closest('div').next().find("input[id$='institution']").val('');
56
    $this.closest('div').next().find("input[id$='email']").val('');
57
    $this.closest('div').next().find("input[id$='search_author_class']").val('');
58
});
59

    
60
function toggle_div(div_id){
61
    $("#" + div_id).toggle(0.3);
62
}
63

    
64
function toggle_save_author(form_object_id, $this){
65
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) {
66
        toggle_input_field(s, $this);
67
    });
68
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('p.description').each(function(s) {
69
        s.toggle();
70
    });
71
    toggle_edit_save_button(form_object_id);
72
    toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
73
}