diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-10-05 13:12:26 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-10-05 21:03:27 +0300 |
commit | 9a26120c718be30f956b972174e1fccffa711acb (patch) | |
tree | f9247408c6a977ed307e376641cadbb58aa118a8 /app | |
parent | b4963a75df298574dd3b65ee89f4e99c33d71520 (diff) |
Fix anchors to comments in diffs
Diffstat (limited to 'app')
-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() |