diff plugins/redmine_bibliography/assets/javascripts/authors.js @ 1288:7e89ba7fac48 redmine-2.2-integration

adds focus to autocomplete.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Sat, 18 May 2013 13:41:32 +0100
parents d0d6bbe9f2e0
children 7fa299909144
line wrap: on
line diff
--- 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 $( "<li></li>" )
+                .data( "item.autocomplete", item )
+                .append( "<a>" + item.institution + "</a>" )
+                .appendTo( ul );
+            };
+        });