From 4850400289ff68f69432d0f717ba36cfa3149c30 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 4 Apr 2014 13:38:03 +0600 Subject: [PATCH] SONAR-5167 It should be possible to use "Tab" to navigate in the new search forms --- sonar-server/src/main/js/measures/app.js | 1 + .../js/navigator/filters/choice-filters.js | 3 ++- .../main/js/navigator/filters/filter-bar.js | 18 ++++++++++++++++-- .../navigator/filters/more-criteria-filters.js | 5 +++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sonar-server/src/main/js/measures/app.js b/sonar-server/src/main/js/measures/app.js index 830a6cf4eb4..96623fccfeb 100644 --- a/sonar-server/src/main/js/measures/app.js +++ b/sonar-server/src/main/js/measures/app.js @@ -191,5 +191,6 @@ requirejs( if (window.queryParams) { NavigatorApp.filterBarView.restoreFromQuery(window.queryParams); } + key.setScope('list'); }); diff --git a/sonar-server/src/main/js/navigator/filters/choice-filters.js b/sonar-server/src/main/js/navigator/filters/choice-filters.js index cf74a21562e..ecc8ba6f4e9 100644 --- a/sonar-server/src/main/js/navigator/filters/choice-filters.js +++ b/sonar-server/src/main/js/navigator/filters/choice-filters.js @@ -163,7 +163,8 @@ define(['handlebars', 'navigator/filters/base-filters', 'common/handlebars-exten selectCurrent: function() { - this.$('label').eq(this.currentChoice).click(); + var cb = this.$('input[type=checkbox]').eq(this.currentChoice); + cb.prop('checked', !cb.prop('checked')).trigger('change'); }, diff --git a/sonar-server/src/main/js/navigator/filters/filter-bar.js b/sonar-server/src/main/js/navigator/filters/filter-bar.js index 6f98ba5b058..300646c5650 100644 --- a/sonar-server/src/main/js/navigator/filters/filter-bar.js +++ b/sonar-server/src/main/js/navigator/filters/filter-bar.js @@ -43,9 +43,17 @@ define( 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; + if (el.is(':input')) { + if (e.keyCode === 9 || e.keyCode === 27) { + return tabbableSet.index(el) >= tabbableSet.length - 1; + } else { + return false; + } + } else { + return true; + } }; - key('f', function() { + key('tab', 'list', function() { key.setScope('filters'); that.selectFirst(); return false; @@ -58,6 +66,11 @@ define( that.selectNext(); return false; }); + key('escape', 'filters', function() { + that.hideDetails(); + this.selected = -1; + key.setScope('list'); + }); }, @@ -90,6 +103,7 @@ define( this.selected++; filters.eq(this.selected).click(); } else { + this.selected = filters.length; this.hideDetails(); this.$('.navigator-filter-submit').focus(); } diff --git a/sonar-server/src/main/js/navigator/filters/more-criteria-filters.js b/sonar-server/src/main/js/navigator/filters/more-criteria-filters.js index a1b2887ebf1..3bfed0fe484 100644 --- a/sonar-server/src/main/js/navigator/filters/more-criteria-filters.js +++ b/sonar-server/src/main/js/navigator/filters/more-criteria-filters.js @@ -17,6 +17,11 @@ define(['navigator/filters/base-filters', 'navigator/filters/choice-filters', 'c }, + selectCurrent: function() { + this.$('label').eq(this.currentChoice).click(); + }, + + serializeData: function() { var filters = this.model.get('filters').map(function(filter) { return _.extend(filter.toJSON(), { id: filter.cid }); -- 2.39.5