[PATCH conductor] BZ#781604 Fix inconsistent Search behaviour on Enter keypress

tsedovic at redhat.com tsedovic at redhat.com
Wed Feb 1 16:29:42 UTC 2012


From: Tomas Sedovic <tomas at sedovic.cz>

https://bugzilla.redhat.com/show_bug.cgi?id=781604

If a form has more than one submit button, it's left to the implementation
which one is going to be pressed on Enter.

It should come to no surprise to anyone that IE's behaviour is different from
all the major browsers.

This adds a little JavaScript piece that makes sure the proper button is
clicked when the user presses Enter in the search fields.
---
 src/app/views/catalogs/_list.html.haml          |    1 +
 src/app/views/catalogs/show.html.haml           |    1 +
 src/app/views/deployables/_list.html.haml       |    1 +
 src/app/views/deployments/_list.html.haml       |    1 +
 src/app/views/hardware_profiles/_list.html.haml |    1 +
 src/app/views/instances/_list.html.haml         |    1 +
 src/app/views/pools/_list.html.haml             |    1 +
 src/app/views/provider_accounts/_list.html.haml |    1 +
 src/app/views/provider_realms/_list.html.haml   |    1 +
 src/app/views/realms/_list.html.haml            |    1 +
 src/app/views/users/_list.html.haml             |    1 +
 src/public/javascripts/application.js           |    9 +++++++++
 12 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/app/views/catalogs/_list.html.haml b/src/app/views/catalogs/_list.html.haml
index bb278f8..4a8a462 100644
--- a/src/app/views/catalogs/_list.html.haml
+++ b/src/app/views/catalogs/_list.html.haml
@@ -20,6 +20,7 @@
       $("#catalogs_preset_filter").change(function() {
         $("#apply_catalogs_preset_filter").click();
       });
+      Conductor.clickOnEnterKeypress($('#catalogs_search'), $('#apply_catalogs_search'));
     });
 
 = filter_table(@header, @catalogs) do |catalog|
diff --git a/src/app/views/catalogs/show.html.haml b/src/app/views/catalogs/show.html.haml
index 09e742a..b633c6d 100644
--- a/src/app/views/catalogs/show.html.haml
+++ b/src/app/views/catalogs/show.html.haml
@@ -43,6 +43,7 @@
           $("#deployables_preset_filter").change(function() {
             $("#apply_deployables_preset_filter").click();
           });
+          Conductor.clickOnEnterKeypress($('#deployables_search'), $('#apply_deployables_search'));
         });
 
     = filter_table(@header, @deployables) do |deployable|
diff --git a/src/app/views/deployables/_list.html.haml b/src/app/views/deployables/_list.html.haml
index b5336ee..776be28 100644
--- a/src/app/views/deployables/_list.html.haml
+++ b/src/app/views/deployables/_list.html.haml
@@ -23,6 +23,7 @@
           $("#catalog_entries_preset_filter").change(function() {
             $("#apply_catalog_entries_preset_filter").click();
           });
+          Conductor.clickOnEnterKeypress($('#catalog_entries_search'), $('#apply_catalog_entries_search'));
         });
 
     = filter_table(@header, @deployables) do |deployable|
diff --git a/src/app/views/deployments/_list.html.haml b/src/app/views/deployments/_list.html.haml
index d2177ac..b2e7109 100644
--- a/src/app/views/deployments/_list.html.haml
+++ b/src/app/views/deployments/_list.html.haml
@@ -23,6 +23,7 @@
       $("#deployments_preset_filter").change(function() {
         $("#apply_deployments_preset_filter").click();
       });
+      Conductor.clickOnEnterKeypress($('#deployments_search'), $('#apply_deployments_search'));
     });
 
 = filter_table(@deployments_header, @deployments) do |deployment|
diff --git a/src/app/views/hardware_profiles/_list.html.haml b/src/app/views/hardware_profiles/_list.html.haml
index 9a84444..138fef9 100644
--- a/src/app/views/hardware_profiles/_list.html.haml
+++ b/src/app/views/hardware_profiles/_list.html.haml
@@ -20,6 +20,7 @@
       $("#hardware_profiles_preset_filter").change(function() {
         $("#apply_hardware_profiles_preset_filter").click();
       });
+      Conductor.clickOnEnterKeypress($('#hardware_profiles_search'), $('#apply_hardware_profiles_search'));
     });
 
 = filter_table(hardware_profiles_header, @hardware_profiles) do |hwp|
