| 10 |
10 |
$(link).closest(".fields").hide();
|
| 11 |
11 |
}
|
| 12 |
12 |
|
| 13 |
|
$(".author_name_on_paper").live('keyup.autocomplete', function(){
|
| 14 |
|
$this = $(this);
|
|
13 |
function authorship_autocomplete(url){
|
|
14 |
$(".author_name_on_paper").live('keyup.autocomplete', function(){
|
|
15 |
$this = $(this);
|
| 15 |
16 |
|
| 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);
|
|
17 |
$this.autocomplete({
|
|
18 |
source: url,
|
|
19 |
minLength: 2,
|
|
20 |
focus: function(event, ui) {
|
|
21 |
$this.val(ui.item.label);
|
|
22 |
return false;
|
|
23 |
},
|
|
24 |
select: function(event, ui){
|
|
25 |
$this.closest('div').find("input[id$='institution']").val(ui.item.institution);
|
|
26 |
$this.closest('div').find("input[id$='email']").val(ui.item.email);
|
| 26 |
27 |
|
| 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);
|
|
28 |
$this.closest('div').find("input[id$='search_author_class']").val(ui.item. search_author_class);
|
|
29 |
$this.closest('div').find("input[id$='search_author_id']").val(ui.item. search_author_id);
|
| 29 |
30 |
|
| 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);
|
|
31 |
$this.closest('div').find("input[id$='search_author_tie']").attr('checked', ' checked');
|
|
32 |
$this.closest('div').find("input[id$='search_author_tie']").next('span'). replaceWith(ui.item.authorship_link);
|
| 32 |
33 |
|
| 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 |
|
|
|
34 |
// triggers the save button
|
|
35 |
$this.closest('div').next('div').find('.author_save_btn').click();
|
|
36 |
}
|
|
37 |
})
|
|
38 |
.data( "autocomplete" )._renderItem = function( ul, item ) {
|
|
39 |
return $( "<li>" )
|
|
40 |
.data("item.autocomplete", item )
|
|
41 |
.append( "<a>" + item.label + "<br><em>" + item.email + "</em><br>" + item. institution + "</a>" )
|
|
42 |
.appendTo(ul);
|
|
43 |
};
|
|
44 |
});
|
|
45 |
}
|