Explorar el Código

HUE-5139 [metadata] Delete search words on ctrl + backspace

Johan Ahlen hace 9 años
padre
commit
9b9eafd
Se han modificado 1 ficheros con 16 adiciones y 0 borrados
  1. 16 0
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

+ 16 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -77,6 +77,22 @@
         });
         });
       }
       }
 
 
+      $element.on('keydown', function (e) {
+        // ctrl + backspace to delete words
+        if (e.which === 8 && e.ctrlKey) {
+          var lastSpaceOrColon = Math.max($element.val().lastIndexOf(' '), $element.val().lastIndexOf(':'));
+          if (lastSpaceOrColon < $element.val().length - 1) {
+            if (lastSpaceOrColon !== -1) {
+              $element.val($element.val().substring(0, lastSpaceOrColon + 1));
+            } else {
+              $element.val('');
+            }
+            e.preventDefault();
+            return false;
+          }
+        }
+      });
+
       if (options.showOnFocus) {
       if (options.showOnFocus) {
         $element.on('focus', function () {
         $element.on('focus', function () {
           $element.hueAutocomplete('search', $element.val());
           $element.hueAutocomplete('search', $element.val());