# HG changeset patch # User luisf # Date 1368880892 -3600 # Node ID 7e89ba7fac48663266534688fa77bb93fe9f302f # Parent 1c3e2fb6793a4f8afac44900dfed147ce7692687 adds focus to autocomplete. diff -r 1c3e2fb6793a -r 7e89ba7fac48 plugins/redmine_bibliography/assets/javascripts/authors.js --- a/plugins/redmine_bibliography/assets/javascripts/authors.js Fri May 17 17:45:36 2013 +0100 +++ b/plugins/redmine_bibliography/assets/javascripts/authors.js Sat May 18 13:41:32 2013 +0100 @@ -20,6 +20,15 @@ $this.autocomplete({ source: '/publications/autocomplete_for_author', minLength: 2, + focus: function(event, ui) { + $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value); + $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution); + $this.closest('div').next().find("input[id$='email']").val(ui.item.email); + $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class); + $this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id); + + return false; + }, select: function(event, ui){ $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value); $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution); @@ -27,8 +36,14 @@ $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class); $this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id); } - }); -}); + }) + .data( "autocomplete" )._renderItem = function( ul, item ) { + return $( "
  • " ) + .data( "item.autocomplete", item ) + .append( "" + item.institution + "" ) + .appendTo( ul ); + }; + });