summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-04-12 09:07:20 +0100
committerPhil Hughes <me@iamphill.com>2016-04-14 11:29:19 +0100
commitf3ed4763f54ee46a50d2e7b3b894f895b4067b61 (patch)
tree13387857f9d9427515525b4cc86b8b27da29be31
parent8a8d4c9bf27d17939bfce4b53287210d8108da2c (diff)
downloadgitlab-ce-f3ed4763f54ee46a50d2e7b3b894f895b4067b61.tar.gz
Correctly scrolls to the line when clicking
-rw-r--r--app/assets/javascripts/merge_request_tabs.js.coffee12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/assets/javascripts/merge_request_tabs.js.coffee b/app/assets/javascripts/merge_request_tabs.js.coffee
index d45c772b8de..316d1fefa5a 100644
--- a/app/assets/javascripts/merge_request_tabs.js.coffee
+++ b/app/assets/javascripts/merge_request_tabs.js.coffee
@@ -88,7 +88,6 @@ class @MergeRequestTabs
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
@@ -163,8 +162,17 @@ class @MergeRequestTabs
@scrollToElement("#diffs")
@highlighSelectedLine()
+ $(document)
+ .off 'click', '.diff-content a'
+ .on 'click', '.diff-content a', (e) =>
+ e.preventDefault()
+ window.location.hash = $(e.currentTarget).attr 'href'
+ @highlighSelectedLine()
+ @scrollToElement("#diffs")
+
highlighSelectedLine: ->
- locationHash = location.hash
+ $('.hll').removeClass 'hll'
+ locationHash = window.location.hash
if locationHash isnt ''
hashClassString = ".#{locationHash.replace('#', '')}"