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 @ 1403:35732ac4324a
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 | // triggers the save button
|
||
| 32 | $this.closest('div').next('div').find('.author_save_btn').click(); |
||
| 33 | 1283:006057cf8f16 | luis | } |
| 34 | 1288:7e89ba7fac48 | luis | }) |
| 35 | .data( "autocomplete" )._renderItem = function( ul, item ) { |
||
| 36 | 1393:67abd7b08753 | luis | return $( "<li>" ) |
| 37 | .data("item.autocomplete", item )
|
||
| 38 | 1403:35732ac4324a | luis | .append( "<a>" + item.label + "<br><em>" + item.email + "</em><br>" + item.institution + "</a>" ) |
| 39 | 1393:67abd7b08753 | luis | .appendTo(ul); |
| 40 | 1288:7e89ba7fac48 | luis | }; |
| 41 | }); |