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 @ 1408:b09744f35f76

History | View | Annotate | Download (1.71 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

    
8
function remove_fields(link) {
9
  $(link).prev("input[type=hidden]").val("1");
10
  $(link).closest(".fields").hide();
11
}
12

    
13
$(".author_name_on_paper").live('keyup.autocomplete', function(){
14
     $this = $(this);
15

    
16
     $this.autocomplete({
17
        source: '/publications/autocomplete_for_author',
18
        minLength: 2,
19
        focus: function(event, ui) {
20
            $this.val(ui.item.label);
21
            return false;
22
        },
23
        select: function(event, ui){
24
            $this.closest('div').find("input[id$='institution']").val(ui.item.institution);
25
            $this.closest('div').find("input[id$='email']").val(ui.item.email);
26

    
27
            $this.closest('div').find("input[id$='search_author_class']").val(ui.item.search_author_class);
28
            $this.closest('div').find("input[id$='search_author_id']").val(ui.item.search_author_id);
29

    
30
            $this.closest('div').find("input[id$='search_author_tie']").attr('checked', 'checked');
31
            $this.closest('div').find("input[id$='search_author_tie']").next('span').replaceWith(ui.item.authorship_link);
32

    
33
            // triggers the save button
34
            $this.closest('div').next('div').find('.author_save_btn').click();
35
        }
36
        })
37
        .data( "autocomplete" )._renderItem = function( ul, item ) {
38
            return $( "<li>" )
39
                .data("item.autocomplete", item )
40
                .append( "<a>" + item.label + "<br><em>" + item.email + "</em><br>" + item.institution + "</a>" )
41
                .appendTo(ul);
42
            };
43
        });
44