diff options
| author | Phil Hughes <me@iamphill.com> | 2016-04-11 13:19:55 +0100 |
|---|---|---|
| committer | Phil Hughes <me@iamphill.com> | 2016-04-14 11:29:19 +0100 |
| commit | 8a8d4c9bf27d17939bfce4b53287210d8108da2c (patch) | |
| tree | d0845938aa0d20f37fb041ceb5474cd086522d82 /app/assets/javascripts | |
| parent | c71cdb194f6b30997826929190eaee70f762848a (diff) | |
| download | gitlab-ce-8a8d4c9bf27d17939bfce4b53287210d8108da2c.tar.gz | |
Diff viewer links to correct part of the file
Added highlight colours to diff rows
Closes #13852
Diffstat (limited to 'app/assets/javascripts')
| -rw-r--r-- | app/assets/javascripts/merge_request_tabs.js.coffee | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/app/assets/javascripts/merge_request_tabs.js.coffee b/app/assets/javascripts/merge_request_tabs.js.coffee index ef0b534a709..d45c772b8de 100644 --- a/app/assets/javascripts/merge_request_tabs.js.coffee +++ b/app/assets/javascripts/merge_request_tabs.js.coffee @@ -85,8 +85,11 @@ class @MergeRequestTabs scrollToElement: (container) -> if window.location.hash - $el = $("div#{container} #{window.location.hash}") - $('body').scrollTo($el.offset().top) if $el.length + navBarHeight = $('.navbar-gitlab').outerHeight() + + $el = $("#{container} #{window.location.hash}") + $('body').scrollTo 0 + $.scrollTo("#{container} #{window.location.hash}", offset: -navBarHeight) if $el.length # Activate a tab based on the current action activateTab: (action) -> @@ -152,12 +155,29 @@ class @MergeRequestTabs @_get url: "#{source}.json" + @_location.search success: (data) => - document.querySelector("div#diffs").innerHTML = data.html + $('#diffs').html data.html gl.utils.localTimeAgo($('.js-timeago', 'div#diffs')) - $('div#diffs .js-syntax-highlight').syntaxHighlight() + $('#diffs .js-syntax-highlight').syntaxHighlight() @expandViewContainer() if @diffViewType() is 'parallel' @diffsLoaded = true @scrollToElement("#diffs") + @highlighSelectedLine() + + highlighSelectedLine: -> + locationHash = location.hash + + if locationHash isnt '' + hashClassString = ".#{locationHash.replace('#', '')}" + $diffLine = $(locationHash) + + if $diffLine.is ':not(tr)' + $diffLine = $("td#{locationHash}, td#{hashClassString}") + else + $diffLine = $('td', $diffLine) + + $diffLine.addClass 'hll' + diffLineTop = $diffLine.offset().top + navBarHeight = $('.navbar-gitlab').outerHeight() loadBuilds: (source) -> return if @buildsLoaded |
