]> source.dussan.org Git - sonarqube.git/commitdiff
Fix navigation between issues in a big file
authorStas Vilchik <vilchiks@gmail.com>
Fri, 19 Dec 2014 08:47:52 +0000 (09:47 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 19 Dec 2014 08:47:52 +0000 (09:47 +0100)
server/sonar-web/src/main/coffee/issues/component-viewer/main.coffee

index 2b0be2c80b30f31df8b0a823e3beb92734e66537..e3833ee254133d2115226d5777c4f53031d0e5e8 100644 (file)
@@ -91,7 +91,7 @@ define [
       selected = @options.app.state.get 'selectedIndex'
       selectedIssue = @options.app.issues.at selected
       if selectedIssue.get('component') == @model.get('key')
-        @scrollToLine selectedIssue.get('line')
+        @scrollToIssue selectedIssue.get('key')
       else
         @unbindShortcuts()
         @options.app.controller.showComponentViewer selectedIssue
@@ -116,14 +116,8 @@ define [
     scrollToIssue: (key) ->
       el = @$("#issue-#{key}")
       if el.length > 0
-        viewTop = el.offset().top
-        viewBottom = viewTop + el.outerHeight()
-        windowTop = $(window).scrollTop()
-        windowBottom = windowTop + $(window).height()
-        if viewTop < windowTop
-          $(window).scrollTop viewTop - TOP_OFFSET
-        if viewBottom > windowBottom
-          $(window).scrollTop $(window).scrollTop() - windowBottom + viewBottom + BOTTOM_OFFSET
+        line = el.closest('[data-line-number]').data 'line-number'
+        this.scrollToLine line
       else
         @unbindShortcuts()
         selected = @options.app.state.get 'selectedIndex'