epic-s6ts
[kivitendo-erp.git] / js / autocomplete_chart.js
index 6e389cf..c3d4cbd 100644 (file)
@@ -14,6 +14,9 @@ namespace('kivi', function(k){
       RIGHT:  39,
       PAGE_UP: 33,
       PAGE_DOWN: 34,
+      SHIFT:     16,
+      CTRL:      17,
+      ALT:       18,
     };
     var CLASSES = {
       PICKED:       'chartpicker-picked',
@@ -96,7 +99,6 @@ namespace('kivi', function(k){
       state = STATES.PICKED;
       last_real = $real.val();
       last_dummy = $dummy.val();
-      last_unverified_dummy = $dummy.val();
       $real.trigger('change');
 
       if (o.fat_set_item && item.id) {
@@ -120,7 +122,6 @@ namespace('kivi', function(k){
       } else if (state == STATES.UNDEFINED && $dummy.val() === '')
         set_item({})
       else {
-        last_unverified_dummy = $dummy.val();
         set_item({ id: last_real, name: last_dummy })
       }
       annotate_state();
@@ -132,7 +133,6 @@ namespace('kivi', function(k){
       else if (state == STATES.UNDEFINED && $dummy.val() === '')
         $dummy.removeClass(STATES.UNDEFINED).addClass(STATES.PICKED);
       else {
-        last_unverified_dummy = $dummy.val();
         $dummy.addClass(STATES.UNDEFINED).removeClass(STATES.PICKED);
       }
     }
@@ -200,6 +200,10 @@ namespace('kivi', function(k){
       select: function(event, ui) {
         set_item(ui.item);
       },
+      search: function(event, ui) {
+        if ((event.which == KEY.SHIFT) || (event.which == KEY.CTRL) || (event.which == KEY.ALT))
+          event.preventDefault();
+      }
     });
     /*  In case users are impatient and want to skip ahead:
      *  Capture <enter> key events and check if it's a unique hit.
@@ -233,7 +237,7 @@ namespace('kivi', function(k){
           });
           return false;
         }
-      } else {
+      } else if ((event.which != KEY.SHIFT) && (event.which != KEY.CTRL) && (event.which != KEY.ALT)) {
         state = STATES.UNDEFINED;
       }
     });
@@ -250,11 +254,9 @@ namespace('kivi', function(k){
     });
 
     // now add a picker div after the original input
-    var pcont  = $('<span>').addClass('position-absolute');
-    var picker = $('<div>');
-    $dummy.after(pcont);
-    pcont.append(picker);
-    picker.addClass('icon16 search').click(open_dialog);
+    var popup_button = $('<span>').addClass('cpc_popup_button');
+    $dummy.after(popup_button);
+    popup_button.click(open_dialog);
 
     var cp = {
       real:           function() { return $real },