To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / plugins / redmine_bibliography / assets / javascripts / authors.js @ 1432:ebda59ca84db
History | View | Annotate | Download (1.85 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 | 1409:3cb633d4b37d | luis | function authorship_autocomplete(url){ |
| 14 | $(".author_name_on_paper").live('keyup.autocomplete', function(){ |
||
| 15 | $this = $(this); |
||
| 16 | 1284:3ce07a57ce68 | luis | |
| 17 | 1409:3cb633d4b37d | luis | $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); |
||
| 27 | 1394:0f918e37e1d6 | luis | |
| 28 | 1409:3cb633d4b37d | luis | $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); |
||
| 30 | 1407:00a51e442fe9 | luis | |
| 31 | 1409:3cb633d4b37d | luis | $this.closest('div').find("input[id$='search_author_tie']").attr('checked', ' checked'); |
| 32 | 1427:2599a11ef11a | luis | $this.closest('div').find("input[id$='search_author_tie']").next('span').replaceWith("<span>" + ui.item.authorship_link + "</span>"); |
| 33 | 1394:0f918e37e1d6 | luis | |
| 34 | 1409:3cb633d4b37d | luis | // 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 | } |