]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5167 It should be possible to use "Tab" to navigate in the new search forms
authorStas Vilchik <vilchiks@gmail.com>
Thu, 3 Apr 2014 12:27:14 +0000 (18:27 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 3 Apr 2014 12:27:22 +0000 (18:27 +0600)
sonar-server/src/main/js/navigator/filters/ajax-select-filters.js
sonar-server/src/main/js/navigator/filters/base-filters.js
sonar-server/src/main/js/navigator/filters/filter-bar.js
sonar-server/src/main/js/navigator/filters/metric-filters.js
sonar-server/src/main/js/navigator/filters/more-criteria-filters.js

index dd2e246d217986f99bfc5f24f7745083b4614452..0f6c130e347b37fa9dc234c48d4203624f04b854 100644 (file)
@@ -100,7 +100,7 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/choice-
 
       var that = this,
           keyup = function(e) {
-            if (e.keyCode !== 38 && e.keyCode !== 40) {
+            if (e.keyCode !== 37 && e.keyCode !== 38 && e.keyCode !== 39 && e.keyCode !== 40) {
               that.search();
             }
           },
@@ -162,7 +162,7 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/choice-
 
 
     keydown: function(e) {
-      if (_([37, 38, 39, 40, 13]).indexOf(e.keyCode) !== -1) {
+      if (_([38, 40, 13]).indexOf(e.keyCode) !== -1) {
         e.preventDefault();
       }
     },
index 8699c601f448b334a2d8a909d8d95715136eb0dc..09cccd3f8b8ce0cef6e343166d9cf5966d6347b5 100644 (file)
@@ -110,11 +110,12 @@ define(['backbone', 'backbone.marionette', 'common/handlebars-extensions'], func
 
     toggleDetails: function(e) {
       e.stopPropagation();
+      this.options.filterBarView.selected = this.options.filterBarView.getEnabledFilters().index(this.$el);
       if (this.$el.hasClass('active')) {
         key.setScope('list');
         this.hideDetails();
       } else {
-        key.setScope('filter');
+        key.setScope('filters');
         this.showDetails();
       }
     },
index a859c721382c80b61c98118da99a3311b2413267..6f98ba5b05809f795d23c0d2dc8b96b7bd6dd10e 100644 (file)
@@ -39,6 +39,60 @@ define(
             that.hideDetails();
           });
           this.addMoreCriteriaFilter();
+
+          key.filter = function(e) {
+            var el = jQuery(e.target),
+                tabbableSet = el.closest('.navigator-filter-details-inner').find(':tabbable');
+            return tabbableSet.index(el) >= tabbableSet.length - 1;
+          };
+          key('f', function() {
+            key.setScope('filters');
+            that.selectFirst();
+            return false;
+          });
+          key('shift+tab', 'filters', function() {
+            that.selectPrev();
+            return false;
+          });
+          key('tab', 'filters', function() {
+            that.selectNext();
+            return false;
+          });
+        },
+
+
+        getEnabledFilters: function() {
+          return this.$(this.itemViewContainer).children()
+              .not('.navigator-filter-disabled')
+              .not('.navigator-filter-inactive')
+              .not('.navigator-filter-favorite');
+        },
+
+
+        selectFirst: function() {
+          this.selected = -1;
+          this.selectNext();
+        },
+
+
+        selectPrev: function() {
+          var filters = this.getEnabledFilters();
+          if (this.selected > 0) {
+            this.selected--;
+            filters.eq(this.selected).click();
+          }
+        },
+
+
+        selectNext: function() {
+          var filters = this.getEnabledFilters();
+          if (this.selected < filters.length - 1) {
+            this.selected++;
+            filters.eq(this.selected).click();
+          } else {
+            this.hideDetails();
+            this.$('.navigator-filter-submit').focus();
+          }
         },
 
 
index f680d0e06e14678d1a4e860559818dd3b7fcd572..cac789dc4aaea58f52df2bd7d14dbc3e7bbf1064 100644 (file)
@@ -66,9 +66,7 @@ define(['navigator/filters/base-filters', 'common/handlebars-extensions'], funct
 
     onShow: function() {
       var select = this.$('[name=metric]');
-      if (!select.val()) {
-        select.select2('open');
-      }
+      select.select2('open');
     }
 
   });
index 755c4bbfb42b17ba31a7ff2dd24827bcd42c8f27..a1b2887ebf1ead846443d7194c49f25f367cad46 100644 (file)
@@ -1,6 +1,6 @@
 define(['navigator/filters/base-filters', 'navigator/filters/choice-filters', 'common/handlebars-extensions'], function (BaseFilters, ChoiceFilters) {
 
-  var DetailsMoreCriteriaFilterView = BaseFilters.DetailsFilterView.extend({
+  var DetailsMoreCriteriaFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
     template: getTemplate('#more-criteria-details-filter-template'),
 
 
@@ -13,6 +13,7 @@ define(['navigator/filters/base-filters', 'navigator/filters/choice-filters', 'c
       var id = $j(e.target).data('id');
       this.model.view.options.filterBarView.enableFilter(id);
       this.model.view.hideDetails();
+      this.updateCurrent(0);
     },