diff options
author | Annabel Dunstone Gray <annabel.dunstone@gmail.com> | 2017-03-02 23:02:35 +0300 |
---|---|---|
committer | Annabel Dunstone Gray <annabel.dunstone@gmail.com> | 2017-03-02 23:02:35 +0300 |
commit | 42c8eec913f2fef99dd69f28baa63ebc8cdd6dac (patch) | |
tree | 0ad4898438de06a856aa4d961521ea0455795b40 | |
parent | a7ff87f459e607a63bfe31845e331d50c92339be (diff) | |
parent | 5f57234c586e33ba12830582c953bad58bddbf8e (diff) |
Merge branch '28893-highlighted-diff-doesn-t-stay-highlighted-on-refresh' into 'master'
Hightlight linenumber on page load
Closes #28893
See merge request !9664
-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: |