diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 29df3a60e2..52ba475631 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -393,6 +393,7 @@ return array( 'rsrc/js/application/diffusion/behavior-audit-preview.js' => 'd835b03a', 'rsrc/js/application/diffusion/behavior-commit-branches.js' => 'bdaf4d04', 'rsrc/js/application/diffusion/behavior-commit-graph.js' => '5a0b1a64', + 'rsrc/js/application/diffusion/behavior-diffusion-browse-file.js' => '054a0f0b', 'rsrc/js/application/diffusion/behavior-jump-to.js' => '73d09eef', 'rsrc/js/application/diffusion/behavior-load-blame.js' => '42126667', 'rsrc/js/application/diffusion/behavior-locate-file.js' => '6d3e1947', @@ -606,6 +607,7 @@ return array( 'javelin-behavior-differential-populate' => '8694b1df', 'javelin-behavior-differential-toggle-files' => 'ca3f91eb', 'javelin-behavior-differential-user-select' => 'a8d8459d', + 'javelin-behavior-diffusion-browse-file' => '054a0f0b', 'javelin-behavior-diffusion-commit-branches' => 'bdaf4d04', 'javelin-behavior-diffusion-commit-graph' => '5a0b1a64', 'javelin-behavior-diffusion-jump-to' => '73d09eef', @@ -918,6 +920,12 @@ return array( 'javelin-util', 'javelin-magical-init', ), + '054a0f0b' => array( + 'javelin-behavior', + 'javelin-dom', + 'javelin-util', + 'phabricator-tooltip', + ), '056da01b' => array( 'aphront-typeahead-control-css', 'phui-tag-view-css', diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php index 7616922aa8..1357bed620 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseController.php @@ -1187,6 +1187,19 @@ final class DiffusionBrowseController extends DiffusionController { $commit_links = $this->renderCommitLinks($blame_commits, $handles); $revision_links = $this->renderRevisionLinks($revisions, $handles); + if ($this->coverage) { + require_celerity_resource('differential-changeset-view-css'); + Javelin::initBehavior( + 'diffusion-browse-file', + array( + 'labels' => array( + 'cov-C' => pht('Covered'), + 'cov-N' => pht('Not Covered'), + 'cov-U' => pht('Not Executable'), + ), + )); + } + $skip_text = pht('Skip Past This Commit'); foreach ($display as $line_index => $line) { $row = array(); @@ -1304,7 +1317,6 @@ final class DiffusionBrowseController extends DiffusionController { )); if ($this->coverage) { - require_celerity_resource('differential-changeset-view-css'); $cov_index = $line_index; if (isset($this->coverage[$cov_index])) { diff --git a/webroot/rsrc/js/application/diffusion/behavior-diffusion-browse-file.js b/webroot/rsrc/js/application/diffusion/behavior-diffusion-browse-file.js new file mode 100644 index 0000000000..41ff0cfcc3 --- /dev/null +++ b/webroot/rsrc/js/application/diffusion/behavior-diffusion-browse-file.js @@ -0,0 +1,47 @@ +/** + * @provides javelin-behavior-diffusion-browse-file + * @requires javelin-behavior + * javelin-dom + * javelin-util + * phabricator-tooltip + */ + +JX.behavior('diffusion-browse-file', function(config, statics) { + if (statics.installed) { + return; + } + statics.installed = true; + + var map = config.labels; + + JX.Stratcom.listen( + ['mouseover', 'mouseout'], + ['phabricator-source', 'tag:td'], + function(e) { + var target = e.getTarget(); + + // NOTE: We're using raw classnames instead of sigils and metadata here + // because these elements are unusual: there are a lot of them on the + // page, and rendering all the extra metadata to do this in a normal way + // would be needlessly expensive. This is an unusual case. + + if (!target.className.match(/cov-/)) { + return; + } + + if (e.getType() == 'mouseout') { + JX.Tooltip.hide(); + return; + } + + for (var k in map) { + if (!target.className.match(k)) { + continue; + } + + var label = map[k]; + JX.Tooltip.show(target, 300, 'E', label); + break; + } + }); +});