From c2d1e374b4f8a2b4802ea6348539da7ec10a227a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 3 Jul 2013 19:55:26 +0200 Subject: [PATCH] mehr code nach js/ verlagert --- js/autocomplete_part.js | 34 +++++++++++++++---- .../webpages/part/_part_picker_result.html | 11 +----- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/js/autocomplete_part.js b/js/autocomplete_part.js index 66123e8af..61280fd93 100644 --- a/js/autocomplete_part.js +++ b/js/autocomplete_part.js @@ -78,6 +78,10 @@ namespace('kivi', function(k){ }); }; + function close_popup() { + $('#part_selection').jqmClose() + }; + $dummy.autocomplete({ source: function(req, rsp) { $.ajax($.extend(o, { @@ -145,13 +149,31 @@ namespace('kivi', function(k){ picker.addClass('icon16 CRM--Schnellsuche').click(open_dialog); return { - real: function() { return $real }, - dummy: function() { return $dummy }, - type: function() { return $type }, - column: function() { return $column }, + real: function() { return $real }, + dummy: function() { return $dummy }, + type: function() { return $type }, + column: function() { return $column }, update_results: update_results, - set_item: set_item, - reset: make_defined_state, + set_item: set_item, + reset: make_defined_state, + init_results: function () { + $('div.part_picker_part').each(function(){ + $(this).click(function(){ + set_item({ + name: $(this).children('input.part_picker_description').val(), + id: $(this).children('input.part_picker_id').val(), + }); + close_popup(); + return true; + }); + }); + $('#part_selection').keypress(function(e){ + if (e.keyCode == 27) { // escape + close_popup(); + $dummy.focus(); + } + }); + } } } }); diff --git a/templates/webpages/part/_part_picker_result.html b/templates/webpages/part/_part_picker_result.html index c6a814335..0512b49ad 100644 --- a/templates/webpages/part/_part_picker_result.html +++ b/templates/webpages/part/_part_picker_result.html @@ -27,14 +27,5 @@ -- 2.20.1