]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5599 Scroll down to the selected rule when coming from the issue drilldown...
authorStas Vilchik <vilchiks@gmail.com>
Tue, 7 Oct 2014 13:49:17 +0000 (15:49 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 7 Oct 2014 13:49:24 +0000 (15:49 +0200)
server/sonar-web/src/main/coffee/component-viewer/header/issues-header.coffee

index b765c2f3cc4bb39c80502190f7026eb2e898f872..9da852a2ffa56d9e7d10c41160edfca6add15c2c 100644 (file)
@@ -103,6 +103,7 @@ define [
       rule = $(e.currentTarget).data 'rule'
       @header.filterLines e, 'filterByRule', rule
       @state.set 'activeHeaderItem', ".js-filter-rule[data-rule='#{rule}']"
+      setTimeout (=> @scrollToRule rule), 0
 
 
     filterByBlockerIssues: (e) ->
@@ -135,6 +136,14 @@ define [
       @state.set 'activeHeaderItem', '.js-filter-INFO-issues'
 
 
+    scrollToRule: (rule) ->
+      ruleEl = @$('.js-filter-rule').filter("[data-rule=\"#{rule}\"]")
+      container = ruleEl.closest '.component-viewer-header-expanded-bar-section-list'
+      topOffset = ruleEl.offset().top - container.offset().top
+      if topOffset > container.height()
+        container.scrollTop topOffset
+
+
     serializeData: ->
       _.extend super,
         period: @state.get('period')?.toJSON()