diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 9853c35217..6c1240fea0 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -385,7 +385,6 @@ return array( 'rsrc/js/application/diffusion/behavior-commit-branches.js' => 'bdaf4d04', 'rsrc/js/application/diffusion/behavior-commit-graph.js' => '75b83cbb', 'rsrc/js/application/diffusion/behavior-diffusion-browse-file.js' => '054a0f0b', - 'rsrc/js/application/diffusion/behavior-jump-to.js' => '73d09eef', 'rsrc/js/application/diffusion/behavior-locate-file.js' => '6d3e1947', 'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'f01586dc', 'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '1db13e70', @@ -471,7 +470,7 @@ return array( 'rsrc/js/core/behavior-keyboard-pager.js' => 'a8da01f0', 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '01fca1f0', 'rsrc/js/core/behavior-lightbox-attachments.js' => '6b31879a', - 'rsrc/js/core/behavior-line-linker.js' => '36165eb1', + 'rsrc/js/core/behavior-line-linker.js' => '66a62306', 'rsrc/js/core/behavior-more.js' => 'a80d0378', 'rsrc/js/core/behavior-object-selector.js' => '77c1f0b0', 'rsrc/js/core/behavior-oncopy.js' => '2926fff2', @@ -601,7 +600,6 @@ return array( 'javelin-behavior-diffusion-browse-file' => '054a0f0b', 'javelin-behavior-diffusion-commit-branches' => 'bdaf4d04', 'javelin-behavior-diffusion-commit-graph' => '75b83cbb', - 'javelin-behavior-diffusion-jump-to' => '73d09eef', 'javelin-behavior-diffusion-locate-file' => '6d3e1947', 'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc', 'javelin-behavior-document-engine' => '0333c0b6', @@ -634,7 +632,7 @@ return array( 'javelin-behavior-phabricator-gesture-example' => '558829c2', 'javelin-behavior-phabricator-keyboard-pager' => 'a8da01f0', 'javelin-behavior-phabricator-keyboard-shortcuts' => '01fca1f0', - 'javelin-behavior-phabricator-line-linker' => '36165eb1', + 'javelin-behavior-phabricator-line-linker' => '66a62306', 'javelin-behavior-phabricator-nav' => '94b7c320', 'javelin-behavior-phabricator-notification-example' => '8ce821c5', 'javelin-behavior-phabricator-object-selector' => '77c1f0b0', @@ -1098,12 +1096,6 @@ return array( 'javelin-dom', 'javelin-vector', ), - '36165eb1' => array( - 'javelin-behavior', - 'javelin-stratcom', - 'javelin-dom', - 'javelin-history', - ), '3ab51e2c' => array( 'javelin-behavior', 'javelin-behavior-device', @@ -1395,6 +1387,12 @@ return array( 'phabricator-darklog', 'phabricator-darkmessage', ), + '66a62306' => array( + 'javelin-behavior', + 'javelin-stratcom', + 'javelin-dom', + 'javelin-history', + ), '66a6def1' => array( 'javelin-behavior', 'javelin-dom', @@ -1471,11 +1469,6 @@ return array( 'javelin-behavior', 'javelin-dom', ), - '73d09eef' => array( - 'javelin-behavior', - 'javelin-vector', - 'javelin-dom', - ), '758b4758' => array( 'javelin-install', 'javelin-workboard-card', diff --git a/src/view/layout/PhabricatorSourceCodeView.php b/src/view/layout/PhabricatorSourceCodeView.php index eec571e5f3..19126d1c6a 100644 --- a/src/view/layout/PhabricatorSourceCodeView.php +++ b/src/view/layout/PhabricatorSourceCodeView.php @@ -96,10 +96,15 @@ final class PhabricatorSourceCodeView extends AphrontView { } $base_uri = (string)$this->uri; + $wrote_anchor = false; foreach ($lines as $line) { $row_attributes = array(); if (isset($this->highlights[$line_number])) { $row_attributes['class'] = 'phabricator-source-highlight'; + if (!$wrote_anchor) { + $row_attributes['id'] = 'phabricator-line-linker-anchor'; + $wrote_anchor = true; + } } if ($this->canClickHighlight) { diff --git a/webroot/rsrc/js/application/diffusion/behavior-jump-to.js b/webroot/rsrc/js/application/diffusion/behavior-jump-to.js deleted file mode 100644 index 96b4947e02..0000000000 --- a/webroot/rsrc/js/application/diffusion/behavior-jump-to.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @provides javelin-behavior-diffusion-jump-to - * @requires javelin-behavior - * javelin-vector - * javelin-dom - */ - -JX.behavior('diffusion-jump-to', function(config) { - - setTimeout(function() { - var pos = JX.Vector.getPosWithScroll(JX.$(config.target)); - JX.DOM.scrollToPosition(0, pos.y - 100); - }, 0); - -}); diff --git a/webroot/rsrc/js/core/behavior-line-linker.js b/webroot/rsrc/js/core/behavior-line-linker.js index c2aec18d8b..8cb3d0c615 100644 --- a/webroot/rsrc/js/core/behavior-line-linker.js +++ b/webroot/rsrc/js/core/behavior-line-linker.js @@ -176,4 +176,16 @@ JX.behavior('phabricator-line-linker', function() { } }); + + // Try to jump to the highlighted lines if we don't have an explicit anchor + // in the URI. + if (!window.location.hash.length) { + try { + var anchor = JX.$('phabricator-line-linker-anchor'); + JX.DOM.scrollToPosition(0, JX.$V(anchor).y - 60); + } catch (ex) { + // If we didn't hit an element on the page, just move on. + } + } + });