aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/coffee
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2014-04-03 17:14:29 +0600
committerStas Vilchik <vilchiks@gmail.com>2014-04-03 17:14:29 +0600
commitf5c17aba00cd5e775c9144f6f0e6eefc2a8f3d9d (patch)
treed40f8c294c5ef59547a9fffc6a6d085b680a8900 /sonar-server/src/main/coffee
parent54cfa65a7340b9f53384401f562c9b302dc17094 (diff)
downloadsonarqube-f5c17aba00cd5e775c9144f6f0e6eefc2a8f3d9d.tar.gz
sonarqube-f5c17aba00cd5e775c9144f6f0e6eefc2a8f3d9d.zip
SONAR-5165 It should be possible to use up and down arrows to navigate through results in Issues page
Enable for coding rules
Diffstat (limited to 'sonar-server/src/main/coffee')
-rw-r--r--sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-view.coffee43
1 files changed, 42 insertions, 1 deletions
diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-view.coffee
index 93db305b2b5..c91beba027e 100644
--- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-view.coffee
+++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-view.coffee
@@ -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