Pārlūkot izejas kodu

HUE-4624 [editor] Doing enter in the query result search box could go to the next match

Enrico Berti 9 gadi atpakaļ
vecāks
revīzija
48fa31b90c

+ 10 - 6
desktop/core/src/desktop/static/desktop/js/jquery.delayedinput.js

@@ -24,7 +24,8 @@
   var pluginName = "jHueDelayedInput",
       defaults = {
         fn: null,
-        timeout: 300
+        timeout: 300,
+        skipOnEnter: false
       };
 
   function Plugin(element, options) {
@@ -43,17 +44,20 @@
     var _this = this;
     var _timeout = -1;
     if (_this.options.fn != null) {
-      $(_this.element).on("keyup", function () {
-        window.clearTimeout(_timeout);
-        _timeout = window.setTimeout(_this.options.fn, _this.options.timeout);
+      $(_this.element).on("keyup", function (e) {
+        if (!(_this.options.skipOnEnter && e.keyCode == 13)){
+          window.clearTimeout(_timeout);
+          _timeout = window.setTimeout(_this.options.fn, _this.options.timeout);
+        }
       });
     }
   };
 
-  $.fn[pluginName] = function (fn, timeout) {
+  $.fn[pluginName] = function (fn, timeout, skipOnEnter) {
     var _options = {
       fn: fn,
-      timeout: timeout
+      timeout: timeout,
+      skipOnEnter: typeof skipOnEnter !== 'undefined' && skipOnEnter
     }
     return this.each(function () {
       if (!$.data(this, 'plugin_' + pluginName)) {

+ 10 - 1
desktop/core/src/desktop/static/desktop/js/jquery.huedatatable.js

@@ -114,7 +114,16 @@
 
         search.find('input').jHueDelayedInput(function () {
           self.fnSearch(search.find('input').val());
-        }, 300);
+        }, 300, true);
+
+        search.find('input').keydown(function(e){
+          if(e.keyCode == 13) {
+            e.preventDefault();
+            e.stopPropagation();
+            e.stopImmediatePropagation();
+            search.find('.fa-chevron-down').trigger('click');
+          }
+        });
 
         search.find('input').focus();
       }