@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move the "select a line range" inline code to DiffInline

Summary: Ref T12616. This makes line range selection use the new code, and removes the remainder of the old "hover a line number" / "select a line range" code.

Test Plan: Hovered line numbers; selected line ranges.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12616

Differential Revision: https://secure.phabricator.com/D17927

+167 -245
+16 -26
resources/celerity/map.php
··· 10 10 'conpherence.pkg.css' => 'ff161f2d', 11 11 'conpherence.pkg.js' => 'b5b51108', 12 12 'core.pkg.css' => 'ee5f28cd', 13 - 'core.pkg.js' => '8c5f913d', 13 + 'core.pkg.js' => '0f87a6eb', 14 14 'darkconsole.pkg.js' => '1f9a31bc', 15 15 'differential.pkg.css' => 'ea471cb0', 16 - 'differential.pkg.js' => 'ae6f5198', 16 + 'differential.pkg.js' => '85c19957', 17 17 'diffusion.pkg.css' => 'b93d9b8c', 18 18 'diffusion.pkg.js' => '84c8f8fd', 19 19 'favicon.ico' => '30672e08', ··· 237 237 'rsrc/externals/javelin/ext/view/__tests__/ViewInterpreter.js' => '7a94d6a5', 238 238 'rsrc/externals/javelin/ext/view/__tests__/ViewRenderer.js' => '6ea96ac9', 239 239 'rsrc/externals/javelin/lib/Cookie.js' => '62dfea03', 240 - 'rsrc/externals/javelin/lib/DOM.js' => '805b806a', 240 + 'rsrc/externals/javelin/lib/DOM.js' => '4976858c', 241 241 'rsrc/externals/javelin/lib/History.js' => 'd4505101', 242 242 'rsrc/externals/javelin/lib/JSON.js' => '69adf288', 243 243 'rsrc/externals/javelin/lib/Leader.js' => '7f243deb', ··· 391 391 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '453c5375', 392 392 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63', 393 393 'rsrc/js/application/diff/DiffChangeset.js' => '68758d99', 394 - 'rsrc/js/application/diff/DiffChangesetList.js' => '57c491b5', 394 + 'rsrc/js/application/diff/DiffChangesetList.js' => '842e2676', 395 395 'rsrc/js/application/diff/DiffInline.js' => '1afe9760', 396 396 'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832', 397 397 'rsrc/js/application/differential/behavior-comment-preview.js' => 'b064af76', 398 398 'rsrc/js/application/differential/behavior-diff-radios.js' => 'e1ff79b1', 399 - 'rsrc/js/application/differential/behavior-edit-inline-comments.js' => '1c6bc8cf', 400 399 'rsrc/js/application/differential/behavior-populate.js' => '5e41c819', 401 400 'rsrc/js/application/differential/behavior-toggle-files.js' => 'ca3f91eb', 402 401 'rsrc/js/application/differential/behavior-user-select.js' => 'a8d8459d', ··· 619 618 'javelin-behavior-device' => 'bb1dd507', 620 619 'javelin-behavior-diff-preview-link' => '051c7832', 621 620 'javelin-behavior-differential-diff-radios' => 'e1ff79b1', 622 - 'javelin-behavior-differential-edit-inline-comments' => '1c6bc8cf', 623 621 'javelin-behavior-differential-feedback-preview' => 'b064af76', 624 622 'javelin-behavior-differential-populate' => '5e41c819', 625 623 'javelin-behavior-differential-toggle-files' => 'ca3f91eb', ··· 715 713 'javelin-color' => '7e41274a', 716 714 'javelin-cookie' => '62dfea03', 717 715 'javelin-diffusion-locate-file-source' => 'c93358e3', 718 - 'javelin-dom' => '805b806a', 716 + 'javelin-dom' => '4976858c', 719 717 'javelin-dynval' => 'f6555212', 720 718 'javelin-event' => '2ee659ce', 721 719 'javelin-fx' => '54b612ba', ··· 780 778 'phabricator-darkmessage' => 'c48cccdd', 781 779 'phabricator-dashboard-css' => 'fe5b1869', 782 780 'phabricator-diff-changeset' => '68758d99', 783 - 'phabricator-diff-changeset-list' => '57c491b5', 781 + 'phabricator-diff-changeset-list' => '842e2676', 784 782 'phabricator-diff-inline' => '1afe9760', 785 783 'phabricator-drag-and-drop-file-upload' => '58dea2fa', 786 784 'phabricator-draggable-list' => 'bea6e7f4', ··· 1039 1037 'javelin-vector', 1040 1038 'javelin-request', 1041 1039 'javelin-uri', 1042 - ), 1043 - '1c6bc8cf' => array( 1044 - 'javelin-behavior', 1045 - 'javelin-stratcom', 1046 - 'javelin-dom', 1047 - 'javelin-util', 1048 - 'javelin-vector', 1049 1040 ), 1050 1041 '1def2711' => array( 1051 1042 'javelin-install', ··· 1250 1241 'javelin-uri', 1251 1242 'phabricator-notification', 1252 1243 ), 1244 + '4976858c' => array( 1245 + 'javelin-magical-init', 1246 + 'javelin-install', 1247 + 'javelin-util', 1248 + 'javelin-vector', 1249 + 'javelin-stratcom', 1250 + ), 1253 1251 '49ae8328' => array( 1254 1252 'javelin-behavior', 1255 1253 'javelin-dom', ··· 1330 1328 'javelin-behavior', 1331 1329 'javelin-vector', 1332 1330 'javelin-dom', 1333 - ), 1334 - '57c491b5' => array( 1335 - 'javelin-install', 1336 1331 ), 1337 1332 '58dea2fa' => array( 1338 1333 'javelin-install', ··· 1529 1524 'javelin-vector', 1530 1525 'javelin-stratcom', 1531 1526 ), 1532 - '805b806a' => array( 1533 - 'javelin-magical-init', 1534 - 'javelin-install', 1535 - 'javelin-util', 1536 - 'javelin-vector', 1537 - 'javelin-stratcom', 1538 - ), 1539 1527 '834a1173' => array( 1540 1528 'javelin-behavior', 1541 1529 'javelin-scrollbar', ··· 1543 1531 '83e03671' => array( 1544 1532 'javelin-install', 1545 1533 'javelin-dom', 1534 + ), 1535 + '842e2676' => array( 1536 + 'javelin-install', 1546 1537 ), 1547 1538 '8499b6ab' => array( 1548 1539 'javelin-behavior', ··· 2421 2412 'phabricator-drag-and-drop-file-upload', 2422 2413 'phabricator-shaped-request', 2423 2414 'javelin-behavior-differential-feedback-preview', 2424 - 'javelin-behavior-differential-edit-inline-comments', 2425 2415 'javelin-behavior-differential-populate', 2426 2416 'javelin-behavior-differential-diff-radios', 2427 2417 'javelin-behavior-aphront-drag-and-drop-textarea',
-1
resources/celerity/packages.php
··· 193 193 'phabricator-shaped-request', 194 194 195 195 'javelin-behavior-differential-feedback-preview', 196 - 'javelin-behavior-differential-edit-inline-comments', 197 196 'javelin-behavior-differential-populate', 198 197 'javelin-behavior-differential-diff-radios', 199 198 'javelin-behavior-aphront-drag-and-drop-textarea',
-7
src/applications/differential/view/DifferentialChangesetListView.php
··· 274 274 ), 275 275 )); 276 276 277 - if ($this->inlineURI) { 278 - Javelin::initBehavior('differential-edit-inline-comments', array( 279 - 'uri' => $this->inlineURI, 280 - 'stage' => 'differential-review-stage', 281 - )); 282 - } 283 - 284 277 if ($this->header) { 285 278 $header = $this->header; 286 279 } else {
+2 -2
webroot/rsrc/externals/javelin/lib/DOM.js
··· 891 891 * it. 892 892 * 893 893 * @param Node Node to look above. 894 - * @param string Tag name, like 'a' or 'textarea'. 894 + * @param string Optional tag name, like 'a' or 'textarea'. 895 895 * @param string Optionally, sigil which selected node must have. 896 896 * @return Node Matching node. 897 897 * ··· 911 911 if (!result) { 912 912 break; 913 913 } 914 - if (JX.DOM.isType(result, tagname)) { 914 + if (!tagname || JX.DOM.isType(result, tagname)) { 915 915 if (!sigil || JX.Stratcom.hasSigil(result, sigil)) { 916 916 break; 917 917 }
+149
webroot/rsrc/js/application/diff/DiffChangesetList.js
··· 62 62 ['mouseover', 'mouseout'], 63 63 'differential-inline-comment', 64 64 onhover); 65 + 66 + var onrangedown = JX.bind(this, this._ifawake, this._onrangedown); 67 + JX.Stratcom.listen( 68 + 'mousedown', 69 + ['differential-changeset', 'tag:th'], 70 + onrangedown); 71 + 72 + var onrangemove = JX.bind(this, this._ifawake, this._onrangemove); 73 + JX.Stratcom.listen( 74 + ['mouseover', 'mouseout'], 75 + ['differential-changeset', 'tag:th'], 76 + onrangemove); 77 + 78 + var onrangeup = JX.bind(this, this._ifawake, this._onrangeup); 79 + JX.Stratcom.listen('mouseup', null, onrangeup); 65 80 }, 66 81 67 82 properties: { ··· 84 99 _hoverInline: null, 85 100 _hoverOrigin: null, 86 101 _hoverTarget: null, 102 + 103 + _rangeActive: false, 104 + _rangeOrigin: null, 105 + _rangeTarget: null, 87 106 88 107 sleep: function() { 89 108 this._asleep = true; ··· 953 972 this._redrawHover(); 954 973 }, 955 974 975 + _setHoverRange: function(origin, target) { 976 + this._hoverOrigin = origin; 977 + this._hoverTarget = target; 978 + 979 + this._redrawHover(); 980 + }, 981 + 956 982 resetHover: function() { 957 983 this._setHoverInline(null); 984 + 985 + this._hoverOrigin = null; 986 + this._hoverTarget = null; 958 987 }, 959 988 960 989 _redrawHover: function() { ··· 1056 1085 1057 1086 getDisplaySideFromHeader: function(th) { 1058 1087 return (th.parentNode.firstChild != th) ? 'right' : 'left'; 1088 + }, 1089 + 1090 + _onrangedown: function(e) { 1091 + if (!e.isNormalMouseEvent()) { 1092 + return; 1093 + } 1094 + 1095 + if (e.getIsTouchEvent()) { 1096 + return; 1097 + } 1098 + 1099 + if (this._rangeActive) { 1100 + return; 1101 + } 1102 + 1103 + var target = e.getTarget(); 1104 + var number = this.getLineNumberFromHeader(target); 1105 + if (!number) { 1106 + return; 1107 + } 1108 + 1109 + e.kill(); 1110 + this._rangeActive = true; 1111 + 1112 + this._rangeOrigin = target; 1113 + this._rangeTarget = target; 1114 + 1115 + this._setHoverRange(this._rangeOrigin, this._rangeTarget); 1116 + }, 1117 + 1118 + _onrangemove: function(e) { 1119 + if (e.getIsTouchEvent()) { 1120 + return; 1121 + } 1122 + 1123 + var target = e.getTarget(); 1124 + 1125 + // Don't update the range if this "<th />" doesn't correspond to a line 1126 + // number. For instance, this may be a dead line number, like the empty 1127 + // line numbers on the left hand side of a newly added file. 1128 + var number = this.getLineNumberFromHeader(target); 1129 + if (!number) { 1130 + return; 1131 + } 1132 + 1133 + if (this._rangeActive) { 1134 + var origin = this._hoverOrigin; 1135 + 1136 + // Don't update the reticle if we're selecting a line range and the 1137 + // "<th />" under the cursor is on the wrong side of the file. You can 1138 + // only leave inline comments on the left or right side of a file, not 1139 + // across lines on both sides. 1140 + var origin_side = this.getDisplaySideFromHeader(origin); 1141 + var target_side = this.getDisplaySideFromHeader(target); 1142 + if (origin_side != target_side) { 1143 + return; 1144 + } 1145 + 1146 + // Don't update the reticle if we're selecting a line range and the 1147 + // "<th />" under the cursor corresponds to a different file. You can 1148 + // only leave inline comments on lines in a single file, not across 1149 + // multiple files. 1150 + var origin_table = JX.DOM.findAbove(origin, 'table'); 1151 + var target_table = JX.DOM.findAbove(target, 'table'); 1152 + if (origin_table != target_table) { 1153 + return; 1154 + } 1155 + } 1156 + 1157 + var is_out = (e.getType() == 'mouseout'); 1158 + if (is_out) { 1159 + if (this._rangeActive) { 1160 + // If we're dragging a range, just leave the state as it is. This 1161 + // allows you to drag over something invalid while selecting a 1162 + // range without the range flickering or getting lost. 1163 + } else { 1164 + // Otherwise, clear the current range. 1165 + this.resetHover(); 1166 + } 1167 + return; 1168 + } 1169 + 1170 + if (this._rangeActive) { 1171 + this._rangeTarget = target; 1172 + } else { 1173 + this._rangeOrigin = target; 1174 + this._rangeTarget = target; 1175 + } 1176 + 1177 + this._setHoverRange(this._rangeOrigin, this._rangeTarget); 1178 + }, 1179 + 1180 + _onrangeup: function(e) { 1181 + if (!this._rangeActive) { 1182 + return; 1183 + } 1184 + 1185 + e.kill(); 1186 + 1187 + var origin = this._rangeOrigin; 1188 + var target = this._rangeTarget; 1189 + 1190 + // If the user dragged a range from the bottom to the top, swap the node 1191 + // order around. 1192 + if (JX.$V(origin).y > JX.$V(target).y) { 1193 + var tmp = target; 1194 + target = origin; 1195 + origin = tmp; 1196 + } 1197 + 1198 + var node = JX.DOM.findAbove(origin, null, 'differential-changeset'); 1199 + var changeset = this.getChangesetForNode(node); 1200 + 1201 + changeset.newInlineForRange(origin, target); 1202 + 1203 + this._rangeActive = false; 1204 + this._rangeOrigin = null; 1205 + this._rangeTarget = null; 1206 + 1207 + this.resetHover(); 1059 1208 } 1060 1209 } 1061 1210
-209
webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js
··· 1 - /** 2 - * @provides javelin-behavior-differential-edit-inline-comments 3 - * @requires javelin-behavior 4 - * javelin-stratcom 5 - * javelin-dom 6 - * javelin-util 7 - * javelin-vector 8 - */ 9 - 10 - JX.behavior('differential-edit-inline-comments', function(config) { 11 - 12 - var selecting = false; 13 - var reticle = JX.$N('div', {className: 'differential-reticle'}); 14 - JX.DOM.hide(reticle); 15 - 16 - var origin = null; 17 - var target = null; 18 - var root = null; 19 - var changeset = null; 20 - 21 - function updateReticle() { 22 - JX.DOM.getContentFrame().appendChild(reticle); 23 - 24 - var top = origin; 25 - var bot = target; 26 - if (JX.$V(top).y > JX.$V(bot).y) { 27 - var tmp = top; 28 - top = bot; 29 - bot = tmp; 30 - } 31 - 32 - // Find the leftmost cell that we're going to highlight: this is the next 33 - // <td /> in the row. In 2up views, it should be directly adjacent. In 34 - // 1up views, we may have to skip over the other line number column. 35 - var l = top; 36 - while (JX.DOM.isType(l, 'th')) { 37 - l = l.nextSibling; 38 - } 39 - 40 - // Find the rightmost cell that we're going to highlight: this is the 41 - // farthest consecutive, adjacent <td /> in the row. Sometimes the left 42 - // and right nodes are the same (left side of 2up view); sometimes we're 43 - // going to highlight several nodes (copy + code + coverage). 44 - var r = l; 45 - while (r.nextSibling && JX.DOM.isType(r.nextSibling, 'td')) { 46 - r = r.nextSibling; 47 - } 48 - 49 - var pos = JX.$V(l) 50 - .add(JX.Vector.getAggregateScrollForNode(l)); 51 - 52 - var dim = JX.$V(r) 53 - .add(JX.Vector.getAggregateScrollForNode(r)) 54 - .add(-pos.x, -pos.y) 55 - .add(JX.Vector.getDim(r)); 56 - 57 - var bpos = JX.$V(bot) 58 - .add(JX.Vector.getAggregateScrollForNode(bot)); 59 - dim.y = (bpos.y - pos.y) + JX.Vector.getDim(bot).y; 60 - 61 - pos.setPos(reticle); 62 - dim.setDim(reticle); 63 - 64 - JX.DOM.show(reticle); 65 - } 66 - 67 - function hideReticle() { 68 - JX.DOM.hide(reticle); 69 - } 70 - 71 - function isOnRight(node) { 72 - return node.parentNode.firstChild != node; 73 - } 74 - 75 - function getRowNumber(th_node) { 76 - try { 77 - return parseInt(th_node.id.match(/^C\d+[ON]L(\d+)$/)[1], 10); 78 - } catch (x) { 79 - return undefined; 80 - } 81 - } 82 - 83 - JX.Stratcom.listen( 84 - 'mousedown', 85 - ['differential-changeset', 'tag:th'], 86 - function(e) { 87 - if (e.isRightButton() || 88 - getRowNumber(e.getTarget()) === undefined) { 89 - return; 90 - } 91 - 92 - if (selecting) { 93 - return; 94 - } 95 - 96 - selecting = true; 97 - root = e.getNode('differential-changeset'); 98 - 99 - origin = target = e.getTarget(); 100 - 101 - var data = e.getNodeData('differential-changeset'); 102 - if (isOnRight(target)) { 103 - changeset = data.right; 104 - } else { 105 - changeset = data.left; 106 - } 107 - 108 - updateReticle(); 109 - 110 - e.kill(); 111 - }); 112 - 113 - JX.Stratcom.listen( 114 - ['mouseover', 'mouseout'], 115 - ['differential-changeset', 'tag:th'], 116 - function(e) { 117 - if (e.getIsTouchEvent()) { 118 - return; 119 - } 120 - 121 - if (getRowNumber(e.getTarget()) === undefined) { 122 - // Don't update the reticle if this "<th />" doesn't correspond to a 123 - // line number. For instance, this may be a dead line number, like the 124 - // empty line numbers on the left hand side of a newly added file. 125 - return; 126 - } 127 - 128 - if (selecting) { 129 - if (isOnRight(e.getTarget()) != isOnRight(origin)) { 130 - // Don't update the reticle if we're selecting a line range and the 131 - // "<th />" under the cursor is on the wrong side of the file. You 132 - // can only leave inline comments on the left or right side of a 133 - // file, not across lines on both sides. 134 - return; 135 - } 136 - 137 - if (e.getNode('differential-changeset') !== root) { 138 - // Don't update the reticle if we're selecting a line range and 139 - // the "<th />" under the cursor corresponds to a different file. 140 - // You can only leave inline comments on lines in a single file, 141 - // not across multiple files. 142 - return; 143 - } 144 - } 145 - 146 - if (e.getType() == 'mouseout') { 147 - if (selecting) { 148 - // Don't hide the reticle if we're selecting, since we want to 149 - // keep showing the line range that will be used if the mouse is 150 - // released. 151 - return; 152 - } 153 - hideReticle(); 154 - } else { 155 - target = e.getTarget(); 156 - if (!selecting) { 157 - // If we're just hovering the mouse and not selecting a line range, 158 - // set the origin to the current row so we highlight it. 159 - origin = target; 160 - } 161 - 162 - updateReticle(); 163 - } 164 - }); 165 - 166 - JX.Stratcom.listen( 167 - 'mouseup', 168 - null, 169 - function(e) { 170 - if (!selecting) { 171 - return; 172 - } 173 - 174 - var o = getRowNumber(origin); 175 - var t = getRowNumber(target); 176 - 177 - var insert; 178 - var len; 179 - if (t < o) { 180 - len = (o - t); 181 - o = t; 182 - insert = origin.parentNode; 183 - } else { 184 - len = (t - o); 185 - insert = target.parentNode; 186 - } 187 - 188 - var view = JX.DiffChangeset.getForNode(root); 189 - 190 - view.newInlineForRange(origin, target); 191 - 192 - selecting = false; 193 - origin = null; 194 - target = null; 195 - 196 - e.kill(); 197 - }); 198 - 199 - JX.Stratcom.listen( 200 - ['mouseover', 'mouseout'], 201 - 'differential-inline-comment', 202 - function(e) { 203 - if (e.getIsTouchEvent()) { 204 - return; 205 - } 206 - hideReticle(); 207 - }); 208 - 209 - });