diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-10-05 13:12:26 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-10-05 14:00:41 +0300 |
commit | 31330e4a3c7d21e4a86b86fd0f199a857d777a3b (patch) | |
tree | 1dc65ccbb8d69591453424c0c3fa9c270c682b98 /app/assets/javascripts/merge_request_tabs.js.coffee | |
parent | 0de7c83a78711601b40b5a739070da2e3af29b11 (diff) |
Fix anchors to comments in diffs
Diffstat (limited to 'app/assets/javascripts/merge_request_tabs.js.coffee')
-rw-r--r-- | app/assets/javascripts/merge_request_tabs.js.coffee | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/assets/javascripts/merge_request_tabs.js.coffee b/app/assets/javascripts/merge_request_tabs.js.coffee index 19a07b6a033..4e56791bde4 100644 --- a/app/assets/javascripts/merge_request_tabs.js.coffee +++ b/app/assets/javascripts/merge_request_tabs.js.coffee @@ -66,6 +66,11 @@ class @MergeRequestTabs @setCurrentAction(action) + scrollToElement: (container) -> + if window.location.hash + top = $(container + " " + window.location.hash).offset().top + $('body').scrollTo(top); + # Activate a tab based on the current action activateTab: (action) -> action = 'notes' if action == 'show' @@ -122,6 +127,7 @@ class @MergeRequestTabs document.getElementById('commits').innerHTML = data.html $('.js-timeago').timeago() @commitsLoaded = true + @scrollToElement(".commits") loadDiff: (source) -> return if @diffsLoaded @@ -131,6 +137,7 @@ class @MergeRequestTabs success: (data) => document.getElementById('diffs').innerHTML = data.html @diffsLoaded = true + @scrollToElement(".diffs") toggleLoading: -> $('.mr-loading-status .loading').toggle() |