diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-06-24 15:10:49 +0600 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-06-24 15:10:49 +0600 |
commit | 7786875492ed5bbdcf689d7516d0b82dbdf1aea6 (patch) | |
tree | 314ef605faade65b9e6992e60cd45101cfd47a47 | |
parent | 73310191a864d23d40c836aee6c796280c8aa1ed (diff) | |
download | sonarqube-7786875492ed5bbdcf689d7516d0b82dbdf1aea6.tar.gz sonarqube-7786875492ed5bbdcf689d7516d0b82dbdf1aea6.zip |
SONAR-5209 Scrolling
4 files changed, 31 insertions, 4 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) -> diff --git a/sonar-server/src/main/hbs/component-viewer/duplicationPopup.hbs b/sonar-server/src/main/hbs/component-viewer/duplicationPopup.hbs index 0e17055d67c..0098740c9ec 100644 --- a/sonar-server/src/main/hbs/component-viewer/duplicationPopup.hbs +++ b/sonar-server/src/main/hbs/component-viewer/duplicationPopup.hbs @@ -9,7 +9,7 @@ <div class="component-viewer-popup-duplications"> Lines: {{#joinEach blocks ','}} - <a class="link-action" data-key="{{../file.key}}"> + <a class="link-action" data-key="{{../file.key}}" data-line="{{from}}"> {{from}} – {{sum from size}} </a> {{/joinEach}} |