]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5165 It should be possible to use up and down arrows to navigate through result...
authorStas Vilchik <vilchiks@gmail.com>
Thu, 3 Apr 2014 11:14:29 +0000 (17:14 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 3 Apr 2014 11:14:29 +0000 (17:14 +0600)
Enable for coding rules

sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-view.coffee
sonar-server/src/main/js/issues/extra.js

index 93db305b2b54935d46259cf642efdaf222d580fc..c91beba027eb37709c6d218623e28a473027ded4 100644 (file)
@@ -19,5 +19,46 @@ define [
       listView: @, app: @options.app
 
 
+    initialize: ->
+      openRule = (el) -> el.click()
+      @openRule = _.debounce openRule, 300
+      key.setScope 'list'
+
+
+    onRender: ->
+      key 'up', 'list', => @selectPrev()
+      key 'down', 'list', => @selectNext()
+
+
+    selectIssue: (el, open) ->
+      @$('.active').removeClass 'active'
+      el.addClass 'active'
+      @openRule el if open
+
+
     selectFirst: ->
-      @$el.find('*:first').click()
+      @selected = -1
+      @selectNext()
+
+
+    selectNext: ->
+      if @selected < @collection.length - 1
+        @selected++
+        child = @$el.children().eq @selected
+        container = jQuery('.navigator-results')
+        containerHeight = container.height()
+        bottom = child.position().top + child.outerHeight()
+        if bottom > containerHeight
+          container.scrollTop(container.scrollTop() - containerHeight + bottom)
+        @selectIssue child, true
+
+
+    selectPrev: ->
+      if @selected > 0
+        @selected--
+        child = @$el.children().eq @selected
+        container = jQuery('.navigator-results')
+        top = child.position().top
+        if top < 0
+          container.scrollTop(container.scrollTop() + top)
+        @selectIssue child, true
\ No newline at end of file
index a291721ed9cd175ac4228d4285a0b99641b1ea86..0cf04865b0efa8a20fecf271d6ea9f876f82d1bb 100644 (file)
@@ -246,7 +246,7 @@ define(
 
         initialize: function() {
           var openIssue = function(el) { el.click(); };
-          this.openIssue = _.debounce(openIssue, 300);
+          this.openRule = _.debounce(openIssue, 300);
         },
 
 
@@ -262,7 +262,7 @@ define(
           this.$('.active').removeClass('active');
           el.addClass('active');
           if (open) {
-            this.openIssue(el);
+            this.openRule(el);
           }
         },