diff options
Diffstat (limited to 'sonar-server/src/main/coffee/component-viewer')
3 files changed, 30 insertions, 3 deletions
diff --git a/sonar-server/src/main/coffee/component-viewer/duplication-popup.coffee b/sonar-server/src/main/coffee/component-viewer/duplication-popup.coffee index f8cd287028b..784f875795b 100644 --- a/sonar-server/src/main/coffee/component-viewer/duplication-popup.coffee +++ b/sonar-server/src/main/coffee/component-viewer/duplication-popup.coffee @@ -23,6 +23,7 @@ define [ goToFile: (e) -> key = $(e.currentTarget).data 'key' + line = $(e.currentTarget).data 'line' return if key == @options.main.component.get 'key' files = @options.main.source.get('duplicationFiles') @options.main.addTransition 'duplication', @collection.map (item) -> @@ -33,6 +34,9 @@ define [ subname: x.dir active: file.key == key @options.main._open key + @options.main.on 'sized', => + @options.main.off 'sized' + @options.main.scrollToLine line serializeData: -> diff --git a/sonar-server/src/main/coffee/component-viewer/main.coffee b/sonar-server/src/main/coffee/component-viewer/main.coffee index 71c5147bdf3..e5271366e03 100644 --- a/sonar-server/src/main/coffee/component-viewer/main.coffee +++ b/sonar-server/src/main/coffee/component-viewer/main.coffee @@ -62,6 +62,8 @@ define [ TESTS_METRIC_LIST = 'tests,test_success_density,test_failures,test_errors,skipped_tests,test_execution_time' + SCROLL_OFFSET = 10 + class ComponentViewer extends utils.mixOf Marionette.Layout, IssuesMixin, CoverageMixin, DuplicationsMixin, SCMMixin @@ -227,7 +229,11 @@ define [ @state.set 'hasSource', (source.status != 404) @render() @showAllLines() if showFullSource - if @settings.get('issues') then @showIssues() else @hideIssues() + if @settings.get('issues') + @showIssues() + else + @hideIssues() + @trigger 'sized' if @settings.get('coverage') then @showCoverage() else @hideCoverage() if @settings.get('duplications') then @showDuplications() else @hideDuplications() if @settings.get('scm') then @showSCM() else @hideSCM() @@ -285,4 +291,17 @@ define [ component: @component.toJSON() transition: transition options: options - active: false
\ No newline at end of file + active: false + + + scrollToLine: (line) -> + @scrolled = line + row = @sourceView.$(".row[data-line-number=#{line}]") + return unless row.length > 0 + d = row.offset().top - @$el.offset().top - SCROLL_OFFSET + @scrollPlusDelta d + + + scrollPlusDelta: (delta) -> + parent = @$el.scrollParent() + parent.scrollTop delta
\ No newline at end of file diff --git a/sonar-server/src/main/coffee/component-viewer/mixins/main-issues.coffee b/sonar-server/src/main/coffee/component-viewer/mixins/main-issues.coffee index eb3fdcd007a..0ac15af4560 100644 --- a/sonar-server/src/main/coffee/component-viewer/mixins/main-issues.coffee +++ b/sonar-server/src/main/coffee/component-viewer/mixins/main-issues.coffee @@ -32,11 +32,15 @@ define [ @source.set 'issues', [issue] @filterByCurrentIssue() @headerView.render() + @trigger 'sized' else unless @state.get 'hasIssues' - @requestIssues(@key).done => @sourceView.render() + @requestIssues(@key).done => + @sourceView.render() + @trigger 'sized' else @sourceView.render() + @trigger 'sized' hideIssues: (store = false) -> |