diff --git a/src/app/views/instances/_list.html.haml b/src/app/views/instances/_list.html.haml
index f254659..e120e68 100644
--- a/src/app/views/instances/_list.html.haml
+++ b/src/app/views/instances/_list.html.haml
@@ -21,6 +21,7 @@
       $("#instances_preset_filter").change(function() {
         $("#apply_instances_preset_filter").click();
       });
+      Conductor.clickOnEnterKeypress($('#instances_search'), $('#apply_instances_search'));
     });
 
 = filter_table(instances_header, @instances) do |instance|
diff --git a/src/app/views/pools/_list.html.haml b/src/app/views/pools/_list.html.haml
index adc0304..274a0b3 100644
--- a/src/app/views/pools/_list.html.haml
+++ b/src/app/views/pools/_list.html.haml
@@ -20,6 +20,7 @@
       $("#pools_preset_filter").change(function() {
         $("#apply_pools_preset_filter").click();
       });
+      Conductor.clickOnEnterKeypress($('#pools_search'), $('#apply_pools_search'));
     });
 
 = filter_table(@header, @pools) do |pool|
diff --git a/src/app/views/provider_accounts/_list.html.haml b/src/app/views/provider_accounts/_list.html.haml
index 2430a04..3f4753e 100644
--- a/src/app/views/provider_accounts/_list.html.haml
+++ b/src/app/views/provider_accounts/_list.html.haml
@@ -20,6 +20,7 @@
         $("#provider_accounts_preset_filter").change(function() {
           $("#apply_provider_accounts_preset_filter").click();
         });
+        Conductor.clickOnEnterKeypress($('#provider_accounts_search'), $('#apply_provider_accounts_search'));
       });
 
   = filter_table(provider_accounts_header, @provider_accounts) do |account|
diff --git a/src/app/views/provider_realms/_list.html.haml b/src/app/views/provider_realms/_list.html.haml
index b88054e..82d3732 100644
--- a/src/app/views/provider_realms/_list.html.haml
+++ b/src/app/views/provider_realms/_list.html.haml
@@ -15,6 +15,7 @@
       $("#provider_realms_preset_filter").change(function() {
         $("#apply_provider_realms_preset_filter").click();
       });
+      Conductor.clickOnEnterKeypress($('#provider_realms_search'), $('#apply_provider_realms_search'));
     });
 
 = filter_table(provider_realms_header, @realms) do |realm|
diff --git a/src/app/views/realms/_list.html.haml b/src/app/views/realms/_list.html.haml
index 1ee3ee8..70d12ab 100644
--- a/src/app/views/realms/_list.html.haml
+++ b/src/app/views/realms/_list.html.haml
@@ -23,6 +23,7 @@
       $("#realms_preset_filter").change(function() {
         $("#apply_realms_preset_filter").click();
       });
+      Conductor.clickOnEnterKeypress($('#realms_search'), $('#apply_realms_search'));
     });
 
 = filter_table(realms_header, @realms) do |realm|
diff --git a/src/app/views/users/_list.html.haml b/src/app/views/users/_list.html.haml
index d320e40..decfe2b 100644
--- a/src/app/views/users/_list.html.haml
+++ b/src/app/views/users/_list.html.haml
@@ -31,6 +31,7 @@
       $("#users_preset_filter").change(function() {
         $("#apply_users_preset_filter").click();
       });
+      Conductor.clickOnEnterKeypress($('#users_search'), $('#apply_users_search'));
     });
 
 = filter_table(@header, @users) do |user|
diff --git a/src/public/javascripts/application.js b/src/public/javascripts/application.js
index a3dd4a7..6cef5c2 100644
--- a/src/public/javascripts/application.js
+++ b/src/public/javascripts/application.js
@@ -256,6 +256,15 @@ $.extend(Conductor, {
     });
   },
 
+  clickOnEnterKeypress: function($textField, $button) {
+    $textField.live('keypress', function(e) {
+      if((e.keyCode || e.which) == 13) {
+        e.preventDefault();
+        $button.click();
+      }
+    });
+  },
+
   fetchAjaxDescription: function(selector_box, description_field, base_url) {
     selector_box.live("change", function(e) {
       var realm_id = $(e.target).val();
-- 
1.7.6.5




More information about the aeolus-devel mailing list