diff options
author | Sam Rose <sam@gitlab.com> | 2017-03-02 16:43:52 +0300 |
---|---|---|
committer | Sam Rose <sam@gitlab.com> | 2017-03-02 18:48:14 +0300 |
commit | 5f57234c586e33ba12830582c953bad58bddbf8e (patch) | |
tree | d47fc199138283e7c877bac1e36ab5d24bfb98a8 | |
parent | e9d75a4b856513ce848c0a704cced54cff9f48f8 (diff) |
Hightlight linenumber on page load
-rw-r--r-- | app/assets/javascripts/diff.js.es6 | 10 | ||||
-rw-r--r-- | changelogs/unreleased/28893-highlighted-diff-doesn-t-stay-highlighted-on-refresh.yml | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/app/assets/javascripts/diff.js.es6 b/app/assets/javascripts/diff.js.es6 index ccccd0a36ff..6829e8aeaea 100644 --- a/app/assets/javascripts/diff.js.es6 +++ b/app/assets/javascripts/diff.js.es6 @@ -25,6 +25,10 @@ require('./lib/utils/url_utility'); isBound = true; } + if (gl.utils.getLocationHash()) { + this.highlightSelectedLine(); + } + this.openAnchoredDiff(); } @@ -78,7 +82,7 @@ require('./lib/utils/url_utility'); if (nothingHereBlock.length) { const clickTarget = $('.js-file-title, .click-to-expand', diffFile); diffFile.data('singleFileDiff').toggleDiff(clickTarget, () => { - this.highlighSelectedLine(); + this.highlightSelectedLine(); if (cb) cb(); }); } else if (cb) { @@ -94,7 +98,7 @@ require('./lib/utils/url_utility'); } else { window.location.hash = hash; } - this.highlighSelectedLine(); + this.highlightSelectedLine(); } diffViewType() { @@ -108,7 +112,7 @@ require('./lib/utils/url_utility'); return line.find('.diff-line-num').map((i, elm) => parseInt($(elm).data('linenumber'), 10)); } - highlighSelectedLine() { + highlightSelectedLine() { const hash = gl.utils.getLocationHash(); const $diffFiles = $('.diff-file'); $diffFiles.find('.hll').removeClass('hll'); diff --git a/changelogs/unreleased/28893-highlighted-diff-doesn-t-stay-highlighted-on-refresh.yml b/changelogs/unreleased/28893-highlighted-diff-doesn-t-stay-highlighted-on-refresh.yml new file mode 100644 index 00000000000..9ba33af010c --- /dev/null +++ b/changelogs/unreleased/28893-highlighted-diff-doesn-t-stay-highlighted-on-refresh.yml @@ -0,0 +1,4 @@ +--- +title: Highlight line number if specified on diff pages when page loads +merge_request: 9664 +author: |