@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 inline replies to new code and remove DifferentialInlineEditor

Summary:
Ref T12616. This moves "reply" to the new stuff and deletes DifferentialInlineEditor, which no longer does anything.

(This breaks some keyboard shortcuts, but I'll rebase D17859 shortly.)

Test Plan: Replied to inlines; things seemed to work properly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12616

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

+104 -522
+32 -43
resources/celerity/map.php
··· 13 13 'core.pkg.js' => '2ff7879f', 14 14 'darkconsole.pkg.js' => '1f9a31bc', 15 15 'differential.pkg.css' => '58712637', 16 - 'differential.pkg.js' => '3a7c5866', 16 + 'differential.pkg.js' => '6375358e', 17 17 'diffusion.pkg.css' => 'b93d9b8c', 18 18 'diffusion.pkg.js' => '84c8f8fd', 19 19 'favicon.ico' => '30672e08', ··· 390 390 'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => '408bf173', 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 - 'rsrc/js/application/diff/DiffChangeset.js' => '454cfe59', 394 - 'rsrc/js/application/diff/DiffChangesetList.js' => '50bc5b50', 395 - 'rsrc/js/application/diff/DiffInline.js' => '38a957be', 393 + 'rsrc/js/application/diff/DiffChangeset.js' => '4c9c47ad', 394 + 'rsrc/js/application/diff/DiffChangesetList.js' => '589a30aa', 395 + 'rsrc/js/application/diff/DiffInline.js' => '98c12b2f', 396 396 'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832', 397 - 'rsrc/js/application/differential/DifferentialInlineCommentEditor.js' => '9ed8d2b6', 398 397 'rsrc/js/application/differential/behavior-comment-jump.js' => '4fdb476d', 399 398 'rsrc/js/application/differential/behavior-comment-preview.js' => 'b064af76', 400 399 'rsrc/js/application/differential/behavior-diff-radios.js' => 'e1ff79b1', 401 - 'rsrc/js/application/differential/behavior-edit-inline-comments.js' => '995c805a', 400 + 'rsrc/js/application/differential/behavior-edit-inline-comments.js' => '89d11432', 402 401 'rsrc/js/application/differential/behavior-keyboard-nav.js' => '92904457', 403 402 'rsrc/js/application/differential/behavior-populate.js' => '5e41c819', 404 403 'rsrc/js/application/differential/behavior-toggle-files.js' => 'ca3f91eb', ··· 572 571 'd3' => 'a11a5ff2', 573 572 'differential-changeset-view-css' => '41af6d25', 574 573 'differential-core-view-css' => '5b7b8ff4', 575 - 'differential-inline-comment-editor' => '9ed8d2b6', 576 574 'differential-revision-add-comment-css' => 'c47f8c40', 577 575 'differential-revision-comment-css' => '14b8565a', 578 576 'differential-revision-history-css' => '0e8eb855', ··· 624 622 'javelin-behavior-diff-preview-link' => '051c7832', 625 623 'javelin-behavior-differential-comment-jump' => '4fdb476d', 626 624 'javelin-behavior-differential-diff-radios' => 'e1ff79b1', 627 - 'javelin-behavior-differential-edit-inline-comments' => '995c805a', 625 + 'javelin-behavior-differential-edit-inline-comments' => '89d11432', 628 626 'javelin-behavior-differential-feedback-preview' => 'b064af76', 629 627 'javelin-behavior-differential-keyboard-navigation' => '92904457', 630 628 'javelin-behavior-differential-populate' => '5e41c819', ··· 785 783 'phabricator-darklog' => 'c8e1ffe3', 786 784 'phabricator-darkmessage' => 'c48cccdd', 787 785 'phabricator-dashboard-css' => 'fe5b1869', 788 - 'phabricator-diff-changeset' => '454cfe59', 789 - 'phabricator-diff-changeset-list' => '50bc5b50', 790 - 'phabricator-diff-inline' => '38a957be', 786 + 'phabricator-diff-changeset' => '4c9c47ad', 787 + 'phabricator-diff-changeset-list' => '589a30aa', 788 + 'phabricator-diff-inline' => '98c12b2f', 791 789 'phabricator-drag-and-drop-file-upload' => '58dea2fa', 792 790 'phabricator-draggable-list' => 'bea6e7f4', 793 791 'phabricator-fatal-config-template-css' => '8f18fa41', ··· 1132 1130 'javelin-dom', 1133 1131 'javelin-workflow', 1134 1132 ), 1135 - '38a957be' => array( 1136 - 'javelin-dom', 1137 - ), 1138 1133 '3ab51e2c' => array( 1139 1134 'javelin-behavior', 1140 1135 'javelin-behavior-device', ··· 1214 1209 'javelin-behavior', 1215 1210 'javelin-dom', 1216 1211 ), 1217 - '454cfe59' => array( 1218 - 'javelin-dom', 1219 - 'javelin-util', 1220 - 'javelin-stratcom', 1221 - 'javelin-install', 1222 - 'javelin-workflow', 1223 - 'javelin-router', 1224 - 'javelin-behavior-device', 1225 - 'javelin-vector', 1226 - 'phabricator-diff-inline', 1227 - ), 1228 1212 '469c0d9e' => array( 1229 1213 'javelin-behavior', 1230 1214 'javelin-dom', ··· 1286 1270 'javelin-uri', 1287 1271 'phabricator-notification', 1288 1272 ), 1273 + '4c9c47ad' => array( 1274 + 'javelin-dom', 1275 + 'javelin-util', 1276 + 'javelin-stratcom', 1277 + 'javelin-install', 1278 + 'javelin-workflow', 1279 + 'javelin-router', 1280 + 'javelin-behavior-device', 1281 + 'javelin-vector', 1282 + 'phabricator-diff-inline', 1283 + ), 1289 1284 '4d863052' => array( 1290 1285 'javelin-dom', 1291 1286 'javelin-util', ··· 1311 1306 'javelin-install', 1312 1307 'javelin-typeahead-source', 1313 1308 'javelin-util', 1314 - ), 1315 - '50bc5b50' => array( 1316 - 'javelin-install', 1317 1309 ), 1318 1310 '519705ea' => array( 1319 1311 'javelin-install', ··· 1355 1347 'javelin-behavior', 1356 1348 'javelin-vector', 1357 1349 'javelin-dom', 1350 + ), 1351 + '589a30aa' => array( 1352 + 'javelin-install', 1358 1353 ), 1359 1354 '58dea2fa' => array( 1360 1355 'javelin-install', ··· 1596 1591 'phabricator-draggable-list', 1597 1592 'javelin-workboard-column', 1598 1593 ), 1594 + '89d11432' => array( 1595 + 'javelin-behavior', 1596 + 'javelin-stratcom', 1597 + 'javelin-dom', 1598 + 'javelin-util', 1599 + 'javelin-vector', 1600 + ), 1599 1601 '8a41885b' => array( 1600 1602 'javelin-install', 1601 1603 'javelin-dom', ··· 1675 1677 'javelin-dom', 1676 1678 'javelin-reactor-dom', 1677 1679 ), 1678 - '995c805a' => array( 1679 - 'javelin-behavior', 1680 - 'javelin-stratcom', 1680 + '98c12b2f' => array( 1681 1681 'javelin-dom', 1682 - 'javelin-util', 1683 - 'javelin-vector', 1684 - 'differential-inline-comment-editor', 1685 1682 ), 1686 1683 '9a6dd75c' => array( 1687 1684 'javelin-behavior', ··· 1705 1702 ), 1706 1703 '9d9685d6' => array( 1707 1704 'phui-oi-list-view-css', 1708 - ), 1709 - '9ed8d2b6' => array( 1710 - 'javelin-dom', 1711 - 'javelin-util', 1712 - 'javelin-stratcom', 1713 - 'javelin-install', 1714 - 'javelin-request', 1715 - 'javelin-workflow', 1716 1705 ), 1717 1706 '9f36c42d' => array( 1718 1707 'javelin-behavior', ··· 2456 2445 'javelin-behavior-phabricator-object-selector', 2457 2446 'javelin-behavior-repository-crossreference', 2458 2447 'javelin-behavior-load-blame', 2459 - 'differential-inline-comment-editor', 2460 2448 'javelin-behavior-differential-toggle-files', 2461 2449 'javelin-behavior-differential-user-select', 2462 2450 'javelin-behavior-aphront-more', 2451 + 'phabricator-diff-inline', 2463 2452 'phabricator-diff-changeset', 2464 2453 'phabricator-diff-changeset-list', 2465 2454 ),
+2 -1
resources/celerity/packages.php
··· 203 203 'javelin-behavior-repository-crossreference', 204 204 'javelin-behavior-load-blame', 205 205 206 - 'differential-inline-comment-editor', 207 206 'javelin-behavior-differential-toggle-files', 208 207 'javelin-behavior-differential-user-select', 209 208 'javelin-behavior-aphront-more', 209 + 210 + 'phabricator-diff-inline', 210 211 'phabricator-diff-changeset', 211 212 'phabricator-diff-changeset-list', 212 213 ),
-13
src/infrastructure/diff/PhabricatorInlineCommentController.php
··· 94 94 95 95 $op = $this->getOperation(); 96 96 switch ($op) { 97 - case 'busy': 98 - if ($request->isFormPost()) { 99 - return new AphrontAjaxResponse(); 100 - } 101 - 102 - return $this->newDialog() 103 - ->setTitle(pht('Already Editing')) 104 - ->appendParagraph( 105 - pht( 106 - 'You are already editing an inline comment. Finish editing '. 107 - 'your current comment before adding new comments.')) 108 - ->addCancelButton('/') 109 - ->addSubmitButton(pht('Jump to Inline')); 110 97 case 'hide': 111 98 case 'show': 112 99 if (!$request->validateCSRF()) {
+12
webroot/rsrc/js/application/diff/DiffChangeset.js
··· 433 433 return inline; 434 434 }, 435 435 436 + newInlineReply: function(original) { 437 + var inline = new JX.DiffInline() 438 + .setChangeset(this) 439 + .bindToReply(original); 440 + 441 + this._inlines.push(inline); 442 + 443 + inline.create(); 444 + 445 + return inline; 446 + }, 447 + 436 448 getInlineByID: function(id) { 437 449 // TODO: Currently, this will only find inlines which the user has 438 450 // already interacted with! Inlines are built lazily as events arrive.
+9
webroot/rsrc/js/application/diff/DiffChangesetList.js
··· 41 41 'click', 42 42 ['differential-inline-comment', 'differential-inline-delete'], 43 43 ondelete); 44 + 45 + var onreply = JX.bind(this, this._ifawake, this._onaction, 'reply'); 46 + JX.Stratcom.listen( 47 + 'click', 48 + ['differential-inline-comment', 'differential-inline-reply'], 49 + onreply); 44 50 }, 45 51 46 52 properties: { ··· 409 415 break; 410 416 case 'delete': 411 417 inline.delete(is_ref); 418 + break; 419 + case 'reply': 420 + inline.reply(); 412 421 break; 413 422 } 414 423 },
+49 -12
webroot/rsrc/js/application/diff/DiffInline.js
··· 24 24 _displaySide: null, 25 25 _isNewFile: null, 26 26 _undoRow: null, 27 + _replyToCommentPHID: null, 27 28 28 29 _isDeleted: false, 29 30 _isInvisible: false, ··· 66 67 }, 67 68 68 69 bindToRange: function(data) { 69 - this._id = null; 70 - this._phid = null; 71 - 72 - this._hidden = false; 73 - 74 70 this._displaySide = data.displaySide; 75 71 this._number = data.number; 76 72 this._length = data.length; 77 73 this._isNewFile = data.isNewFile; 78 74 this._changesetID = data.changesetID; 79 75 76 + // Insert the comment after any other comments which already appear on 77 + // the same row. 78 + var parent_row = JX.DOM.findAbove(data.target, 'tr'); 79 + var target_row = parent_row.nextSibling; 80 + while (target_row && JX.Stratcom.hasSigil(target_row, 'inline-row')) { 81 + target_row = target_row.nextSibling; 82 + } 83 + 80 84 var row = this._newRow(); 81 - JX.Stratcom.getData(row).inline = this; 82 - this._row = row; 85 + parent_row.parentNode.insertBefore(row, target_row); 83 86 84 87 this.setInvisible(true); 85 88 86 - // Insert the comment after any other comments which already appear on 87 - // the same row. 88 - var parent_row = JX.DOM.findAbove(data.target, 'tr'); 89 + return this; 90 + }, 91 + 92 + bindToReply: function(inline) { 93 + this._displaySide = inline._displaySide; 94 + this._number = inline._number; 95 + this._length = inline._length; 96 + this._isNewFile = inline._isNewFile; 97 + this._changesetID = inline._changesetID; 98 + 99 + this._replyToCommentPHID = inline._phid; 100 + 101 + // TODO: This should insert correctly into the thread, not just at the 102 + // bottom. 103 + var parent_row = inline._row; 89 104 var target_row = parent_row.nextSibling; 90 105 while (target_row && JX.Stratcom.hasSigil(target_row, 'inline-row')) { 91 106 target_row = target_row.nextSibling; 92 107 } 108 + 109 + var row = this._newRow(); 93 110 parent_row.parentNode.insertBefore(row, target_row); 111 + 112 + this.setInvisible(true); 94 113 95 114 return this; 96 115 }, ··· 100 119 sigil: 'inline-row' 101 120 }; 102 121 103 - return JX.$N('tr', attributes); 122 + var row = JX.$N('tr', attributes); 123 + 124 + JX.Stratcom.getData(row).inline = this; 125 + this._row = row; 126 + 127 + this._id = null; 128 + this._phid = null; 129 + this._hidden = false; 130 + 131 + return row; 104 132 }, 105 133 106 134 setHidden: function(hidden) { ··· 172 200 .send(); 173 201 }, 174 202 203 + reply: function() { 204 + var changeset = this.getChangeset(); 205 + return changeset.newInlineReply(this); 206 + }, 207 + 175 208 edit: function() { 176 209 var uri = this._getInlineURI(); 177 210 var handler = JX.bind(this, this._oneditresponse); ··· 238 271 return this._changesetID; 239 272 }, 240 273 274 + getReplyToCommentPHID: function() { 275 + return this._replyToCommentPHID; 276 + }, 277 + 241 278 setDeleted: function(deleted) { 242 279 this._isDeleted = deleted; 243 280 this._redraw(); ··· 266 303 length: this.getLineLength(), 267 304 is_new: this.isNewFile(), 268 305 changesetID: this.getChangesetID(), 269 - replyToCommentPHID: '' 306 + replyToCommentPHID: this.getReplyToCommentPHID() || '', 270 307 }; 271 308 }, 272 309
-360
webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js
··· 1 - /** 2 - * @provides differential-inline-comment-editor 3 - * @requires javelin-dom 4 - * javelin-util 5 - * javelin-stratcom 6 - * javelin-install 7 - * javelin-request 8 - * javelin-workflow 9 - */ 10 - 11 - JX.install('DifferentialInlineCommentEditor', { 12 - 13 - construct : function(uri) { 14 - this._uri = uri; 15 - }, 16 - 17 - events : ['done'], 18 - 19 - members : { 20 - _uri : null, 21 - _undoText : null, 22 - _completed: false, 23 - _skipOverInlineCommentRows : function(node) { 24 - // TODO: Move this semantic information out of class names. 25 - while (node && node.className.indexOf('inline') !== -1) { 26 - node = node.nextSibling; 27 - } 28 - return node; 29 - }, 30 - _buildRequestData : function() { 31 - return { 32 - op : this.getOperation(), 33 - on_right : this.getOnRight(), 34 - id : this.getID(), 35 - number : this.getLineNumber(), 36 - is_new : (this.getIsNew() ? 1 : 0), 37 - length : this.getLength(), 38 - changesetID : this.getChangesetID(), 39 - text : this.getText() || '', 40 - renderer: this.getRenderer(), 41 - replyToCommentPHID: this.getReplyToCommentPHID() || '', 42 - }; 43 - }, 44 - _draw : function(content, exact_row) { 45 - var row = this.getRow(); 46 - var table = this.getTable(); 47 - var target = exact_row ? row : this._skipOverInlineCommentRows(row); 48 - 49 - function copyRows(dst, src, before) { 50 - var rows = JX.DOM.scry(src, 'tr'); 51 - for (var ii = 0; ii < rows.length; ii++) { 52 - 53 - // Find the table this <tr /> belongs to. If it's a sub-table, like a 54 - // table in an inline comment, don't copy it. 55 - if (JX.DOM.findAbove(rows[ii], 'table') !== src) { 56 - continue; 57 - } 58 - 59 - if (before) { 60 - dst.insertBefore(rows[ii], before); 61 - } else { 62 - dst.appendChild(rows[ii]); 63 - } 64 - } 65 - return rows; 66 - } 67 - 68 - return copyRows(table, content, target); 69 - }, 70 - _removeUndoLink : function() { 71 - var rows = JX.DifferentialInlineCommentEditor._undoRows; 72 - if (rows) { 73 - for (var ii = 0; ii < rows.length; ii++) { 74 - JX.DOM.remove(rows[ii]); 75 - } 76 - } 77 - JX.DifferentialInlineCommentEditor._undoRows = []; 78 - }, 79 - _undo : function() { 80 - this._removeUndoLink(); 81 - 82 - if (this._undoText) { 83 - this.setText(this._undoText); 84 - } else { 85 - this.setOperation('undelete'); 86 - } 87 - 88 - this.start(); 89 - }, 90 - _registerUndoListener : function() { 91 - if (!JX.DifferentialInlineCommentEditor._activeEditor) { 92 - JX.Stratcom.listen( 93 - 'click', 94 - 'differential-inline-comment-undo', 95 - function(e) { 96 - JX.DifferentialInlineCommentEditor._activeEditor._undo(); 97 - e.kill(); 98 - }); 99 - } 100 - JX.DifferentialInlineCommentEditor._activeEditor = this; 101 - }, 102 - _setRowState : function(state) { 103 - var is_hidden = (state == 'hidden'); 104 - var is_loading = (state == 'loading'); 105 - var row = this.getRow(); 106 - JX.DOM.alterClass(row, 'differential-inline-hidden', is_hidden); 107 - JX.DOM.alterClass(row, 'differential-inline-loading', is_loading); 108 - }, 109 - _didContinueWorkflow : function(response) { 110 - var drawn = this._draw(JX.$H(response).getNode()); 111 - 112 - var op = this.getOperation(); 113 - if (op == 'edit') { 114 - this._setRowState('hidden'); 115 - } 116 - 117 - JX.DOM.find( 118 - drawn[0], 119 - 'textarea', 120 - 'differential-inline-comment-edit-textarea').focus(); 121 - 122 - var oncancel = JX.bind(this, function(e) { 123 - e.kill(); 124 - 125 - this._didCancelWorkflow(); 126 - 127 - if (op == 'edit') { 128 - this._setRowState('visible'); 129 - } 130 - 131 - JX.DOM.remove(drawn[0]); 132 - }); 133 - JX.DOM.listen(drawn[0], 'click', 'inline-edit-cancel', oncancel); 134 - 135 - var onsubmit = JX.bind(this, function(e) { 136 - e.kill(); 137 - 138 - JX.Workflow.newFromForm(e.getTarget()) 139 - .setHandler(JX.bind(this, function(response) { 140 - JX.DOM.remove(drawn[0]); 141 - if (op == 'edit') { 142 - this._setRowState('visible'); 143 - } 144 - this._didCompleteWorkflow(response); 145 - })) 146 - .start(); 147 - 148 - JX.DOM.alterClass(drawn[0], 'differential-inline-loading', true); 149 - }); 150 - JX.DOM.listen( 151 - drawn[0], 152 - ['submit', 'didSyntheticSubmit'], 153 - 'inline-edit-form', 154 - onsubmit); 155 - }, 156 - 157 - 158 - _didCompleteWorkflow : function(response) { 159 - var op = this.getOperation(); 160 - 161 - // We don't get any markup back if the user deletes a comment, or saves 162 - // an empty comment (which effects a delete). 163 - if (response.markup) { 164 - this._draw(JX.$H(response.markup).getNode()); 165 - } 166 - 167 - if (op == 'delete' || op == 'refdelete') { 168 - this._undoText = null; 169 - this._drawUndo(); 170 - } else { 171 - this._removeUndoLink(); 172 - } 173 - 174 - // These operations remove the old row (edit adds a new row first). 175 - var remove_old = (op == 'edit' || op == 'delete' || op == 'refdelete'); 176 - if (remove_old) { 177 - this._setRowState('hidden'); 178 - } 179 - 180 - if (op == 'undelete') { 181 - this._setRowState('visible'); 182 - } 183 - 184 - this._completed = true; 185 - 186 - this._didUpdate(); 187 - this.invoke('done'); 188 - }, 189 - 190 - 191 - _didCancelWorkflow : function() { 192 - this.invoke('done'); 193 - 194 - switch (this.getOperation()) { 195 - case 'delete': 196 - case 'refdelete': 197 - if (!this._completed) { 198 - this._setRowState('visible'); 199 - } 200 - return; 201 - case 'undelete': 202 - return; 203 - } 204 - 205 - var textarea; 206 - try { 207 - textarea = JX.DOM.find( 208 - document.body, // TODO: use getDialogRootNode() when available 209 - 'textarea', 210 - 'differential-inline-comment-edit-textarea'); 211 - } catch (ex) { 212 - // The close handler is called whenever the dialog closes, even if the 213 - // user closed it by completing the workflow with "Save". The 214 - // JX.Workflow API should probably be refined to allow programmatic 215 - // distinction of close caused by 'cancel' vs 'submit'. Testing for 216 - // presence of the textarea serves as a proxy for detecting a 'cancel'. 217 - return; 218 - } 219 - 220 - var text = textarea.value; 221 - 222 - // If the user hasn't edited the text (i.e., no change from original for 223 - // 'edit' or no text at all), don't offer them an undo. 224 - if (text == this.getOriginalText() || text === '') { 225 - return; 226 - } 227 - 228 - // Save the text so we can 'undo' back to it. 229 - this._undoText = text; 230 - 231 - this._drawUndo(); 232 - }, 233 - 234 - _drawUndo: function() { 235 - var templates = this.getTemplates(); 236 - var template = this.getOnRight() ? templates.r : templates.l; 237 - template = JX.$H(template).getNode(); 238 - 239 - // NOTE: Operation order matters here; we can't remove anything until 240 - // after we draw the new rows because _draw uses the old rows to figure 241 - // out where to place the comment. 242 - 243 - // We use 'exact_row' to put the "undo" text directly above the affected 244 - // comment. 245 - var exact_row = true; 246 - var rows = this._draw(template, exact_row); 247 - 248 - this._removeUndoLink(); 249 - 250 - JX.DifferentialInlineCommentEditor._undoRows = rows; 251 - }, 252 - 253 - _onBusyWorkflow: function() { 254 - // If the user clicks the "Jump to Inline" button, scroll to the row 255 - // being edited. 256 - JX.DOM.scrollTo(this.getRow()); 257 - }, 258 - 259 - start : function() { 260 - var op = this.getOperation(); 261 - 262 - // The user is already editing a comment, we're going to give them an 263 - // error message. 264 - if (op == 'busy') { 265 - var onbusy = JX.bind(this, this._onBusyWorkflow); 266 - 267 - new JX.Workflow(this._uri, {op: op}) 268 - .setHandler(onbusy) 269 - .start(); 270 - 271 - return this; 272 - } 273 - 274 - this._registerUndoListener(); 275 - var data = this._buildRequestData(); 276 - 277 - if (op == 'delete' || op == 'refdelete' || op == 'undelete') { 278 - this._setRowState('loading'); 279 - 280 - var oncomplete = JX.bind(this, this._didCompleteWorkflow); 281 - var oncancel = JX.bind(this, this._didCancelWorkflow); 282 - 283 - new JX.Workflow(this._uri, data) 284 - .setHandler(oncomplete) 285 - .setCloseHandler(oncancel) 286 - .start(); 287 - } else { 288 - var handler = JX.bind(this, this._didContinueWorkflow); 289 - 290 - if (op == 'edit') { 291 - this._setRowState('loading'); 292 - } 293 - 294 - new JX.Request(this._uri, handler) 295 - .setData(data) 296 - .send(); 297 - } 298 - 299 - return this; 300 - }, 301 - 302 - deleteByID: function(id) { 303 - var data = { 304 - op: 'refdelete', 305 - id: id 306 - }; 307 - 308 - new JX.Workflow(this._uri, data) 309 - .setHandler(JX.bind(this, function() { 310 - this._didUpdate(); 311 - })) 312 - .start(); 313 - }, 314 - 315 - _didUpdate: function() { 316 - // After making changes to inline comments, refresh the transaction 317 - // preview at the bottom of the page. 318 - 319 - // TODO: This isn't the cleanest way to find the preview form, but 320 - // rendering no longer has direct access to it. 321 - var forms = JX.DOM.scry(document.body, 'form', 'transaction-append'); 322 - if (forms.length) { 323 - JX.DOM.invoke(forms[0], 'shouldRefresh'); 324 - } 325 - } 326 - 327 - }, 328 - 329 - statics : { 330 - /** 331 - * Global refernece to the 'undo' rows currently rendered in the document. 332 - */ 333 - _undoRows : null, 334 - 335 - /** 336 - * Global listener for the 'undo' click associated with the currently 337 - * displayed 'undo' link. When an editor is start()ed, it becomes the active 338 - * editor. 339 - */ 340 - _activeEditor : null 341 - }, 342 - 343 - properties : { 344 - operation : null, 345 - row : null, 346 - table : null, 347 - onRight : null, 348 - ID : null, 349 - lineNumber : null, 350 - changesetID : null, 351 - length : null, 352 - isNew : null, 353 - text : null, 354 - templates : null, 355 - originalText : null, 356 - renderer: null, 357 - replyToCommentPHID: null 358 - } 359 - 360 - });
-93
webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js
··· 5 5 * javelin-dom 6 6 * javelin-util 7 7 * javelin-vector 8 - * differential-inline-comment-editor 9 8 */ 10 9 11 10 JX.behavior('differential-edit-inline-comments', function(config) { ··· 126 125 setSelectedCells([]); 127 126 } 128 127 129 - JX.DifferentialInlineCommentEditor.listen('done', function() { 130 - selecting = false; 131 - editor = false; 132 - hideReticle(); 133 - set_link_state(false); 134 - }); 135 - 136 128 function isOnRight(node) { 137 129 return node.parentNode.firstChild != node; 138 130 } ··· 149 141 return undefined; 150 142 } 151 143 } 152 - 153 - var set_link_state = function(active) { 154 - JX.DOM.alterClass(JX.$(config.stage), 'inline-editor-active', active); 155 - }; 156 144 157 145 JX.Stratcom.listen( 158 146 'mousedown', ··· 163 151 return; 164 152 } 165 153 166 - if (editor) { 167 - new JX.DifferentialInlineCommentEditor(config.uri) 168 - .setOperation('busy') 169 - .setRow(editor.getRow().previousSibling) 170 - .start(); 171 - return; 172 - } 173 - 174 154 if (selecting) { 175 155 return; 176 156 } ··· 290 270 origin = null; 291 271 target = null; 292 272 293 - set_link_state(true); 294 - 295 273 e.kill(); 296 274 }); 297 275 ··· 308 286 } else { 309 287 updateReticleForComment(e); 310 288 } 311 - }); 312 - 313 - var action_handler = function(op, e) { 314 - // NOTE: We prevent this event, rather than killing it, because some 315 - // actions are now handled by DiffChangesetList. 316 - e.prevent(); 317 - 318 - if (editor) { 319 - return; 320 - } 321 - 322 - var node = e.getNode('differential-inline-comment'); 323 - 324 - // If we're on a touch device, we didn't highlight the affected lines 325 - // earlier because we can't use hover events to mutate the document. 326 - // Highlight them now. 327 - updateReticleForComment(e); 328 - 329 - handle_inline_action(node, op); 330 - }; 331 - 332 - var handle_inline_action = function(node, op) { 333 - var data = JX.Stratcom.getData(node); 334 - 335 - var original = data.original; 336 - var reply_phid = null; 337 - if (op == 'reply') { 338 - // If the user hit "reply", the original text is empty (a new reply), not 339 - // the text of the comment they're replying to. 340 - original = ''; 341 - reply_phid = data.phid; 342 - } 343 - 344 - var row = JX.DOM.findAbove(node, 'tr'); 345 - var changeset_root = JX.DOM.findAbove( 346 - node, 347 - 'div', 348 - 'differential-changeset'); 349 - var view = JX.DiffChangeset.getForNode(changeset_root); 350 - 351 - editor = new JX.DifferentialInlineCommentEditor(config.uri) 352 - .setTemplates(view.getUndoTemplates()) 353 - .setOperation(op) 354 - .setID(data.id) 355 - .setChangesetID(data.changesetID) 356 - .setLineNumber(data.number) 357 - .setLength(data.length) 358 - .setOnRight(data.on_right) 359 - .setOriginalText(original) 360 - .setRow(row) 361 - .setTable(row.parentNode) 362 - .setReplyToCommentPHID(reply_phid) 363 - .setRenderer(view.getRenderer()) 364 - .start(); 365 - 366 - set_link_state(true); 367 - }; 368 - 369 - for (var op in {'reply': 1}) { 370 - JX.Stratcom.listen( 371 - 'click', 372 - ['differential-inline-comment', 'differential-inline-' + op], 373 - JX.bind(null, action_handler, op)); 374 - } 375 - 376 - JX.Stratcom.listen( 377 - 'differential-inline-action', 378 - null, 379 - function(e) { 380 - var data = e.getData(); 381 - handle_inline_action(data.node, data.op); 382 289 }); 383 290 384 291 });