mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 21:40:55 +01:00
Make line selection in source code views less fragile and more consistent
Summary: Depends on D19347. Ref T13105. See PHI565. The "highlight lines" behavior is interacting poorly with the new blame element in Diffusion. Make the behavior a little simpler and hopefully more robust. Test Plan: - Clicked commit/revision links in Diffusion, saw the links get followed instead of the lines highlighted. - Highlighted lines in Diffusion, saw just the line/code highlight instead of the whole thing. - Highlighted lines in Paste and new-style Harbormaster build logs, saw consistent behavior. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13105 Differential Revision: https://secure.phabricator.com/D19348
This commit is contained in:
parent
ac570fd4bc
commit
c5c53e277a
3 changed files with 25 additions and 35 deletions
|
@ -119,7 +119,7 @@ return array(
|
|||
'rsrc/css/font/font-lato.css' => 'c7ccd872',
|
||||
'rsrc/css/font/phui-font-icon-base.css' => '870a7360',
|
||||
'rsrc/css/layout/phabricator-filetree-view.css' => 'b912ad97',
|
||||
'rsrc/css/layout/phabricator-source-code-view.css' => '326df52d',
|
||||
'rsrc/css/layout/phabricator-source-code-view.css' => 'c5edc888',
|
||||
'rsrc/css/phui/button/phui-button-bar.css' => 'f1ff5494',
|
||||
'rsrc/css/phui/button/phui-button-simple.css' => '8e1baf68',
|
||||
'rsrc/css/phui/button/phui-button.css' => '1863cc6e',
|
||||
|
@ -471,7 +471,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' => '1e017314',
|
||||
'rsrc/js/core/behavior-line-linker.js' => '69837bed',
|
||||
'rsrc/js/core/behavior-more.js' => 'a80d0378',
|
||||
'rsrc/js/core/behavior-object-selector.js' => '77c1f0b0',
|
||||
'rsrc/js/core/behavior-oncopy.js' => '2926fff2',
|
||||
|
@ -634,7 +634,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' => '1e017314',
|
||||
'javelin-behavior-phabricator-line-linker' => '69837bed',
|
||||
'javelin-behavior-phabricator-nav' => '94b7c320',
|
||||
'javelin-behavior-phabricator-notification-example' => '8ce821c5',
|
||||
'javelin-behavior-phabricator-object-selector' => '77c1f0b0',
|
||||
|
@ -780,7 +780,7 @@ return array(
|
|||
'phabricator-search-results-css' => '505dd8cf',
|
||||
'phabricator-shaped-request' => '7cbe244b',
|
||||
'phabricator-slowvote-css' => 'a94b7230',
|
||||
'phabricator-source-code-view-css' => '326df52d',
|
||||
'phabricator-source-code-view-css' => 'c5edc888',
|
||||
'phabricator-standard-page-view' => '34ee718b',
|
||||
'phabricator-textareautils' => '320810c8',
|
||||
'phabricator-title' => '485aaa6c',
|
||||
|
@ -1003,12 +1003,6 @@ return array(
|
|||
'javelin-workflow',
|
||||
'javelin-magical-init',
|
||||
),
|
||||
'1e017314' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
'javelin-history',
|
||||
),
|
||||
'1f6794f6' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
|
@ -1413,6 +1407,12 @@ return array(
|
|||
'javelin-dom',
|
||||
'phuix-button-view',
|
||||
),
|
||||
'69837bed' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
'javelin-history',
|
||||
),
|
||||
'69adf288' => array(
|
||||
'javelin-install',
|
||||
),
|
||||
|
|
|
@ -52,10 +52,14 @@ th.phabricator-source-line a:hover {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
.phabricator-source-highlight {
|
||||
.phabricator-source-highlight .phabricator-source-code {
|
||||
background: {$paste.highlight};
|
||||
}
|
||||
|
||||
.phabricator-source-highlight .phabricator-source-line {
|
||||
background: {$paste.border};
|
||||
}
|
||||
|
||||
.phabricator-source-code-summary {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
|
|
@ -19,24 +19,7 @@ JX.behavior('phabricator-line-linker', function() {
|
|||
// Ignore.
|
||||
}
|
||||
|
||||
function getRowNumber(tr) {
|
||||
// Starting from the left, find the rightmost "<th />" tag among all
|
||||
// "<th />" tags at the start of the row. Our goal here is to skip over
|
||||
// blame information in Diffusion. This could probably be significantly
|
||||
// more graceful.
|
||||
var th = null;
|
||||
for (var ii = 0; ii < tr.childNodes.length; ii++) {
|
||||
if (JX.DOM.isType(tr.childNodes[ii], 'th')) {
|
||||
th = tr.childNodes[ii];
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!th) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function getRowNumber(th) {
|
||||
// If the "<th />" tag contains an "<a />" with "data-n" that we're using
|
||||
// to prevent copy/paste of line numbers, use that.
|
||||
if (th.firstChild) {
|
||||
|
@ -51,7 +34,7 @@ JX.behavior('phabricator-line-linker', function() {
|
|||
|
||||
JX.Stratcom.listen(
|
||||
['click', 'mousedown'],
|
||||
['phabricator-source', 'tag:tr', 'tag:th', 'tag:a'],
|
||||
['phabricator-source', 'tag:th', 'tag:a'],
|
||||
function(e) {
|
||||
if (!e.isNormalMouseEvent()) {
|
||||
return;
|
||||
|
@ -62,13 +45,13 @@ JX.behavior('phabricator-line-linker', function() {
|
|||
// table. The row's immediate ancestor table needs to be the table with
|
||||
// the "phabricator-source" sigil.
|
||||
|
||||
var row = e.getNode('tag:tr');
|
||||
var cell = e.getNode('tag:th');
|
||||
var table = e.getNode('phabricator-source');
|
||||
if (JX.DOM.findAbove(row, 'table') !== table) {
|
||||
if (JX.DOM.findAbove(cell, 'table') !== table) {
|
||||
return;
|
||||
}
|
||||
|
||||
var number = getRowNumber(row);
|
||||
var number = getRowNumber(cell);
|
||||
if (!number) {
|
||||
return;
|
||||
}
|
||||
|
@ -81,7 +64,7 @@ JX.behavior('phabricator-line-linker', function() {
|
|||
return;
|
||||
}
|
||||
|
||||
origin = row;
|
||||
origin = cell;
|
||||
target = origin;
|
||||
|
||||
root = table;
|
||||
|
@ -95,7 +78,7 @@ JX.behavior('phabricator-line-linker', function() {
|
|||
if (e.getNode('phabricator-source') !== root) {
|
||||
return;
|
||||
}
|
||||
target = e.getNode('tag:tr');
|
||||
target = e.getNode('tag:th');
|
||||
|
||||
var min;
|
||||
var max;
|
||||
|
@ -130,6 +113,9 @@ JX.behavior('phabricator-line-linker', function() {
|
|||
highlighted = [];
|
||||
|
||||
// Highlight the newly selected rows.
|
||||
min = JX.DOM.findAbove(min, 'tr');
|
||||
max = JX.DOM.findAbove(max, 'tr');
|
||||
|
||||
var cursor = min;
|
||||
while (true) {
|
||||
JX.DOM.alterClass(cursor, 'phabricator-source-highlight', true);
|
||||
|
|
Loading…
Reference in a new issue