From 5f57234c586e33ba12830582c953bad58bddbf8e Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Thu, 2 Mar 2017 08:43:52 -0500 Subject: Hightlight linenumber on page load --- app/assets/javascripts/diff.js.es6 | 10 +++++++--- ...93-highlighted-diff-doesn-t-stay-highlighted-on-refresh.yml | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/28893-highlighted-diff-doesn-t-stay-highlighted-on-refresh.yml 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: -- cgit v1.2.1