Differential D12032 Diff 28963 webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js
Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js
| Show First 20 Lines • Show All 292 Lines • ▼ Show 20 Lines | var action_handler = function(op, e) { | ||||
| } | } | ||||
| var node = e.getNode('differential-inline-comment'); | var node = e.getNode('differential-inline-comment'); | ||||
| handle_inline_action(node, op); | handle_inline_action(node, op); | ||||
| }; | }; | ||||
| var handle_inline_action = function(node, op) { | var handle_inline_action = function(node, op) { | ||||
| var data = JX.Stratcom.getData(node); | var data = JX.Stratcom.getData(node); | ||||
| var row = node.parentNode.parentNode; | |||||
| var other_rows = []; | // If you click an action in the preview at the bottom of the page, we | ||||
| // find the corresponding node and simulate clicking that, if it's | |||||
| // present on the page. This gives the editor a more consistent view | |||||
| // of the document. | |||||
| if (JX.Stratcom.hasSigil(node, 'differential-inline-comment-preview')) { | if (JX.Stratcom.hasSigil(node, 'differential-inline-comment-preview')) { | ||||
| // The DOM structure around the comment is different if it's part of the | |||||
| // preview, so make sure not to pass the wrong container. | |||||
| row = node; | |||||
| if (op === 'delete') { | |||||
| // Furthermore, deleting a comment in the preview does not automatically | |||||
| // delete other occurrences of the same comment, so do that manually. | |||||
| var nodes = JX.DOM.scry( | var nodes = JX.DOM.scry( | ||||
| JX.DOM.getContentFrame(), | JX.DOM.getContentFrame(), | ||||
| 'div', | 'div', | ||||
| 'differential-inline-comment'); | 'differential-inline-comment'); | ||||
| for (var i = 0; i < nodes.length; ++i) { | |||||
| if (JX.Stratcom.getData(nodes[i]).id === data.id) { | var found = false; | ||||
| other_rows.push(nodes[i]); | var node_data; | ||||
| for (var ii = 0; ii < nodes.length; ++ii) { | |||||
| if (nodes[ii] == node) { | |||||
| // Don't match the preview itself. | |||||
| continue; | |||||
| } | |||||
| node_data = JX.Stratcom.getData(nodes[ii]); | |||||
| if (node_data.id == data.id) { | |||||
| node = nodes[ii]; | |||||
| data = node_data; | |||||
| found = true; | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| if (!found) { | |||||
| new JX.DifferentialInlineCommentEditor(config.uri) | |||||
| .deleteByID(data.id); | |||||
| return; | |||||
| } | } | ||||
| op = 'refdelete'; | |||||
| } | } | ||||
| var original = data.original; | var original = data.original; | ||||
| var reply_phid = null; | var reply_phid = null; | ||||
| if (op == 'reply') { | if (op == 'reply') { | ||||
| // If the user hit "reply", the original text is empty (a new reply), not | // If the user hit "reply", the original text is empty (a new reply), not | ||||
| // the text of the comment they're replying to. | // the text of the comment they're replying to. | ||||
| original = ''; | original = ''; | ||||
| reply_phid = data.phid; | reply_phid = data.phid; | ||||
| } | } | ||||
| var row = JX.DOM.findAbove(node, 'tr'); | |||||
| var changeset_root = JX.DOM.findAbove( | var changeset_root = JX.DOM.findAbove( | ||||
| node, | node, | ||||
| 'div', | 'div', | ||||
| 'differential-changeset'); | 'differential-changeset'); | ||||
| var view = JX.ChangesetViewManager.getForNode(changeset_root); | var view = JX.ChangesetViewManager.getForNode(changeset_root); | ||||
| editor = new JX.DifferentialInlineCommentEditor(config.uri) | editor = new JX.DifferentialInlineCommentEditor(config.uri) | ||||
| .setTemplates(view.getUndoTemplates()) | .setTemplates(view.getUndoTemplates()) | ||||
| .setOperation(op) | .setOperation(op) | ||||
| .setID(data.id) | .setID(data.id) | ||||
| .setChangesetID(data.changesetID) | .setChangesetID(data.changesetID) | ||||
| .setLineNumber(data.number) | .setLineNumber(data.number) | ||||
| .setLength(data.length) | .setLength(data.length) | ||||
| .setOnRight(data.on_right) | .setOnRight(data.on_right) | ||||
| .setOriginalText(original) | .setOriginalText(original) | ||||
| .setRow(row) | .setRow(row) | ||||
| .setOtherRows(other_rows) | |||||
| .setTable(row.parentNode) | .setTable(row.parentNode) | ||||
| .setReplyToCommentPHID(reply_phid) | .setReplyToCommentPHID(reply_phid) | ||||
| .setRenderer(view.getRenderer()) | .setRenderer(view.getRenderer()) | ||||
| .start(); | .start(); | ||||
| set_link_state(true); | set_link_state(true); | ||||
| }; | }; | ||||
| Show All 16 Lines | |||||