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 @ 1394:0f918e37e1d6

History | View | Annotate | Download (1.59 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 469:ae87ae455cfb luis
}
7
8 1278:f8bb7ccc6fac luis
function remove_fields(link) {
9
  $(link).prev("input[type=hidden]").val("1");
10
  $(link).closest(".fields").hide();
11 481:dd242ea99fd3 luis
}
12
13 1394:0f918e37e1d6 luis
$(".author_name_on_paper").live('keyup.autocomplete', function(){
14 1284:3ce07a57ce68 luis
     $this = $(this);
15
16
     $this.autocomplete({
17 1282:8d30e7644b75 luis
        source: '/publications/autocomplete_for_author',
18 1283:006057cf8f16 luis
        minLength: 2,
19 1288:7e89ba7fac48 luis
        focus: function(event, ui) {
20 1393:67abd7b08753 luis
            $this.val(ui.item.label);
21 1288:7e89ba7fac48 luis
            return false;
22
        },
23 1283:006057cf8f16 luis
        select: function(event, ui){
24 1394:0f918e37e1d6 luis
            $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
            $this.closest('div').find("input[id$='search_author_tie']").attr('checked', 'checked');
30
31
32
33
            // triggers the save button
34
            $this.closest('div').next('div').find('.author_save_btn').click();
35 1283:006057cf8f16 luis
        }
36 1288:7e89ba7fac48 luis
        })
37
        .data( "autocomplete" )._renderItem = function( ul, item ) {
38 1393:67abd7b08753 luis
            return $( "<li>" )
39
                .data("item.autocomplete", item )
40
                .append( "<a>" + item.label + "<br><em>" + item.email + "</em><br>" + item.intitution + "</a>" )
41
                .appendTo(ul);
42 1288:7e89ba7fac48 luis
            };
43
        });